Skip to content

Commit 5c40bca

Browse files
committed
update
1 parent 01e06ae commit 5c40bca

File tree

2 files changed

+70
-12
lines changed

2 files changed

+70
-12
lines changed

cmd/workspace/shares/overrides.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package shares
2+
3+
import (
4+
"github.com/databricks/cli/cmd/root"
5+
"github.com/databricks/cli/libs/cmdctx"
6+
"github.com/databricks/cli/libs/cmdio"
7+
"github.com/databricks/databricks-sdk-go/service/sharing"
8+
"github.com/spf13/cobra"
9+
)
10+
11+
func newList() *cobra.Command {
12+
cmd := &cobra.Command{}
13+
14+
var listReq sharing.ListSharesRequest
15+
16+
cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of shares to return.`)
17+
cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Opaque pagination token to go to next page based on previous query.`)
18+
19+
cmd.Use = "list"
20+
cmd.Short = `List shares (Deprecated).`
21+
cmd.Long = `List shares (Deprecated).
22+
23+
Gets an array of data object shares from the metastore. The caller must be a
24+
metastore admin or the owner of the share. There is no guarantee of a specific
25+
ordering of the elements in the array.`
26+
27+
cmd.Annotations = make(map[string]string)
28+
29+
cmd.Args = func(cmd *cobra.Command, args []string) error {
30+
check := root.ExactArgs(0)
31+
return check(cmd, args)
32+
}
33+
34+
cmd.PreRunE = root.MustWorkspaceClient
35+
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
36+
ctx := cmd.Context()
37+
w := cmdctx.WorkspaceClient(ctx)
38+
39+
response := w.Shares.List(ctx, listReq)
40+
return cmdio.RenderIterator(ctx, response)
41+
}
42+
43+
// Disable completions since they are not applicable.
44+
// Can be overridden by manual implementation in `override.go`.
45+
cmd.ValidArgsFunction = cobra.NoFileCompletions
46+
47+
return cmd
48+
}
49+
50+
func cmdOverride(cmd *cobra.Command) {
51+
// List command override is added here because the command is deprecated
52+
// and removed from the API definition. Use `list-shares` instead.
53+
cmd.AddCommand(newList())
54+
}
55+
56+
func init() {
57+
cmdOverrides = append(cmdOverrides, cmdOverride)
58+
}

cmd/workspace/shares/shares.go

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)