Skip to content

Commit

Permalink
add back check for seeds and host
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Schmidt committed Jul 3, 2024
1 parent b58f6db commit ee7b061
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/indexCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ For example:
asvec index create -i myindex -n test -s testset -d 256 -m COSINE --%s vector \
--%s test --%s false
`, HelpTxtSetupEnv, flags.VectorField, flags.StorageNamespace, flags.BatchEnabled),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(indexCreateFlags.clientFlags.NewSLogAttr(),
Expand Down
3 changes: 3 additions & 0 deletions cmd/indexDrop.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ For example:
%s
asvec index drop -i myindex -n test
`, HelpTxtSetupEnv),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(indexDropFlags.clientFlags.NewSLogAttr(),
Expand Down
3 changes: 3 additions & 0 deletions cmd/indexList.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ For example:
%s
asvec index ls
`, flags.Verbose, HelpTxtSetupEnv),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(indexListFlags.clientFlags.NewSLogAttr(),
Expand Down
3 changes: 3 additions & 0 deletions cmd/rolesList.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ For example:
%s
asvec role ls
`, HelpTxtSetupEnv),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
rolesListFlags.clientFlags.NewSLogAttr()...,
Expand Down
3 changes: 3 additions & 0 deletions cmd/userCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ For example:
%s
asvec user create --%s foo --%s read-write
`, HelpTxtSetupEnv, flags.Name, flags.Roles),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(
Expand Down
3 changes: 3 additions & 0 deletions cmd/userDrop.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ For example:
%s
asvec user drop --%s foo
`, HelpTxtSetupEnv, flags.Name),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(
Expand Down
3 changes: 3 additions & 0 deletions cmd/userGrant.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ For example:
%s
asvec user grant --%s foo --%s admin
`, HelpTxtSetupEnv, flags.Name, flags.Roles),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(
Expand Down
3 changes: 3 additions & 0 deletions cmd/userList.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ For example:
%s
asvec user ls
`, HelpTxtSetupEnv),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
userListFlags.clientFlags.NewSLogAttr()...,
Expand Down
4 changes: 3 additions & 1 deletion cmd/userNewPassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ For example:
%s
asvec user new-password --%s foo
`, HelpTxtSetupEnv, flags.Name),

PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(
Expand Down
3 changes: 3 additions & 0 deletions cmd/userRevoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ For example:
%s
asvec user revoke --%s foo --%s admin
`, HelpTxtSetupEnv, flags.Name, flags.Roles),
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkSeedsAndHost()
},
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(
Expand Down
9 changes: 9 additions & 0 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"golang.org/x/term"

avs "github.com/aerospike/avs-client-go"
"github.com/spf13/viper"
)

func passwordPrompt(prompt string) (string, error) {
Expand Down Expand Up @@ -107,3 +108,11 @@ func confirm(prompt string) bool {

return strings.EqualFold(confirm, "y")
}

func checkSeedsAndHost() error {
if viper.IsSet(flags.Seeds) && viper.IsSet(flags.Host) {
return fmt.Errorf("only --%s or --%s allowed", flags.Seeds, flags.Host)
}

return nil
}

0 comments on commit ee7b061

Please sign in to comment.