Skip to content

Commit 361c242

Browse files
authored
Autogenerate command groups for help output (#3967)
## Changes Autogenerate command groups from the groups we use for the API documentation. Update group IDs to match those where applicable. The sort order in the help output now matches the sort order on our [API documentation](https://docs.databricks.com/api/workspace). ## Why The groups had gone stale and the help output didn't properly attribute generated commands to the right groups. ## Tests See acceptance tests.
1 parent 4bdab3c commit 361c242

File tree

12 files changed

+92
-90
lines changed

12 files changed

+92
-90
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cmd/account/encryption-keys/encryption-keys.go linguist-generated=true
1212
cmd/account/esm-enablement-account/esm-enablement-account.go linguist-generated=true
1313
cmd/account/federation-policy/federation-policy.go linguist-generated=true
1414
cmd/account/groups-v2/groups-v2.go linguist-generated=true
15+
cmd/account/groups.go linguist-generated=true
1516
cmd/account/iam-v2/iam-v2.go linguist-generated=true
1617
cmd/account/ip-access-lists/ip-access-lists.go linguist-generated=true
1718
cmd/account/llm-proxy-partner-powered-account/llm-proxy-partner-powered-account.go linguist-generated=true
@@ -97,6 +98,7 @@ cmd/workspace/git-credentials/git-credentials.go linguist-generated=true
9798
cmd/workspace/global-init-scripts/global-init-scripts.go linguist-generated=true
9899
cmd/workspace/grants/grants.go linguist-generated=true
99100
cmd/workspace/groups-v2/groups-v2.go linguist-generated=true
101+
cmd/workspace/groups.go linguist-generated=true
100102
cmd/workspace/instance-pools/instance-pools.go linguist-generated=true
101103
cmd/workspace/instance-profiles/instance-profiles.go linguist-generated=true
102104
cmd/workspace/ip-access-lists/ip-access-lists.go linguist-generated=true

acceptance/cmd/account/account-help/output.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Identity and Access Management
99
access-control These APIs manage access rules on resources in an account.
1010
groups Groups simplify identity management, making it easier to assign access to Databricks account, data, and other securable objects.
1111
groups-v2 Groups simplify identity management, making it easier to assign access to Databricks account, data, and other securable objects.
12+
iam-v2 These APIs are used to manage identities and the workspace access of these identities in <Databricks>.
1213
service-principals Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms.
1314
service-principals-v2 Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms.
1415
users User identities recognized by Databricks and represented by email addresses.
@@ -25,10 +26,8 @@ Settings
2526
network-connectivity These APIs provide configurations for the network connectivity of your workspaces for serverless compute resources.
2627
network-policies These APIs manage network policies for this account.
2728
settings Accounts Settings API allows users to manage settings at the account level.
28-
workspace-network-configuration These APIs allow configuration of network settings for Databricks workspaces by selecting which network policy to associate with the workspace.
29-
30-
Settings (v2)
3129
settings-v2 APIs to manage account level settings.
30+
workspace-network-configuration These APIs allow configuration of network settings for Databricks workspaces by selecting which network policy to associate with the workspace.
3231

3332
Provisioning
3433
credentials These APIs manage credential configurations for this workspace.
@@ -54,9 +53,6 @@ OAuth
5453
service-principal-federation-policy These APIs manage service principal federation policies.
5554
service-principal-secrets These APIs enable administrators to manage service principal secrets.
5655

57-
Identity and Access Management (v2)
58-
iam-v2 These APIs are used to manage identities and the workspace access of these identities in <Databricks>.
59-
6056
Flags:
6157
-h, --help help for account
6258

acceptance/help/output.txt

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ Machine Learning
3434
Real-time Serving
3535
serving-endpoints The Serving Endpoints API allows you to create, update, and delete model serving endpoints.
3636

37+
Apps
38+
apps Apps run directly on a customer’s Databricks instance, integrate with their data, use and extend Databricks services, and enable users to interact through single sign-on.
39+
40+
Vector Search
41+
vector-search-endpoints **Endpoint**: Represents the compute resources to host vector search indexes.
42+
vector-search-indexes **Index**: An efficient representation of your embedding vectors that supports real-time and efficient approximate nearest neighbor (ANN) search queries.
43+
3744
Identity and Access Management
3845
current-user This API allows retrieving information about currently authenticated user or service principal.
3946
groups Groups simplify identity management, making it easier to assign access to Databricks workspace, data, and other securable objects.
@@ -43,6 +50,7 @@ Identity and Access Management
4350
service-principals-v2 Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms.
4451
users User identities recognized by Databricks and represented by email addresses.
4552
users-v2 User identities recognized by Databricks and represented by email addresses.
53+
workspace-iam-v2 These APIs are used to manage identities and the workspace access of these identities in <Databricks>.
4654

4755
Databricks SQL
4856
alerts The alerts API can be used to perform CRUD operations on alerts.
@@ -55,6 +63,11 @@ Databricks SQL
5563
query-history A service responsible for storing and retrieving the list of queries run against SQL endpoints and serverless compute.
5664
warehouses A SQL warehouse is a compute resource that lets you run SQL commands on data objects within Databricks SQL.
5765

66+
AI/BI
67+
genie Genie provides a no-code experience for business users, powered by AI/BI.
68+
lakeview These APIs provide specific management operations for Lakeview dashboards.
69+
lakeview-embedded Token-based Lakeview APIs for embedding dashboards in external applications.
70+
5871
Unity Catalog
5972
artifact-allowlists In Databricks Runtime 13.3 and above, you can add libraries and init scripts to the allowlist in UC so that users can leverage these artifacts on compute configured with shared access mode.
6073
catalogs A catalog is the first layer of Unity Catalog’s three-level namespace.
@@ -98,19 +111,10 @@ Settings
98111
token-management Enables administrators to get all tokens and delete tokens for other users.
99112
tokens The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs.
100113
workspace-conf This API allows updating known workspace settings for advanced users.
114+
workspace-settings-v2 APIs to manage workspace level settings.
101115

102-
Developer Tools
103-
bundle Databricks Asset Bundles let you express data/AI/analytics projects as code.
104-
sync Synchronize a local directory to a workspace directory
105-
106-
Vector Search
107-
vector-search-endpoints **Endpoint**: Represents the compute resources to host vector search indexes.
108-
vector-search-indexes **Index**: An efficient representation of your embedding vectors that supports real-time and efficient approximate nearest neighbor (ANN) search queries.
109-
110-
Dashboards
111-
genie Genie provides a no-code experience for business users, powered by AI/BI.
112-
lakeview These APIs provide specific management operations for Lakeview dashboards.
113-
lakeview-embedded Token-based Lakeview APIs for embedding dashboards in external applications.
116+
OAuth
117+
service-principal-secrets-proxy These APIs enable administrators to manage service principal secrets at the workspace level.
114118

115119
Marketplace
116120
consumer-fulfillments Fulfillments are entities that allow consumers to preview installations.
@@ -126,41 +130,39 @@ Marketplace
126130
provider-provider-analytics-dashboards Manage templated analytics solution for providers.
127131
provider-providers Providers are entities that manage assets in Marketplace.
128132

129-
Apps
130-
apps Apps run directly on a customer’s Databricks instance, integrate with their data, use and extend Databricks services, and enable users to interact through single sign-on.
131-
132133
Clean Rooms
133134
clean-room-asset-revisions Clean Room Asset Revisions denote new versions of uploaded assets (e.g.
134135
clean-room-assets Clean room assets are data and code objects — Tables, volumes, and notebooks that are shared with the clean room.
135136
clean-room-auto-approval-rules Clean room auto-approval rules automatically create an approval on your behalf when an asset (e.g.
136137
clean-room-task-runs Clean room task runs are the executions of notebooks in a clean room.
137138
clean-rooms A clean room uses Delta Sharing and serverless compute to provide a secure and privacy-protecting environment where multiple parties can work together on sensitive enterprise data without direct access to each other's data.
138139

139-
Database
140+
Quality Monitor
141+
quality-monitor-v2 Manage data quality of UC objects (currently support schema).
142+
143+
Data Quality Monitoring
144+
data-quality Manage the data quality of Unity Catalog objects (currently support schema and table).
145+
146+
Database Instances
140147
database Database Instances provide access to a database via REST API or direct SQL.
141148
psql Connect to the specified Database Instance
142149

143-
Quality Monitor v2
144-
quality-monitor-v2 Manage data quality of UC objects (currently support schema).
145-
146-
OAuth
147-
service-principal-secrets-proxy These APIs enable administrators to manage service principal secrets at the workspace level.
150+
Tags
151+
tag-policies The Tag Policy API allows you to manage policies for governed tags in Databricks.
148152

149-
Identity and Access Management (v2)
150-
workspace-iam-v2 These APIs are used to manage identities and the workspace access of these identities in <Databricks>.
153+
Developer Tools
154+
bundle Databricks Asset Bundles let you express data/AI/analytics projects as code.
155+
sync Synchronize a local directory to a workspace directory
151156

152157
Additional Commands:
153158
account Databricks Account Commands
154159
api Perform Databricks API call
155160
auth Authentication related commands
156161
completion Generate the autocompletion script for the specified shell
157162
configure Configure authentication
158-
data-quality Manage the data quality of Unity Catalog objects (currently support schema and table).
159163
help Help about any command
160164
labs Manage Databricks Labs installations
161-
tag-policies The Tag Policy API allows you to manage policies for governed tags in Databricks.
162165
version Retrieve information about the current version of this CLI
163-
workspace-settings-v2 APIs to manage workspace level settings.
164166

165167
Flags:
166168
--debug enable debug logging

cmd/account/cmd.go

Lines changed: 0 additions & 9 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: 5 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/account/iam-v2/iam-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/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: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,26 @@ const (
3030
permissionsGroup = "permissions"
3131
)
3232

33+
// configureGroups adds groups to the command, only if a group
34+
// has at least one available command.
35+
func configureGroups(cmd *cobra.Command, groups []cobra.Group) {
36+
filteredGroups := cmdgroup.FilterGroups(groups, cmd.Commands())
37+
for i := range filteredGroups {
38+
cmd.AddGroup(&filteredGroups[i])
39+
}
40+
}
41+
42+
func accountCommand() *cobra.Command {
43+
cmd := account.New()
44+
configureGroups(cmd, account.Groups())
45+
return cmd
46+
}
47+
3348
func New(ctx context.Context) *cobra.Command {
3449
cli := root.New(ctx)
3550

3651
// Add account subcommand.
37-
cli.AddCommand(account.New())
52+
cli.AddCommand(accountCommand())
3853

3954
// Add workspace subcommands.
4055
workspaceCommands := workspace.All()
@@ -83,12 +98,10 @@ func New(ctx context.Context) *cobra.Command {
8398
cli.AddCommand(ssh.New())
8499

85100
// Add workspace command groups, filtering out empty groups or groups with only hidden commands.
86-
allGroups := workspace.Groups()
87-
allCommands := cli.Commands()
88-
filteredGroups := cmdgroup.FilterGroups(allGroups, allCommands)
89-
for i := range filteredGroups {
90-
cli.AddGroup(&filteredGroups[i])
91-
}
101+
configureGroups(cli, append(workspace.Groups(), cobra.Group{
102+
ID: "development",
103+
Title: "Developer Tools",
104+
}))
92105

93106
return cli
94107
}

cmd/workspace/groups.go

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

cmd/workspace/quality-monitor-v2/quality-monitor-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.

0 commit comments

Comments
 (0)