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
2 changed files with 17 additions and 17 deletions
|
@ -141,18 +141,16 @@ cscli bouncers add MyBouncerName -l 24`,
|
|||
var cmdBouncersDelete = &cobra.Command{
|
||||
Use: "delete MyBouncerName",
|
||||
Short: "delete bouncer",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
DisableAutoGenTag: true,
|
||||
Run: func(cmd *cobra.Command, arg []string) {
|
||||
keyName := arg[0]
|
||||
if keyName == "" {
|
||||
log.Errorf("Please provide a bouncer name")
|
||||
return
|
||||
}
|
||||
err := dbClient.DeleteBouncer(keyName)
|
||||
if err != nil {
|
||||
log.Errorf("unable to delete bouncer: %s", err)
|
||||
return
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
for _, bouncerID := range args {
|
||||
err := dbClient.DeleteBouncer(bouncerID)
|
||||
if err != nil {
|
||||
log.Errorf("unable to delete bouncer: %s", err)
|
||||
return
|
||||
}
|
||||
log.Infof("bouncer '%s' deleted successfully", bouncerID)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ cscli machines add MyTestMachine --password MyPassword
|
|||
Use: "delete --machine MyTestMachine",
|
||||
Short: "delete machines",
|
||||
Example: `cscli machines delete "machine_name"`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
DisableAutoGenTag: true,
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
var err error
|
||||
|
@ -277,12 +277,14 @@ cscli machines add MyTestMachine --password MyPassword
|
|||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
machineID = args[0]
|
||||
err := dbClient.DeleteWatcher(machineID)
|
||||
if err != nil {
|
||||
log.Errorf("unable to delete machine: %s", err)
|
||||
return
|
||||
for _, machineID := range args {
|
||||
err := dbClient.DeleteWatcher(machineID)
|
||||
if err != nil {
|
||||
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")
|
||||
|
|
Loading…
Add table
Reference in a new issue