Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Schmidt committed Jun 28, 2024
1 parent 6743180 commit a2ad64b
Show file tree
Hide file tree
Showing 23 changed files with 1,082 additions and 270 deletions.
23 changes: 0 additions & 23 deletions cmd/drop.go

This file was deleted.

118 changes: 0 additions & 118 deletions cmd/dropIndex.go

This file was deleted.

11 changes: 10 additions & 1 deletion cmd/flags/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package flags
import (
"fmt"
"log/slog"
"time"

commonFlags "github.com/aerospike/tools-common-go/flags"
"github.com/spf13/pflag"
Expand All @@ -14,6 +15,7 @@ type ClientFlags struct {
ListenerName StringOptionalFlag
User StringOptionalFlag
Password commonFlags.PasswordFlag
Timeout time.Duration
TLSFlags
}

Expand All @@ -32,21 +34,28 @@ func (cf *ClientFlags) NewClientFlagSet() *pflag.FlagSet {
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.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))

return flagSet
}

func (cf *ClientFlags) NewSLogAttr() []any {
logPass := ""
if cf.Password.String() != "" {
logPass = "*"
}

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, cf.Password.String()),
slog.String(Password, logPass),
slog.Bool(TLSCaFile, cf.TLSRootCAFile != nil),
slog.Bool(TLSCaPath, cf.TLSRootCAPath != nil),
slog.Bool(TLSCertFile, cf.TLSCertFile != nil),
slog.Bool(TLSKeyFile, cf.TLSKeyFile != nil),
slog.Bool(TLSKeyFilePass, cf.TLSKeyFilePass != nil),
slog.Duration(Timeout, cf.Timeout),
}
}
7 changes: 7 additions & 0 deletions cmd/flags/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ const (
ListenerName = "listener-name"
User = "user"
Password = "password"
Username = "name"
NewUser = "create-user"
DropUser = "drop-user"
GrantUser = "grant-user"
RevokeUser = "revoke-user"
NewPassword = "new-password"
Roles = "roles"
Namespace = "namespace"
Sets = "sets"
IndexName = "index-name"
Expand Down
10 changes: 5 additions & 5 deletions cmd/create.go → cmd/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
"github.com/spf13/cobra"
)

// createCmd represents the create command
var createCmd = &cobra.Command{
Use: "create",
// indexCmd represents the create command
var indexCmd = &cobra.Command{
Use: "index",
Short: "A parent command for creating resources",
Long: `A parent command for creating resources. It currently only supports creating indexes.
For example:
export ASVEC_HOST=<avs-ip>:5000
asvec create index -i myindex -n test -s testset -f vector-field -d 256 -m COSINE
asvec index ---help
`,
}

func init() {
rootCmd.AddCommand(createCmd)
rootCmd.AddCommand(indexCmd)
}
Loading

0 comments on commit a2ad64b

Please sign in to comment.