Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack rm q #230

Merged
merged 5 commits into from
Sep 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions cmd/amp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ var (

// All main does is process commands and flags and invoke the app
func main() {
fmt.Printf("amp (cli version: %s, build: %s)\n", Version, Build)

cobra.OnInitialize(func() {
InitConfig(configFile, &Config, verbose, serverAddr)
if addr := RootCmd.Flag("server").Value.String(); addr != "" {
Expand All @@ -43,7 +41,6 @@ func main() {
if Config.ServerAddress == "" {
Config.ServerAddress = client.DefaultServerAddress
}
fmt.Println("Server: " + Config.ServerAddress)
AMP = client.NewAMP(&Config)
AMP.Connect()
cli.AtExit(func() {
Expand All @@ -62,14 +59,24 @@ func main() {
fmt.Println(Config)
},
}

// infoCmd represents the amp information
infoCmd := &cobra.Command{
Use: "info",
Short: "Display amp version and server information",
Long: `Display amp version and server information.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("amp (cli version: %s, build: %s)\n", Version, Build)
fmt.Printf("Server: %s\n", Config.ServerAddress)
},
}
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().StringVar(&serverAddr, "server", "", "Server address")
RootCmd.AddCommand(configCmd)
RootCmd.AddCommand(infoCmd)
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
cli.Exit(-1)
Expand Down
24 changes: 13 additions & 11 deletions cmd/amp/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func init() {
RootCmd.AddCommand(StackCmd)
flags := upCmd.Flags()
flags.StringVarP(&stackfile, "file", "f", stackfile, "The name of the stackfile")
rmCmd.Flags().Bool("force", false, "Remove the stack whatever condition")
rmCmd.Flags().BoolP("force", "f", false, "Remove the stack whatever condition")
listCmd.Flags().BoolP("quiet", "q", false, "return only stack id to be use with grep")
StackCmd.AddCommand(upCmd)
StackCmd.AddCommand(startCmd)
Expand Down Expand Up @@ -186,18 +186,20 @@ func remove(amp *client.AMP, cmd *cobra.Command, args []string) error {
if cmd.Flag("force").Value.String() == "true" {
force = true
}
request := &stack.RemoveRequest{
StackIdent: ident,
Force: force,
}
for _, stackIdent := range args {
request := &stack.RemoveRequest{
StackIdent: stackIdent,
Force: force,
}

client := stack.NewStackServiceClient(amp.Conn)
reply, err := client.Remove(context.Background(), request)
if err != nil {
return err
}
client := stack.NewStackServiceClient(amp.Conn)
reply, err := client.Remove(context.Background(), request)
if err != nil {
return err
}

fmt.Println(reply)
fmt.Println(reply.StackId)
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion swarm
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ haproxy() { # Owner: freignat91
--label amp.swarm="infrastructure" \
-p 8080:8080 \
-p 80:80 \
appcelerator/haproxy:latest
appcelerator/haproxy:test2
}


Expand Down