Skip to content

Commit

Permalink
Revert "EVEREST-1778 Ask user provide namespace name if it is missed …
Browse files Browse the repository at this point in the history
…in `everestctl namespaces add` command"

This reverts commit b76fe75.
  • Loading branch information
maxkondr committed Jan 10, 2025
1 parent 0820f46 commit af8b049
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
27 changes: 4 additions & 23 deletions commands/namespaces/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"os"

"github.com/AlecAivazis/survey/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/zap"
Expand All @@ -29,7 +28,7 @@ func NewAddCommand(l *zap.SugaredLogger) *cobra.Command {
Use: "add",
Long: "Add a new namespace",
Short: "Add a new namespace",
Example: `everestctl namespaces add ns-1 --operator.mongodb=true --operator.postgresql=true --operator.xtradb-cluster=true --skip-wizard`,
Example: `everestctl namespaces add [NAMESPACE] [FLAGS]`,
Run: func(cmd *cobra.Command, args []string) {
initAddViperFlags(cmd)
c := &namespaces.NamespaceAddConfig{}
Expand All @@ -40,29 +39,11 @@ func NewAddCommand(l *zap.SugaredLogger) *cobra.Command {
}
bindInstallHelmOpts(c)

if len(args) == 1 {
// user provided namespace name
c.Namespaces = args[0]
} else if c.SkipWizard {
// user didn't provide namespace name, but we can't ask him to provide it
output.PrintError(namespaces.ErrNamespaceIsMissed, l, true)
if len(args) != 1 {
output.PrintError(fmt.Errorf("invalid number of arguments: expected 1, got %d", len(args)), l, true)
os.Exit(1)
} else {
// ask user to provide namespace name
var resp string
q := &survey.Input{Message: "Enter namespace name"}
if err = survey.AskOne(q, &resp); err != nil {
output.PrintError(err, l, true)
os.Exit(1)
}

if resp == "" {
// user didn't provide namespace name
output.PrintError(namespaces.ErrNamespaceIsMissed, l, true)
os.Exit(1)
}
c.Namespaces = resp
}
c.Namespaces = args[0]

enableLogging := viper.GetBool("verbose") || viper.GetBool("json")
c.Pretty = !enableLogging
Expand Down
2 changes: 0 additions & 2 deletions pkg/cli/namespaces/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ var (
ErrNamespaceAlreadyExists = errors.New("namespace already exists")
// ErrNamespaceAlreadyOwned appears when the namespace is already owned by Everest.
ErrNamespaceAlreadyOwned = errors.New("namespace already exists and is managed by Everest")
// ErrNamespaceIsMissed appears when the namespace name is missed.
ErrNamespaceIsMissed = errors.New("namespace name is mandatory")
)

func (cfg *NamespaceAddConfig) validateNamespaceOwnership(
Expand Down

0 comments on commit af8b049

Please sign in to comment.