Skip to content

Commit 59922b2

Browse files
committed
revert GroupID back to settingsv2; filter out empty groups in the help output
1 parent 1cba8a4 commit 59922b2

File tree

8 files changed

+115
-41
lines changed

8 files changed

+115
-41
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
>>> [CLI] account --help
3+
Databricks Account Commands
4+
5+
Usage:
6+
databricks account [command]
7+
8+
Identity and Access Management
9+
access-control These APIs manage access rules on resources in an account.
10+
groups Groups simplify identity management, making it easier to assign access to Databricks account, data, and other securable objects.
11+
service-principals Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms.
12+
users User identities recognized by Databricks and represented by email addresses.
13+
workspace-assignment The Workspace Permission Assignment API allows you to manage workspace permissions for principals in your account.
14+
15+
Unity Catalog
16+
metastore-assignments These APIs manage metastore assignments to a workspace.
17+
metastores These APIs manage Unity Catalog metastores for an account.
18+
storage-credentials These APIs manage storage credentials for a particular metastore.
19+
20+
Settings
21+
ip-access-lists The Accounts IP Access List API enables account admins to configure IP access lists for access to the account console.
22+
network-connectivity These APIs provide configurations for the network connectivity of your workspaces for serverless compute resources.
23+
network-policies These APIs manage network policies for this account.
24+
settings Accounts Settings API allows users to manage settings at the account level.
25+
workspace-network-configuration These APIs allow configuration of network settings for Databricks workspaces by selecting which network policy to associate with the workspace.
26+
27+
Provisioning
28+
credentials These APIs manage credential configurations for this workspace.
29+
encryption-keys These APIs manage encryption key configurations for this workspace (optional).
30+
networks These APIs manage network configurations for customer-managed VPCs (optional).
31+
private-access These APIs manage private access settings for this account.
32+
storage These APIs manage storage configurations for this workspace.
33+
vpc-endpoints These APIs manage VPC endpoint configurations for this account.
34+
workspaces These APIs manage workspaces for this account.
35+
36+
Billing
37+
billable-usage This API allows you to download billable usage logs for the specified account and date range.
38+
budget-policy A service serves REST API about Budget policies.
39+
budgets These APIs manage budget configurations for this account.
40+
log-delivery These APIs manage log delivery configurations for this account.
41+
usage-dashboards These APIs manage usage dashboards for this account.
42+
43+
OAuth
44+
custom-app-integration These APIs enable administrators to manage custom OAuth app integrations, which is required for adding/using Custom OAuth App Integration like Tableau Cloud for Databricks in AWS cloud.
45+
federation-policy These APIs manage account federation policies.
46+
o-auth-published-apps These APIs enable administrators to view all the available published OAuth applications in Databricks.
47+
published-app-integration These APIs enable administrators to manage published OAuth app integrations, which is required for adding/using Published OAuth App Integration like Tableau Desktop for Databricks in AWS cloud.
48+
service-principal-federation-policy These APIs manage service principal federation policies.
49+
service-principal-secrets These APIs enable administrators to manage service principal secrets.
50+
51+
Flags:
52+
-h, --help help for account
53+
54+
Global Flags:
55+
--debug enable debug logging
56+
-o, --output type output type: text or json (default text)
57+
-p, --profile string ~/.databrickscfg profile
58+
-t, --target string bundle target to use (if applicable)
59+
60+
Use "databricks account [command] --help" for more information about a command.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trace $CLI account --help

cmd/account/cmd.go

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

cmd/account/groups.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func Groups() []cobra.Group {
1818
ID: "settings",
1919
Title: "Settings",
2020
},
21+
{
22+
ID: "settingsv2",
23+
Title: "Settings (v2)",
24+
},
2125
{
2226
ID: "provisioning",
2327
Title: "Provisioning",

cmd/account/settings-v2/settings-v2.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/cmd.go

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/databricks/cli/cmd/sync"
2020
"github.com/databricks/cli/cmd/version"
2121
"github.com/databricks/cli/cmd/workspace"
22+
"github.com/databricks/cli/libs/cmdgroup"
2223
"github.com/spf13/cobra"
2324
)
2425

@@ -27,41 +28,6 @@ const (
2728
permissionsGroup = "permissions"
2829
)
2930

30-
// filterGroups returns command groups that have at least one available (non-hidden) command.
31-
// Empty groups or groups with only hidden commands are filtered out from the help output.
32-
// Commands that belong to filtered groups will have their GroupID cleared.
33-
func filterGroups(groups []cobra.Group, allCommands []*cobra.Command) []cobra.Group {
34-
var filteredGroups []cobra.Group
35-
36-
// Create a map to track which groups have available commands
37-
groupHasAvailableCommands := make(map[string]bool)
38-
39-
// Check each command to see if it belongs to a group and is available
40-
for _, cmd := range allCommands {
41-
if cmd.GroupID != "" && cmd.IsAvailableCommand() {
42-
groupHasAvailableCommands[cmd.GroupID] = true
43-
}
44-
}
45-
46-
// Collect groups that have available commands
47-
validGroupIDs := make(map[string]bool)
48-
for _, group := range groups {
49-
if groupHasAvailableCommands[group.ID] {
50-
filteredGroups = append(filteredGroups, group)
51-
validGroupIDs[group.ID] = true
52-
}
53-
}
54-
55-
// Clear GroupID for commands that belong to filtered groups
56-
for _, cmd := range allCommands {
57-
if cmd.GroupID != "" && !validGroupIDs[cmd.GroupID] {
58-
cmd.GroupID = ""
59-
}
60-
}
61-
62-
return filteredGroups
63-
}
64-
6531
func New(ctx context.Context) *cobra.Command {
6632
cli := root.New(ctx)
6733

@@ -115,7 +81,7 @@ func New(ctx context.Context) *cobra.Command {
11581
// Add workspace command groups, filtering out empty groups or groups with only hidden commands.
11682
allGroups := workspace.Groups()
11783
allCommands := cli.Commands()
118-
filteredGroups := filterGroups(allGroups, allCommands)
84+
filteredGroups := cmdgroup.FilterGroups(allGroups, allCommands)
11985
for i := range filteredGroups {
12086
cli.AddGroup(&filteredGroups[i])
12187
}

libs/cmdgroup/command.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,38 @@ func tmpl(w io.Writer, text string, data any) error {
106106
template.Must(t.Parse(text))
107107
return t.Execute(w, data)
108108
}
109+
110+
// FilterGroups returns command groups that have at least one available (non-hidden) command.
111+
// Empty groups or groups with only hidden commands are filtered out from the help output.
112+
// Commands that belong to filtered groups will have their GroupID cleared.
113+
func FilterGroups(groups []cobra.Group, allCommands []*cobra.Command) []cobra.Group {
114+
var filteredGroups []cobra.Group
115+
116+
// Create a map to track which groups have available commands
117+
groupHasAvailableCommands := make(map[string]bool)
118+
119+
// Check each command to see if it belongs to a group and is available
120+
for _, cmd := range allCommands {
121+
if cmd.GroupID != "" && cmd.IsAvailableCommand() {
122+
groupHasAvailableCommands[cmd.GroupID] = true
123+
}
124+
}
125+
126+
// Collect groups that have available commands
127+
validGroupIDs := make(map[string]bool)
128+
for _, group := range groups {
129+
if groupHasAvailableCommands[group.ID] {
130+
filteredGroups = append(filteredGroups, group)
131+
validGroupIDs[group.ID] = true
132+
}
133+
}
134+
135+
// Clear GroupID for commands that belong to filtered groups
136+
for _, cmd := range allCommands {
137+
if cmd.GroupID != "" && !validGroupIDs[cmd.GroupID] {
138+
cmd.GroupID = ""
139+
}
140+
}
141+
142+
return filteredGroups
143+
}

0 commit comments

Comments
 (0)