From f2e9463413e36651bd4e05a5e2501771e002a95d Mon Sep 17 00:00:00 2001 From: Neha Viswanathan Date: Thu, 15 Dec 2016 10:09:19 -0800 Subject: [PATCH] removed capitalized error messages --- cmd/amp/config.go | 18 ++++-------------- cmd/amp/platform_manager.go | 8 ++++---- cmd/amp/registry.go | 8 ++++---- cmd/amp/topic-create.go | 4 ++-- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/cmd/amp/config.go b/cmd/amp/config.go index 2ea8d5604..bdb340a99 100644 --- a/cmd/amp/config.go +++ b/cmd/amp/config.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "fmt" "log" "strconv" @@ -16,21 +15,13 @@ 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 { @@ -38,7 +29,6 @@ func init() { } fmt.Println(f.Value()) case 2: - // Change one key s := structs.New(Config) f, ok := s.FieldOk(strings.Title(args[0])) if !ok { @@ -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 { diff --git a/cmd/amp/platform_manager.go b/cmd/amp/platform_manager.go index 5e222c378..a666e5e1f 100644 --- a/cmd/amp/platform_manager.go +++ b/cmd/amp/platform_manager.go @@ -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 @@ -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 @@ -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 { @@ -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) } diff --git a/cmd/amp/registry.go b/cmd/amp/registry.go index 626ab28b4..b219b82c8 100644 --- a/cmd/amp/registry.go +++ b/cmd/amp/registry.go @@ -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) @@ -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) @@ -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 } diff --git a/cmd/amp/topic-create.go b/cmd/amp/topic-create.go index 3979d50b1..b362732c0 100644 --- a/cmd/amp/topic-create.go +++ b/cmd/amp/topic-create.go @@ -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{