diff --git a/cmd/lakectl/cmd/config.go b/cmd/lakectl/cmd/config.go index d8cf4335e7a..9f69cde5dc5 100644 --- a/cmd/lakectl/cmd/config.go +++ b/cmd/lakectl/cmd/config.go @@ -1,6 +1,7 @@ package cmd import ( + "errors" "fmt" "net/url" "path/filepath" @@ -11,6 +12,8 @@ import ( "github.com/spf13/viper" ) +var ErrInvalidEndpoint = errors.New("invalid endpoint") + // configCmd represents the config command var configCmd = &cobra.Command{ Use: "config", @@ -34,13 +37,13 @@ var configCmd = &cobra.Command{ }{ {Key: "credentials.access_key_id", Prompt: &promptui.Prompt{Label: "Access key ID"}}, {Key: "credentials.secret_access_key", Prompt: &promptui.Prompt{Label: "Secret access key", Mask: '*'}}, - {Key: "server.endpoint_url", Prompt: &promptui.Prompt{Label: "Server endpoint URL", Validate: func(rawURL string) error { + {Key: "server.endpoint_url", Prompt: &promptui.Prompt{Label: "Server endpoint", Validate: func(rawURL string) error { u, err := url.ParseRequestURI(rawURL) if err != nil { return err } if u.Path != "" { - fmt.Printf("Warning: It's recommended to configure the endpoint without specifying a path (%s)\n", u.Path) + return fmt.Errorf("%w: do not specify endpoint path", ErrInvalidEndpoint) } return nil }}},