Skip to content

Commit

Permalink
Fix for issues #547,#561,#565
Browse files Browse the repository at this point in the history
  • Loading branch information
Neha Viswanathan committed Dec 14, 2016
1 parent 89340c6 commit bdc1a36
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion cmd/amp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func init() {
}
fmt.Println(f.Value())
default:
log.Fatal("too many arguments")
log.Fatal("Too many arguments")
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/amp/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

var loginCmd = &cobra.Command{
Use: "login",
Short: "Login via github",
Long: `Create a github access token and store it in your Config file to authenticate further commands`,
Short: "Login via GitHub",
Long: `Create a github access token and store it in your Config file to authenticate further commands.`,
RunE: func(cmd *cobra.Command, args []string) error {
err := AMP.Connect()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cmd/amp/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (

var logsCmd = &cobra.Command{
Use: "logs [OPTIONS] [SERVICE]",
Short: "Fetch log entries matching provided criteria. If provided, SERVICE can be a partial or full service id or service name.",
Short: "Fetch log entries matching provided criteria",
Long: `Fetch log entries matching provided criteria. If provided, SERVICE can be a partial or full service id or service name.`,
RunE: func(cmd *cobra.Command, args []string) error {
err := AMP.Connect()
if err != nil {
Expand Down
14 changes: 9 additions & 5 deletions cmd/amp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
Run: func(cmd *cobra.Command, args []string) {
if listVersion {
fmt.Printf("amp (cli version: %s, build: %s)\n", Version, Build)
cli.Exit(0)
}
fmt.Println(cmd.UsageString())
},
Expand Down Expand Up @@ -64,8 +65,8 @@ func main() {
// versionCmd represents the amp version
versionCmd := &cobra.Command{
Use: "version",
Short: "Display the version number of amp",
Long: `Display the version number of amp`,
Short: "Display amp version",
Long: `Display amp version.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("amp (cli version: %s, build: %s)\n", Version, Build)
},
Expand All @@ -82,14 +83,17 @@ func main() {
fmt.Printf("Server: %s\n", Config.ServerAddress)
},
}
RootCmd.AddCommand(infoCmd)

RootCmd.SetUsageTemplate(usageTemplate)
RootCmd.SetHelpTemplate(helpTemplate)

RootCmd.PersistentFlags().StringVar(&configFile, "config", "", "Config file (default is $HOME/.amp.yaml)")
RootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, `Verbose output`)
RootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Verbose output")
RootCmd.PersistentFlags().StringVar(&serverAddr, "server", "", "Server address")
RootCmd.Flags().BoolVarP(&listVersion, "version", "V", false, "Version number")
RootCmd.AddCommand(infoCmd)
RootCmd.PersistentFlags().BoolVarP(&listVersion, "version", "V", false, "Version number")
RootCmd.PersistentFlags().BoolP("help", "h", false, "Display help")

cmd, _, err := RootCmd.Find(os.Args[1:])
if err != nil {
fmt.Println(err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/amp/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

// PlatformCmd is the main command for attaching topic subcommands.
var PlatformCmd = &cobra.Command{
Use: "platform operations",
Short: "platform operations (alias: pf)",
Use: "platform",
Short: "Platform operations (alias: pf)",
Long: `Manage platform-related operations.`,
Aliases: []string{"pf"},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 2 additions & 2 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 @@ -182,7 +182,7 @@ func (s *ampManager) pull(stack *ampStack) error {
s.printf(colInfo, "+")
}
s.printf(colInfo, "\n")
s.printf(colSuccess, "image %s pulled\n", image)
s.printf(colSuccess, "Image %s pulled\n", image)

}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/amp/platform_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
var PlatformMonitor = &cobra.Command{
Use: "monitor",
Short: "Display AMP platform services",
Long: `Display AMP platform services information and states`,
Long: `Display AMP platform services information and states.`,
Run: func(cmd *cobra.Command, args []string) {
displayAMPServiceStatus(cmd, args)
},
Expand Down
6 changes: 3 additions & 3 deletions cmd/amp/platform_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
var PlatformPull = &cobra.Command{
Use: "pull",
Short: "Pull platform images",
Long: `Pull all AMP platform images`,
Long: `Pull all AMP platform images.`,
Run: func(cmd *cobra.Command, args []string) {
pullAMPImages(cmd, args)
},
}

func init() {
PlatformPull.Flags().BoolP("silence", "s", false, "no console output at all")
PlatformPull.Flags().BoolP("local", "l", false, "use local amp image")
PlatformPull.Flags().BoolP("silence", "s", false, "No console output at all")
PlatformPull.Flags().BoolP("local", "l", false, "Use local amp image")
PlatformCmd.AddCommand(PlatformPull)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/amp/platform_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var PlatformStart = &cobra.Command{

func init() {
PlatformStart.Flags().BoolP("force", "f", false, "Start all possible services, do not stop on error")
PlatformStart.Flags().BoolP("silence", "s", false, "no console output at all")
PlatformStart.Flags().BoolP("local", "l", false, "use local amp image")
PlatformStart.Flags().BoolP("silence", "s", false, "No console output at all")
PlatformStart.Flags().BoolP("local", "l", false, "Use local amp image")
PlatformCmd.AddCommand(PlatformStart)
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/amp/platform_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
var PlatformStatus = &cobra.Command{
Use: "status",
Short: "Get AMP platform status",
Long: `Get AMP platform global status (stopped, partially running, running command return 1 if status is not running`,
Long: `Get AMP platform global status (stopped, partially running, running command return 1 if status is not running.`,
Run: func(cmd *cobra.Command, args []string) {
getAMPStatus(cmd, args)
},
}

func init() {
PlatformStatus.Flags().BoolP("silence", "s", false, "no console output at all")
PlatformStatus.Flags().BoolP("local", "l", false, "use local amp image")
PlatformStatus.Flags().BoolP("silence", "s", false, "No console output at all")
PlatformStatus.Flags().BoolP("local", "l", false, "Use local amp image")
PlatformCmd.AddCommand(PlatformStatus)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/amp/platform_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var PlatformStop = &cobra.Command{
}

func init() {
PlatformStop.Flags().BoolP("silence", "s", false, "no console output at all")
PlatformStop.Flags().BoolP("local", "l", false, "use local amp image")
PlatformStop.Flags().BoolP("silence", "s", false, "No console output at all")
PlatformStop.Flags().BoolP("local", "l", false, "Use local amp image")
PlatformCmd.AddCommand(PlatformStop)
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/amp/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

// RegCmd is the main command for attaching registry subcommands.
var RegCmd = &cobra.Command{
Use: "registry operations",
Use: "registry",
Short: "Registry operations",
Long: `Manage registry-related operations.`,
}
Expand All @@ -31,15 +31,15 @@ var (
pushCmd = &cobra.Command{
Use: "push [image]",
Short: "Push an image to the amp registry",
Long: `Push an image to the amp registry`,
Long: `Push an image to the amp registry.`,
RunE: func(cmd *cobra.Command, args []string) error {
return RegistryPush(AMP, cmd, args)
},
}
reglsCmd = &cobra.Command{
Use: "ls",
Short: "List the amp registry images",
Long: `List the amp registry images`,
Long: `List the amp registry images.`,
RunE: func(cmd *cobra.Command, args []string) error {
return RegistryLs(AMP, cmd, args)
},
Expand Down Expand Up @@ -94,7 +94,7 @@ func RegistryPush(amp *client.AMP, cmd *cobra.Command, args []string) error {
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 All @@ -112,7 +112,7 @@ func RegistryPush(amp *client.AMP, cmd *cobra.Command, args []string) error {
return err
}
}
fmt.Printf("push image %s\n", taggedImage)
fmt.Printf("Push image %s\n", taggedImage)
resp, err := dclient.ImagePush(ctx, taggedImage, imagePushOptions)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions cmd/amp/service-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
serviceCreateCmd = &cobra.Command{
Use: "create [OPTIONS] IMAGE [CMD] [ARG...]",
Short: "Create a new service",
Long: `Create a new service`,
Long: `Create a new service.`,
RunE: func(cmd *cobra.Command, args []string) error {
return serviceCreate(AMP, cmd, args)
},
Expand Down Expand Up @@ -102,13 +102,13 @@ func serviceCreate(amp *client.AMP, cmd *cobra.Command, args []string) error {
case "global":
if replicas != 0 {
// global mode can't specify replicas (only allowed 1 per node)
log.Fatal("replicas can only be used with replicated mode")
log.Fatal("Replicas can only be used with replicated mode")
}
swarmMode = &service.ServiceSpec_Global{
Global: &service.GlobalService{},
}
default:
log.Fatalf("invalid option for mode: %s", mode)
log.Fatalf("Invalid option for mode: %s", mode)
}

spec := &service.ServiceSpec{
Expand Down
2 changes: 1 addition & 1 deletion cmd/amp/service-rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
serviceRmCmd = &cobra.Command{
Use: "rm [OPTIONS] SERVICE [SERVICE...]",
Short: "Remove one or more services",
Long: `Remove one or more services`,
Long: `Remove one or more services.`,
RunE: func(cmd *cobra.Command, args []string) error {
return serviceRm(AMP, cmd, args)
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/amp/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

// StackCmd is the main command for attaching stack subcommands.
var StackCmd = &cobra.Command{
Use: "stack operations",
Use: "stack",
Short: "Stack operations",
Long: `Manage stack-related operations.`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -46,7 +46,7 @@ var (
stackStartCmd = &cobra.Command{
Use: "start [stack name or id]",
Short: "Start a stopped stack",
Long: `Start a stopped stack`,
Long: `Start a stopped stack.`,
RunE: func(cmd *cobra.Command, args []string) error {
return stackStart(AMP, cmd, args)
},
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
4 changes: 2 additions & 2 deletions cmd/amp/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

// TopicCmd is the main command for attaching topic subcommands.
var TopicCmd = &cobra.Command{
Use: "topic operations",
Short: "topic operations",
Use: "topic",
Short: "Topic operations",
Long: `Manage topic-related operations.`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return AMP.Connect()
Expand Down
17 changes: 8 additions & 9 deletions cmd/amplifier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ var (
func parseFlags() {
var displayVersion bool

//
// set up flags
flag.StringVarP(&port, "port", "p", defaultPort, "server port (default '"+defaultPort+"')")
flag.StringVarP(&etcdEndpoints, "endpoints", "e", amp.EtcdDefaultEndpoint, "etcd comma-separated endpoints")
flag.StringVarP(&elasticsearchURL, "elasticsearchURL", "s", amp.ElasticsearchDefaultURL, "elasticsearch URL (default '"+amp.ElasticsearchDefaultURL+"')")
flag.StringVarP(&clientID, "clientid", "i", defaultClientID, "github app clientid (default '"+defaultClientID+"')")
flag.StringVarP(&clientSecret, "clientsecret", "c", defaultClientSecret, "github app clientsecret (default '"+defaultClientSecret+"')")
flag.StringVarP(&natsURL, "natsURL", "", amp.NatsDefaultURL, "Nats URL (default '"+amp.NatsDefaultURL+"')")
flag.StringVarP(&influxURL, "influxURL", "", amp.InfluxDefaultURL, "InfluxDB URL (default '"+amp.InfluxDefaultURL+"')")
flag.StringVar(&dockerURL, "dockerURL", amp.DockerDefaultURL, "Docker URL (default '"+amp.DockerDefaultURL+"')")
flag.StringVarP(&port, "port", "p", defaultPort, "Server port (default '"+defaultPort+"')")
flag.StringVarP(&etcdEndpoints, "endpoints", "e", amp.EtcdDefaultEndpoint, "Etcd comma-separated endpoints")
flag.StringVarP(&elasticsearchURL, "elasticsearch-url", "s", amp.ElasticsearchDefaultURL, "Elasticsearch URL (default '"+amp.ElasticsearchDefaultURL+"')")
flag.StringVarP(&clientID, "clientid", "i", defaultClientID, "GitHub app clientid (default '"+defaultClientID+"')")
flag.StringVarP(&clientSecret, "clientsecret", "c", defaultClientSecret, "GitHub app clientsecret (default '"+defaultClientSecret+"')")
flag.StringVarP(&natsURL, "nats-url", "", amp.NatsDefaultURL, "Nats URL (default '"+amp.NatsDefaultURL+"')")
flag.StringVarP(&influxURL, "influx-url", "", amp.InfluxDefaultURL, "InfluxDB URL (default '"+amp.InfluxDefaultURL+"')")
flag.StringVar(&dockerURL, "docker-url", amp.DockerDefaultURL, "Docker URL (default '"+amp.DockerDefaultURL+"')")
flag.BoolVarP(&displayVersion, "version", "v", false, "Print version information and quit")

// parse command line flags
Expand Down

0 comments on commit bdc1a36

Please sign in to comment.