Skip to content

Commit

Permalink
lakectl config validate endpoint doesn't include path
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder committed Sep 15, 2023
1 parent 50adc28 commit 8b1fea7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/lakectl/cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"net/url"
"path/filepath"
Expand All @@ -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",
Expand All @@ -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
}}},
Expand Down

0 comments on commit 8b1fea7

Please sign in to comment.