Skip to content

Commit

Permalink
removed capitalized error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Neha Viswanathan committed Dec 15, 2016
1 parent cf53bc3 commit f2e9463
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
18 changes: 4 additions & 14 deletions cmd/amp/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"encoding/json"
"fmt"
"log"
"strconv"
Expand All @@ -16,29 +15,20 @@ func init() {
// configCmd represents the Config command
configCmd := &cobra.Command{
Use: "config",
Short: "Display or update configuration",
Long: `With no argument, display the current configuration.
With one argument, display the value for this key
With two arguments, set the value for the key (respectively 2nd and 1st arg)`,
Short: "Display the current configuration",
Long: `Display the current configuration.`,
Run: func(cmd *cobra.Command, args []string) {
switch len(args) {
case 0:
// Display full configuration
j, err := json.MarshalIndent(structs.Map(Config), "", " ")
if err != nil {
fmt.Println("error:", err)
}
fmt.Println(string(j))
fmt.Println(Config)
case 1:
// Display one key
s := structs.New(Config)
f, ok := s.FieldOk(strings.Title(args[0]))
if !ok {
log.Fatalf("Field %s not found", strings.Title(args[0]))
}
fmt.Println(f.Value())
case 2:
// Change one key
s := structs.New(Config)
f, ok := s.FieldOk(strings.Title(args[0]))
if !ok {
Expand All @@ -54,7 +44,7 @@ func init() {
case "string":
f.Set(args[1])
default:
log.Fatal("unsupported field type")
log.Fatal("Unsupported field type")
}
err := cli.SaveConfiguration(Config)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cmd/amp/platform_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *ampManager) init(firstMessage string) error {
defaultHeaders := map[string]string{"User-Agent": "amplifier"}
cli, err := client.NewClient(DockerURL, DockerVersion, nil, defaultHeaders)
if err != nil {
return fmt.Errorf("Impossible to connect to Docker on: %s\n%v", DockerURL, err)
return fmt.Errorf("impossible to connect to Docker on: %s\n%v", DockerURL, err)
}
s.docker = cli
return nil
Expand Down Expand Up @@ -384,7 +384,7 @@ func (s *ampManager) updateServiceStates(service *ampService) error {
s.forceService(service)
return nil
}
return fmt.Errorf("Service %s startup timeout", service.name)
return fmt.Errorf("service %s startup timeout", service.name)
}
}
service.ready = false
Expand Down Expand Up @@ -466,7 +466,7 @@ func (s *ampManager) createService(service *ampService) error {
s.forceService(service)
return nil
}
return fmt.Errorf("Service %s image %s doesn't exist", service.name, service.image)
return fmt.Errorf("service %s image %s doesn't exist", service.name, service.image)
}
r, err := s.docker.ServiceCreate(s.ctx, *service.spec, options)
if err != nil {
Expand Down Expand Up @@ -598,7 +598,7 @@ func (s *ampManager) cleanVolume(name string) error {
return nil
}
if time.Now().Sub(started) > 30*time.Second {
return fmt.Errorf("Timeout waiting for all services removed")
return fmt.Errorf("timeout waiting for all services removed")
}
time.Sleep(1 * time.Second)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/amp/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func RegistryPush(amp *client.AMP, cmd *cobra.Command, args []string) error {
ac := types.AuthConfig{Username: "none"}
jsonString, err := json.Marshal(ac)
if err != nil {
return errors.New("Failed to marshal authconfig")
return errors.New("failed to marshal authconfig")
}
dst := make([]byte, base64.URLEncoding.EncodedLen(len(jsonString)))
base64.URLEncoding.Encode(dst, jsonString)
Expand All @@ -91,10 +91,10 @@ func RegistryPush(amp *client.AMP, cmd *cobra.Command, args []string) error {
image := args[0]
distributionRef, err := distreference.ParseNamed(image)
if err != nil {
return fmt.Errorf("Error parsing reference: %q is not a valid repository/tag", image)
return fmt.Errorf("error parsing reference: %q is not a valid repository/tag", image)
}
if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical {
return errors.New("Refusing to create a tag with a digest reference")
return errors.New("refusing to create a tag with a digest reference")
}
tag := reference.GetTagFromNamedRef(distributionRef)
hostname, name := distreference.SplitHostname(distributionRef)
Expand Down Expand Up @@ -124,7 +124,7 @@ func RegistryPush(amp *client.AMP, cmd *cobra.Command, args []string) error {
re := regexp.MustCompile(`: digest: sha256:`)
if !re.Match(body) {
fmt.Print(string(body))
return errors.New("Push failed")
return errors.New("push failed")
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/amp/topic-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func init() {

func createTopic(amp *client.AMP, cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("Must specify topic name")
return errors.New("must specify topic name")
}
name := args[0]
if name == "" {
return errors.New("Must specify topic name")
return errors.New("must specify topic name")
}

request := &topic.CreateRequest{Topic: &topic.TopicEntry{
Expand Down

0 comments on commit f2e9463

Please sign in to comment.