allow deleting multiple machines (#930)
* allow deleting multiple machines * allow multiple bouncers deletion Co-authored-by: AlteredCoder <AlteredCoder>
This commit is contained in:
parent
e54b5beb8d
commit
4aca9941cb
|
@ -141,18 +141,16 @@ cscli bouncers add MyBouncerName -l 24`,
|
||||||
var cmdBouncersDelete = &cobra.Command{
|
var cmdBouncersDelete = &cobra.Command{
|
||||||
Use: "delete MyBouncerName",
|
Use: "delete MyBouncerName",
|
||||||
Short: "delete bouncer",
|
Short: "delete bouncer",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
Run: func(cmd *cobra.Command, arg []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
keyName := arg[0]
|
for _, bouncerID := range args {
|
||||||
if keyName == "" {
|
err := dbClient.DeleteBouncer(bouncerID)
|
||||||
log.Errorf("Please provide a bouncer name")
|
if err != nil {
|
||||||
return
|
log.Errorf("unable to delete bouncer: %s", err)
|
||||||
}
|
return
|
||||||
err := dbClient.DeleteBouncer(keyName)
|
}
|
||||||
if err != nil {
|
log.Infof("bouncer '%s' deleted successfully", bouncerID)
|
||||||
log.Errorf("unable to delete bouncer: %s", err)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ cscli machines add MyTestMachine --password MyPassword
|
||||||
Use: "delete --machine MyTestMachine",
|
Use: "delete --machine MyTestMachine",
|
||||||
Short: "delete machines",
|
Short: "delete machines",
|
||||||
Example: `cscli machines delete "machine_name"`,
|
Example: `cscli machines delete "machine_name"`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
var err error
|
var err error
|
||||||
|
@ -277,12 +277,14 @@ cscli machines add MyTestMachine --password MyPassword
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
machineID = args[0]
|
machineID = args[0]
|
||||||
err := dbClient.DeleteWatcher(machineID)
|
for _, machineID := range args {
|
||||||
if err != nil {
|
err := dbClient.DeleteWatcher(machineID)
|
||||||
log.Errorf("unable to delete machine: %s", err)
|
if err != nil {
|
||||||
return
|
log.Errorf("unable to delete machine: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Infof("machine '%s' deleted successfully", machineID)
|
||||||
}
|
}
|
||||||
log.Infof("machine '%s' deleted successfully", machineID)
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmdMachinesDelete.Flags().StringVarP(&machineID, "machine", "m", "", "machine to delete")
|
cmdMachinesDelete.Flags().StringVarP(&machineID, "machine", "m", "", "machine to delete")
|
||||||
|
|
Loading…
Reference in a new issue