feat: support hetzner cloud server removal
All checks were successful
continuous-integration/drone/push Build is passing

Part of coop-cloud/organising#212.
This commit is contained in:
2021-11-03 08:34:36 +01:00
parent f57ae1e904
commit f041083604
3 changed files with 118 additions and 12 deletions

View File

@ -126,3 +126,31 @@ func ValidateSubCmdFlags(c *cli.Context) bool {
}
return true
}
// ValidateServer ensures the server name arg is valid.
func ValidateServer(c *cli.Context) (string, error) {
serverName := c.Args().First()
serverNames, err := config.ReadServerNames()
if err != nil {
return serverName, err
}
if serverName == "" && !NoInput {
prompt := &survey.Select{
Message: "Specify a server name",
Options: serverNames,
}
if err := survey.AskOne(prompt, &serverName); err != nil {
return serverName, err
}
}
if serverName == "" {
ShowSubcommandHelpAndError(c, errors.New("no server provided"))
}
logrus.Debugf("validated '%s' as server argument", serverName)
return serverName, nil
}