Fix incorrect output for single worker/control-plane clusters (#1209)

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2023-02-17 08:15:17 +01:00 committed by GitHub
parent 292f8eef21
commit d90828cb3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,8 +125,8 @@ func (c *createCmd) create(cmd *cobra.Command, creator cloudCreator, fileHandler
if !flags.yes {
// Ask user to confirm action.
cmd.Printf("The following Constellation cluster will be created:\n")
cmd.Printf("%d control-planes nodes of type %s will be created.\n", flags.controllerCount, instanceType)
cmd.Printf("%d worker nodes of type %s will be created.\n", flags.workerCount, instanceType)
cmd.Printf("%d control-plane node%s of type %s will be created.\n", flags.controllerCount, isPlural(flags.controllerCount), instanceType)
cmd.Printf("%d worker node%s of type %s will be created.\n", flags.workerCount, isPlural(flags.workerCount), instanceType)
ok, err := askToConfirm(cmd, "Do you want to create this cluster?")
if err != nil {
return err
@ -248,6 +248,13 @@ func translateCreateErrors(cmd *cobra.Command, err error) error {
}
}
func isPlural(count int) string {
if count == 1 {
return ""
}
return "s"
}
func must(err error) {
if err != nil {
panic(err)