Skip to content

Commit

Permalink
pass version to client creation
Browse files Browse the repository at this point in the history
  • Loading branch information
pmenglund committed Nov 5, 2023
1 parent 586eda0 commit 340e71c
Show file tree
Hide file tree
Showing 16 changed files with 344 additions and 319 deletions.
26 changes: 13 additions & 13 deletions cmd/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewListAliasesCmd() *cobra.Command {
ws, _ := cmd.Flags().GetString(flag.Workspace)

ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -58,7 +58,7 @@ func NewListAliasesCmd() *cobra.Command {
},
}
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.AllWorkspaces, "only show aliases for the selected workspace")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

return &cmd
}
Expand All @@ -74,12 +74,12 @@ func NewGetAliasCmd() *cobra.Command {
# Documentation URL
https://docs.rockset.com/documentation/reference/getalias`,
Annotations: group("alias"),
ValidArgsFunction: completion.Alias,
ValidArgsFunction: completion.Alias(Version),
RunE: func(cmd *cobra.Command, args []string) error {
ws, _ := cmd.Flags().GetString(flag.Workspace)

ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -93,7 +93,7 @@ func NewGetAliasCmd() *cobra.Command {
},
}
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "get an alias for the selected workspace")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

return &cmd
}
Expand All @@ -115,7 +115,7 @@ func NewCreateAliasCmd() *cobra.Command {
ws, _ := cmd.Flags().GetString(flag.Workspace)

ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -130,7 +130,7 @@ func NewCreateAliasCmd() *cobra.Command {
},
}
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "create alias in the selected workspace")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

return &cmd
}
Expand All @@ -147,14 +147,14 @@ func NewUpdateAliasCmd() *cobra.Command {
https://docs.rockset.com/documentation/reference/updatealias`,

Annotations: group("alias"),
ValidArgsFunction: completion.Alias,
ValidArgsFunction: completion.Alias(Version),
RunE: func(cmd *cobra.Command, args []string) error {
name := args[0]
collections := args[1:]
ws, _ := cmd.Flags().GetString(flag.Workspace)

ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -169,7 +169,7 @@ func NewUpdateAliasCmd() *cobra.Command {
},
}
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "create alias in the selected workspace")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

return &cmd
}
Expand All @@ -185,13 +185,13 @@ func NewDeleteAliasCmd() *cobra.Command {
# Documentation URL
https://docs.rockset.com/documentation/reference/deletealias`,
Annotations: group("alias"),
ValidArgsFunction: completion.Alias,
ValidArgsFunction: completion.Alias(Version),
RunE: func(cmd *cobra.Command, args []string) error {
name := args[0]
ws, _ := cmd.Flags().GetString(flag.Workspace)

ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -206,7 +206,7 @@ func NewDeleteAliasCmd() *cobra.Command {
},
}
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "delete alias for the selected workspace")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

return &cmd
}
26 changes: 13 additions & 13 deletions cmd/api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func NewListAPIKeysCmd() *cobra.Command {
Args: cobra.RangeArgs(0, 1),
Short: "list apikeys for the current user, or the specified USER",
Annotations: group("apikey"),
ValidArgsFunction: completion.Email,
ValidArgsFunction: completion.Alias(Version),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down Expand Up @@ -64,10 +64,10 @@ func NewGetAPIKeyCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
Short: "get apikey information",
Annotations: group("apikey"),
ValidArgsFunction: completion.APIKey,
ValidArgsFunction: completion.Alias(Version),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -87,7 +87,7 @@ func NewGetAPIKeyCmd() *cobra.Command {
}

cmd.Flags().String(flag.Email, "", "the email address of the user who's key to get, defaults to self")
_ = cmd.RegisterFlagCompletionFunc(flag.Email, completion.Email)
_ = cmd.RegisterFlagCompletionFunc(flag.Email, completion.Alias(Version))

return &cmd
}
Expand All @@ -99,10 +99,10 @@ func NewDeleteAPIKeyCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
Short: "delete an apikey",
Annotations: group("apikey"),
ValidArgsFunction: completion.APIKey,
ValidArgsFunction: completion.Alias(Version),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -124,7 +124,7 @@ func NewDeleteAPIKeyCmd() *cobra.Command {
}

cmd.Flags().String(flag.Email, "", "the email address of the user who's key to delete, defaults to self")
_ = cmd.RegisterFlagCompletionFunc(flag.Email, completion.Email)
_ = cmd.RegisterFlagCompletionFunc(flag.Email, completion.Alias(Version))

return &cmd
}
Expand All @@ -138,7 +138,7 @@ func NewCreateAPIKeyCmd() *cobra.Command {
Annotations: group("apikey"),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -160,7 +160,7 @@ func NewCreateAPIKeyCmd() *cobra.Command {
}

cmd.Flags().String(flag.Role, "", "role for the apikey")
_ = cmd.RegisterFlagCompletionFunc(flag.Role, completion.Role)
_ = cmd.RegisterFlagCompletionFunc(flag.Role, completion.Role(Version))

return &cmd
}
Expand All @@ -172,10 +172,10 @@ func newUpdateAPIKeyCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
Short: "update the state of an apikey",
Annotations: group("apikey"),
ValidArgsFunction: completion.APIKey,
ValidArgsFunction: completion.Alias(Version),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -199,7 +199,7 @@ func newUpdateAPIKeyCmd() *cobra.Command {
}

cmd.Flags().String(flag.Email, "", "the email address of the user who's key to update, defaults to self")
_ = cmd.RegisterFlagCompletionFunc(flag.Email, completion.Email)
_ = cmd.RegisterFlagCompletionFunc(flag.Email, completion.Alias(Version))

cmd.Flags().String(flag.State, "",
fmt.Sprintf("the state of the apikey, either %s or %s", option.KeyActive, option.KeySuspended))
Expand Down
2 changes: 1 addition & 1 deletion cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func newAuthKeyCmd() *cobra.Command {
name := args[0]
role := args[1]

rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down
30 changes: 15 additions & 15 deletions cmd/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ func newDeleteCollectionCmd() *cobra.Command {
Long: "delete Rockset collection",
Annotations: group("collection"),
Args: cobra.ExactArgs(1),
ValidArgsFunction: completion.Collection,
ValidArgsFunction: completion.Collection(Version),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -51,7 +51,7 @@ func newDeleteCollectionCmd() *cobra.Command {
}

cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "workspace for the collection")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

return &cmd
}
Expand All @@ -64,14 +64,14 @@ func newGetCollectionCmd() *cobra.Command {
Long: "get Rockset collection",
Annotations: group("collection"),
Args: cobra.ExactArgs(1),
ValidArgsFunction: completion.Collection,
ValidArgsFunction: completion.Collection(Version),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
ws, _ := cmd.Flags().GetString(flag.Workspace)
output, _ := cmd.Flags().GetString("output")
name := args[0]

rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func newGetCollectionCmd() *cobra.Command {

cmd.Flags().Bool(flag.Wide, false, "display more information")
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "workspace for the collection")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

cmd.Flags().String("output", "", "save json for create collection request to output file, use `-` for stdout")
_ = cobra.MarkFlagFilename(cmd.Flags(), "output")
Expand All @@ -120,7 +120,7 @@ func newListCollectionsCmd() *cobra.Command {
ctx := cmd.Context()
ws, _ := cmd.Flags().GetString(flag.Workspace)

rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down Expand Up @@ -149,7 +149,7 @@ func newListCollectionsCmd() *cobra.Command {

cmd.Flags().Bool(flag.Wide, false, "display more information")
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.AllWorkspaces, "workspace for the collection")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

return &cmd
}
Expand All @@ -173,7 +173,7 @@ func newCreateCollectionCmd() *cobra.Command {

options := getCommonCollectionFlags(cmd)

rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down Expand Up @@ -253,7 +253,7 @@ func newCreateS3CollectionCmd() *cobra.Command {

options = append(options, option.WithS3Source(integration, bucket, option.WithJSONFormat(), s3Opts...))

rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand All @@ -276,7 +276,7 @@ func newCreateS3CollectionCmd() *cobra.Command {
cmd.Flags().String("source-format", "json", "data source format")

_ = cobra.MarkFlagRequired(cmd.Flags(), flag.Integration)
_ = cmd.RegisterFlagCompletionFunc(flag.Integration, completion.Integration)
_ = cmd.RegisterFlagCompletionFunc(flag.Integration, completion.Integration(Version))

_ = cobra.MarkFlagRequired(cmd.Flags(), flag.Bucket)

Expand Down Expand Up @@ -315,7 +315,7 @@ func newCreateSampleCollectionCmd() *cobra.Command {

options = append(options, option.WithSampleDataset(ds), option.WithSampleDatasetPattern(pattern))

rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down Expand Up @@ -357,7 +357,7 @@ func newCreateTailCollectionCmd() *cobra.Command {
frequency, _ := cmd.Flags().GetDuration("frequency")
timeField, _ := cmd.Flags().GetString("time-field")

rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down Expand Up @@ -403,7 +403,7 @@ ORDER BY c.%s ASC`,
cmd.Flags().String("time-field", "_event_time", "field name for the time")

cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "workspace for the collection")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

return &cmd
}
Expand Down Expand Up @@ -433,7 +433,7 @@ func waitForCollection(ctx context.Context, cmd *cobra.Command, rs *rockset.Rock

func addCommonCollectionFlags(cmd *cobra.Command) {
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "workspace for the collection")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

cmd.Flags().String(flag.Description, "", "collection description")
cmd.Flags().Duration(flag.Retention, 0, "collection retention")
Expand Down
16 changes: 8 additions & 8 deletions cmd/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func newDeleteDocumentsCmd() *cobra.Command {
coll, _ := cmd.Flags().GetString("collection")

ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down Expand Up @@ -52,12 +52,12 @@ func newDeleteDocumentsCmd() *cobra.Command {
},
}

cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.Description, "workspace name")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "workspace name")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

cmd.Flags().String(flag.Collection, "", "collection name")
_ = cmd.MarkFlagRequired(flag.Collection)
_ = cmd.RegisterFlagCompletionFunc(flag.Collection, completion.Collection)
_ = cmd.RegisterFlagCompletionFunc(flag.Collection, completion.Collection(Version))

return &cmd
}
Expand All @@ -73,7 +73,7 @@ func newIngestCmd() *cobra.Command {
batchSize, _ := cmd.Flags().GetUint64("batch-size")

ctx := cmd.Context()
rs, err := config.Client(cmd)
rs, err := config.Client(cmd, Version)
if err != nil {
return err
}
Expand Down Expand Up @@ -106,12 +106,12 @@ func newIngestCmd() *cobra.Command {
},
}

cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.Description, "workspace name")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace)
cmd.Flags().StringP(flag.Workspace, flag.WorkspaceShort, flag.DefaultWorkspace, "workspace name")
_ = cmd.RegisterFlagCompletionFunc(flag.Workspace, completion.Workspace(Version))

cmd.Flags().String(flag.Collection, "", "collection name")
_ = cobra.MarkFlagRequired(cmd.Flags(), flag.Collection)
_ = cmd.RegisterFlagCompletionFunc(flag.Collection, completion.Collection)
_ = cmd.RegisterFlagCompletionFunc(flag.Collection, completion.Collection(Version))

cmd.Flags().Uint64("batch-size", 100,
"number of documents to batch together each write")
Expand Down
Loading

0 comments on commit 340e71c

Please sign in to comment.