Skip to content

Commit

Permalink
Update to 0.5.1 for all tests, use --name for user cmds, add --yes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Schmidt committed Jul 1, 2024
1 parent a2ad64b commit 7e30e7f
Show file tree
Hide file tree
Showing 18 changed files with 322 additions and 104 deletions.
8 changes: 4 additions & 4 deletions cmd/flags/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func (cf *ClientFlags) NewClientFlagSet() *pflag.FlagSet {
flagSet.VarP(cf.Host, Host, "h", commonFlags.DefaultWrapHelpString(fmt.Sprintf("The AVS host to connect to. If cluster discovery is needed use --%s", Seeds))) //nolint:lll // For readability
flagSet.Var(cf.Seeds, Seeds, commonFlags.DefaultWrapHelpString(fmt.Sprintf("The AVS seeds to use for cluster discovery. If no cluster discovery is needed (i.e. load-balancer) then use --%s", Host))) //nolint:lll // For readability
flagSet.VarP(&cf.ListenerName, ListenerName, "l", commonFlags.DefaultWrapHelpString("The listener to ask the AVS server for as configured in the AVS server. Likely required for cloud deployments.")) //nolint:lll // For readability
flagSet.VarP(&cf.User, User, "U", commonFlags.DefaultWrapHelpString("The AVS user to authenticate with.")) //nolint:lll // For readability
flagSet.VarP(&cf.Password, Password, "P", commonFlags.DefaultWrapHelpString("The AVS password for the specified user.")) //nolint:lll // For readability
flagSet.VarP(&cf.User, AuthUser, "U", commonFlags.DefaultWrapHelpString("The AVS user to authenticate with.")) //nolint:lll // For readability
flagSet.VarP(&cf.Password, AuthPassword, "P", commonFlags.DefaultWrapHelpString("The AVS password for the specified user.")) //nolint:lll // For readability
flagSet.DurationVar(&cf.Timeout, Timeout, time.Second*5, commonFlags.DefaultWrapHelpString("The timeout to use for each request to AVS")) //nolint:lll // For readability
flagSet.AddFlagSet(cf.NewTLSFlagSet(commonFlags.DefaultWrapHelpString))

Expand All @@ -49,8 +49,8 @@ func (cf *ClientFlags) NewSLogAttr() []any {
return []any{slog.String(Host, cf.Host.String()),
slog.String(Seeds, cf.Seeds.String()),
slog.String(ListenerName, cf.ListenerName.String()),
slog.String(User, cf.User.String()),
slog.String(Password, logPass),
slog.String(AuthUser, cf.User.String()),
slog.String(AuthPassword, logPass),
slog.Bool(TLSCaFile, cf.TLSRootCAFile != nil),
slog.Bool(TLSCaPath, cf.TLSRootCAPath != nil),
slog.Bool(TLSCertFile, cf.TLSCertFile != nil),
Expand Down
9 changes: 3 additions & 6 deletions cmd/flags/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ const (
Seeds = "seeds"
Host = "host"
ListenerName = "listener-name"
User = "user"
Password = "password"
AuthUser = "user"
AuthPassword = "password"
Username = "name"
NewUser = "create-user"
DropUser = "drop-user"
GrantUser = "grant-user"
RevokeUser = "revoke-user"
NewPassword = "new-password"
Roles = "roles"
Namespace = "namespace"
Sets = "sets"
Yes = "yes"
IndexName = "index-name"
VectorField = "vector-field"
Dimension = "dimension"
Expand Down
7 changes: 5 additions & 2 deletions cmd/indexCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
//nolint:govet // Padding not a concern for a CLI
var indexCreateFlags = &struct {
clientFlags flags.ClientFlags
yes bool
namespace string
sets []string
indexName string
Expand Down Expand Up @@ -48,7 +49,8 @@ var indexCreateFlags = &struct {
}

func newIndexCreateFlagSet() *pflag.FlagSet {
flagSet := &pflag.FlagSet{} //nolint:lll // For readability
flagSet := &pflag.FlagSet{}
flagSet.BoolVarP(&indexCreateFlags.yes, flags.Yes, "y", false, commonFlags.DefaultWrapHelpString("When true do not prompt for confirmation.")) //nolint:lll // For readability
flagSet.StringVarP(&indexCreateFlags.namespace, flags.Namespace, "n", "", commonFlags.DefaultWrapHelpString("The namespace for the index.")) //nolint:lll // For readability
flagSet.StringSliceVarP(&indexCreateFlags.sets, flags.Sets, "s", nil, commonFlags.DefaultWrapHelpString("The sets for the index.")) //nolint:lll // For readability
flagSet.StringVarP(&indexCreateFlags.indexName, flags.IndexName, "i", "", commonFlags.DefaultWrapHelpString("The name of the index.")) //nolint:lll // For readability
Expand Down Expand Up @@ -103,6 +105,7 @@ func newIndexCreateCmd() *cobra.Command {
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(indexCreateFlags.clientFlags.NewSLogAttr(),
slog.Bool(flags.Yes, indexCreateFlags.yes),
slog.String(flags.Namespace, indexCreateFlags.namespace),
slog.Any(flags.Sets, indexCreateFlags.sets),
slog.String(flags.IndexName, indexCreateFlags.indexName),
Expand Down Expand Up @@ -150,7 +153,7 @@ func newIndexCreateCmd() *cobra.Command {
},
}

if !confirm(fmt.Sprintf(
if !indexCreateFlags.yes && !confirm(fmt.Sprintf(
"Are you sure you want to create the index %s field %s?",
nsAndSetString(
indexCreateFlags.namespace,
Expand Down
5 changes: 4 additions & 1 deletion cmd/indexDrop.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
//nolint:govet // Padding not a concern for a CLI
var indexDropFlags = &struct {
clientFlags flags.ClientFlags
yes bool
namespace string
sets []string
indexName string
Expand All @@ -27,6 +28,7 @@ var indexDropFlags = &struct {

func newIndexDropFlagSet() *pflag.FlagSet {
flagSet := &pflag.FlagSet{}
flagSet.BoolVarP(&indexDropFlags.yes, flags.Yes, "y", false, commonFlags.DefaultWrapHelpString("When true do not prompt for confirmation."))
flagSet.StringVarP(&indexDropFlags.namespace, flags.Namespace, "n", "", commonFlags.DefaultWrapHelpString("The namespace for the index.")) //nolint:lll // For readability
flagSet.StringSliceVarP(&indexDropFlags.sets, flags.Sets, "s", nil, commonFlags.DefaultWrapHelpString("The sets for the index.")) //nolint:lll // For readability
flagSet.StringVarP(&indexDropFlags.indexName, flags.IndexName, "i", "", commonFlags.DefaultWrapHelpString("The name of the index.")) //nolint:lll // For readability
Expand Down Expand Up @@ -62,6 +64,7 @@ func newIndexDropCommand() *cobra.Command {
RunE: func(_ *cobra.Command, _ []string) error {
logger.Debug("parsed flags",
append(indexDropFlags.clientFlags.NewSLogAttr(),
slog.Bool(flags.Yes, indexDropFlags.yes),
slog.String(flags.Namespace, indexDropFlags.namespace),
slog.Any(flags.Sets, indexDropFlags.sets),
slog.String(flags.IndexName, indexDropFlags.indexName),
Expand All @@ -74,7 +77,7 @@ func newIndexDropCommand() *cobra.Command {
}
defer adminClient.Close()

if !confirm(fmt.Sprintf(
if !indexDropFlags.yes && !confirm(fmt.Sprintf(
"Are you sure you want to drop the index %s on field %s?",
nsAndSetString(
indexCreateFlags.namespace,
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func init() {
common.SetupRoot(rootCmd, "aerospike-vector-search", "0.0.0") // TODO: Handle version
viper.SetEnvPrefix("ASVEC")

bindEnvs := []string{flags.Host, flags.Seeds, flags.User, flags.Password}
bindEnvs := []string{flags.Host, flags.Seeds, flags.AuthUser, flags.AuthPassword}

// Bind specified flags to ASVEC_*
for _, env := range bindEnvs {
Expand Down
6 changes: 3 additions & 3 deletions cmd/userCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ var userCreateFlags = &struct {
func newUserCreateFlagSet() *pflag.FlagSet {
flagSet := &pflag.FlagSet{} //nolint:lll // For readability //nolint:lll // For readability
flagSet.AddFlagSet(userCreateFlags.clientFlags.NewClientFlagSet())
flagSet.StringVar(&userCreateFlags.newUsername, flags.NewUser, "", "TODO")
flagSet.StringVar(&userCreateFlags.newUsername, flags.Username, "", "TODO")
flagSet.StringVar(&userCreateFlags.newPassword, flags.NewPassword, "", "TODO")
flagSet.StringSliceVar(&userCreateFlags.roles, flags.Roles, []string{}, "TODO")

return flagSet
}

var userCreateRequiredFlags = []string{
flags.NewUser,
flags.Username,
flags.Roles,
}

Expand All @@ -52,7 +52,7 @@ func newUserCreateCmd() *cobra.Command {
logger.Debug("parsed flags",
append(
userCreateFlags.clientFlags.NewSLogAttr(),
slog.String(flags.NewUser, userCreateFlags.newUsername),
slog.String(flags.Username, userCreateFlags.newUsername),
slog.Any(flags.Roles, userCreateFlags.roles),
)...,
)
Expand Down
6 changes: 3 additions & 3 deletions cmd/userDrop.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ var userDropFlags = &struct {
func newUserDropFlagSet() *pflag.FlagSet {
flagSet := &pflag.FlagSet{} //nolint:lll // For readability //nolint:lll // For readability
flagSet.AddFlagSet(userDropFlags.clientFlags.NewClientFlagSet())
flagSet.StringVar(&userDropFlags.dropUser, flags.DropUser, "", "TODO")
flagSet.StringVar(&userDropFlags.dropUser, flags.Username, "", "TODO")

return flagSet
}

var userDropRequiredFlags = []string{
flags.DropUser,
flags.Username,
}

func newUserDropCmd() *cobra.Command {
Expand All @@ -46,7 +46,7 @@ func newUserDropCmd() *cobra.Command {
logger.Debug("parsed flags",
append(
userDropFlags.clientFlags.NewSLogAttr(),
slog.String(flags.NewUser, userDropFlags.dropUser),
slog.String(flags.Username, userDropFlags.dropUser),
)...,
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/userGrant.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ var userGrantFlags = &struct {
func newUserGrantFlagSet() *pflag.FlagSet {
flagSet := &pflag.FlagSet{} //nolint:lll // For readability //nolint:lll // For readability
flagSet.AddFlagSet(userGrantFlags.clientFlags.NewClientFlagSet())
flagSet.StringVar(&userGrantFlags.grantUser, flags.GrantUser, "", "TODO")
flagSet.StringVar(&userGrantFlags.grantUser, flags.Username, "", "TODO")
flagSet.StringSliceVar(&userGrantFlags.roles, flags.Roles, []string{}, "TODO")

return flagSet
}

var userGrantRequiredFlags = []string{
flags.GrantUser,
flags.Username,
flags.Roles,
}

Expand All @@ -50,7 +50,7 @@ func newUserGrantCmd() *cobra.Command {
logger.Debug("parsed flags",
append(
userGrantFlags.clientFlags.NewSLogAttr(),
slog.String(flags.NewUser, userGrantFlags.grantUser),
slog.String(flags.Username, userGrantFlags.grantUser),
slog.Any(flags.Roles, userGrantFlags.roles),
)...,
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/userNewPassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func newUserNewPasswordCmd() *cobra.Command {
logger.Debug("parsed flags",
append(
userNewPassFlags.clientFlags.NewSLogAttr(),
slog.String(flags.NewUser, userNewPassFlags.username),
slog.String(flags.Username, userNewPassFlags.username),
slog.Any(flags.Roles, userNewPassFlags.roles),
)...,
)
Expand Down
6 changes: 3 additions & 3 deletions cmd/userRevoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ var userRevokeFlags = &struct {
func newUserRevokeFlagSet() *pflag.FlagSet {
flagSet := &pflag.FlagSet{} //nolint:lll // For readability //nolint:lll // For readability
flagSet.AddFlagSet(userRevokeFlags.clientFlags.NewClientFlagSet())
flagSet.StringVar(&userRevokeFlags.revokeUser, flags.RevokeUser, "", "TODO")
flagSet.StringVar(&userRevokeFlags.revokeUser, flags.Username, "", "TODO")
flagSet.StringSliceVar(&userRevokeFlags.roles, flags.Roles, []string{}, "TODO")

return flagSet
}

var userRevokeRequiredFlags = []string{
flags.RevokeUser,
flags.Username,
flags.Roles,
}

Expand All @@ -59,7 +59,7 @@ func newUserRevokeCmd() *cobra.Command {
logger.Debug("parsed flags",
append(
userRevokeFlags.clientFlags.NewSLogAttr(),
slog.String(flags.NewUser, userRevokeFlags.revokeUser),
slog.String(flags.Username, userRevokeFlags.revokeUser),
slog.Any(flags.Roles, userRevokeFlags.roles),
)...,
)
Expand Down
2 changes: 1 addition & 1 deletion docker/auth/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "--config-file"
- "/opt/aerospike/etc/aerospike/aerospike.conf"
avs:
image: aerospike.jfrog.io/docker/aerospike/aerospike-proximus-private:0.5.0-SNAPSHOT
image: aerospike.jfrog.io/docker/aerospike/aerospike-proximus-private:0.5.1-SNAPSHOT
ports:
- "10000:10000"
networks:
Expand Down
10 changes: 5 additions & 5 deletions docker/config/aerospike-proximus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ cluster:
# The Proximus service listening ports, TLS and network interface.
service:
ports:
10000: {}
advertised-listeners:
default:
address: 127.0.0.1
port: 10000
10000:
advertised-listeners:
default:
address: 127.0.0.1
port: 10000

# Management API listening ports, TLS and network interface.
manage:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "--config-file"
- "/opt/aerospike/etc/aerospike/aerospike.conf"
avs:
image: aerospike/aerospike-proximus:0.4.0
image: aerospike.jfrog.io/docker/aerospike/aerospike-proximus-private:0.5.1-SNAPSHOT
ports:
- "10000:10000"
networks:
Expand Down
2 changes: 1 addition & 1 deletion docker/mtls/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "--config-file"
- "/opt/aerospike/etc/aerospike/aerospike.conf"
avs:
image: aerospike.jfrog.io/docker/aerospike/aerospike-proximus-private:0.5.0-SNAPSHOT
image: aerospike.jfrog.io/docker/aerospike/aerospike-proximus-private:0.5.1-SNAPSHOT
ports:
- "10000:10000"
networks:
Expand Down
2 changes: 1 addition & 1 deletion docker/tls/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "--config-file"
- "/opt/aerospike/etc/aerospike/aerospike.conf"
avs:
image: aerospike.jfrog.io/docker/aerospike/aerospike-proximus-private:0.5.0-SNAPSHOT
image: aerospike.jfrog.io/docker/aerospike/aerospike-proximus-private:0.5.1-SNAPSHOT
ports:
- "10000:10000"
networks:
Expand Down
Loading

0 comments on commit 7e30e7f

Please sign in to comment.