Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acceptance/cmd/bundle/dms-read-only/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions acceptance/cmd/bundle/dms-read-only/output.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

>>> [CLI] bundle deployment list
>>> [CLI] bundle-deployments list-deployments
[
{
"display_name": "first deployment",
Expand All @@ -15,16 +15,21 @@
}
]

>>> [CLI] bundle deployment get deployments/abc
>>> [CLI] bundle-deployments get-deployment deployments/abc
{
"display_name": "first deployment",
"git_info": {
"branch": "main",
"commit": "[COMMIT_SHA]",
"origin_url": "https://github.com/databricks/cli"
},
"last_version_id": "v1",
"name": "deployments/abc",
"status": "DEPLOYMENT_STATUS_ACTIVE",
"target_name": "dev"
}

>>> [CLI] bundle version list deployments/abc
>>> [CLI] bundle-deployments list-versions deployments/abc
[
{
"cli_version": "[DEV_VERSION]",
Expand All @@ -34,15 +39,20 @@
}
]

>>> [CLI] bundle version get deployments/abc/versions/v1
>>> [CLI] bundle-deployments get-version deployments/abc/versions/v1
{
"cli_version": "[DEV_VERSION]",
"git_info": {
"branch": "main",
"commit": "[COMMIT_SHA]",
"origin_url": "https://github.com/databricks/cli"
},
"name": "deployments/abc/versions/v1",
"status": "VERSION_STATUS_COMPLETED",
"version_type": ""
}

>>> [CLI] bundle resource list deployments/abc
>>> [CLI] bundle-deployments list-resources deployments/abc
[
{
"last_action_type": "OPERATION_ACTION_TYPE_CREATE",
Expand All @@ -53,7 +63,7 @@
}
]

>>> [CLI] bundle resource get deployments/abc/resources/my_job
>>> [CLI] bundle-deployments get-resource deployments/abc/resources/my_job
{
"last_action_type": "OPERATION_ACTION_TYPE_CREATE",
"last_version_id": "v1",
Expand All @@ -62,7 +72,7 @@
"resource_type": "DEPLOYMENT_RESOURCE_TYPE_JOB"
}

>>> [CLI] bundle operation list deployments/abc/versions/v1
>>> [CLI] bundle-deployments list-operations deployments/abc/versions/v1
[
{
"action_type": "OPERATION_ACTION_TYPE_CREATE",
Expand All @@ -72,7 +82,7 @@
}
]

>>> [CLI] bundle operation get deployments/abc/versions/v1/operations/my_job
>>> [CLI] bundle-deployments get-operation deployments/abc/versions/v1/operations/my_job
{
"action_type": "OPERATION_ACTION_TYPE_CREATE",
"name": "deployments/abc/versions/v1/operations/my_job",
Expand Down
16 changes: 8 additions & 8 deletions acceptance/cmd/bundle/dms-read-only/script
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
trace $CLI bundle deployment list
trace $CLI bundle deployment get deployments/abc
trace $CLI bundle version list deployments/abc
trace $CLI bundle version get deployments/abc/versions/v1
trace $CLI bundle resource list deployments/abc
trace $CLI bundle resource get deployments/abc/resources/my_job
trace $CLI bundle operation list deployments/abc/versions/v1
trace $CLI bundle operation get deployments/abc/versions/v1/operations/my_job
trace $CLI bundle-deployments list-deployments
trace $CLI bundle-deployments get-deployment deployments/abc
trace $CLI bundle-deployments list-versions deployments/abc
trace $CLI bundle-deployments get-version deployments/abc/versions/v1
trace $CLI bundle-deployments list-resources deployments/abc
trace $CLI bundle-deployments get-resource deployments/abc/resources/my_job
trace $CLI bundle-deployments list-operations deployments/abc/versions/v1
trace $CLI bundle-deployments get-operation deployments/abc/versions/v1/operations/my_job
36 changes: 30 additions & 6 deletions acceptance/cmd/bundle/dms-read-only/test.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# Local-only acceptance test for the read-only DMS commands under
# `databricks bundle {deployment,version,resource,operation}`. The DMS APIs
# aren't on test workspaces yet, so we stub the eight read endpoints with
# fixed response bodies and assert the CLI renders them as expected.
# Local-only acceptance test for the read-only verbs of the auto-generated
# `databricks bundle-deployments` command (DMS). The DMS APIs aren't on test
# workspaces yet, so we stub the eight read endpoints with fixed response
# bodies and assert the generated command renders them as expected.
#
# The deployment/version stubs include git_info: it is the field of interest
# for this service and is silently dropped by older CLI releases whose SDK
# model predates it, so we assert it round-trips through the generated command.
Local = true
Cloud = false

# bundle-deployments is a workspace-service command independent of the bundle
# deploy engine, so opt out of the inherited terraform/direct matrix.
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = []

# Normalize the git commit SHA so the golden output isn't tied to a specific
# commit value.
[[Repls]]
Old = '\b[0-9a-f]{40}\b'
New = '[COMMIT_SHA]'

[[Server]]
Pattern = "GET /api/2.0/bundle/deployments"
Response.Body = '''
Expand Down Expand Up @@ -34,7 +48,12 @@ Response.Body = '''
"display_name": "first deployment",
"target_name": "dev",
"status": "DEPLOYMENT_STATUS_ACTIVE",
"last_version_id": "v1"
"last_version_id": "v1",
"git_info": {
"branch": "main",
"commit": "b3ceef677c3edbc098de4e38578e008f08dc0df1",
"origin_url": "https://github.com/databricks/cli"
}
}
'''

Expand All @@ -58,7 +77,12 @@ Response.Body = '''
{
"name": "deployments/abc/versions/v1",
"cli_version": "0.0.0-dev",
"status": "VERSION_STATUS_COMPLETED"
"status": "VERSION_STATUS_COMPLETED",
"git_info": {
"branch": "main",
"commit": "b3ceef677c3edbc098de4e38578e008f08dc0df1",
"origin_url": "https://github.com/databricks/cli"
}
}
'''

Expand Down
54 changes: 1 addition & 53 deletions cmd/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,62 +36,10 @@ Online documentation: https://docs.databricks.com/en/dev-tools/bundles/index.htm
cmd.AddCommand(newSummaryCommand())
cmd.AddCommand(newGenerateCommand())
cmd.AddCommand(newDebugCommand())
cmd.AddCommand(deployment.NewDeploymentCommand())
cmd.AddCommand(newOpenCommand())
cmd.AddCommand(newPlanCommand())
cmd.AddCommand(newConfigRemoteSyncCommand())

// Bundle Metadata Service (DMS) read-only command groups. Only `get`
// and `list` are surfaced here; mutating verbs (create/delete/heartbeat/
// complete) are not user-facing yet and stay in the auto-generated
// `cmd/workspace/bundle` tree (which is filtered out of top-level
// registration in cmd/cmd.go).
//
// Hide everything from help output for now: the DMS API surface isn't
// documented as a user-facing CLI feature yet. Commands still route
// through cobra so callers who know about them can invoke them; they
// just don't show up in `bundle --help` / `bundle <group> --help`.
dms := metadataServiceCommands()
for _, c := range dms {
c.Hidden = true
}

// The DAB `deployment` group already exists for bind/unbind/migrate.
// Augment it additively with the (hidden) DMS read-side verbs.
deploymentCmd := deployment.NewDeploymentCommand()
deploymentCmd.AddCommand(renameTo(dms["get-deployment"], "get"))
deploymentCmd.AddCommand(renameTo(dms["list-deployments"], "list"))
cmd.AddCommand(deploymentCmd)

// The three new groups are hidden too; cobra hides a parent when all
// of its children are hidden, but we set the flag explicitly so the
// group disappears from `bundle --help` even if a future child is
// added without the hide flag.
versionCmd := &cobra.Command{
Use: "version",
Short: "Read version records in the bundle metadata service.",
Hidden: true,
}
versionCmd.AddCommand(renameTo(dms["get-version"], "get"))
versionCmd.AddCommand(renameTo(dms["list-versions"], "list"))
cmd.AddCommand(versionCmd)

resourceCmd := &cobra.Command{
Use: "resource",
Short: "Read resource records from the bundle metadata service.",
Hidden: true,
}
resourceCmd.AddCommand(renameTo(dms["get-resource"], "get"))
resourceCmd.AddCommand(renameTo(dms["list-resources"], "list"))
cmd.AddCommand(resourceCmd)

operationCmd := &cobra.Command{
Use: "operation",
Short: "Read operation records in the bundle metadata service.",
Hidden: true,
}
operationCmd.AddCommand(renameTo(dms["get-operation"], "get"))
operationCmd.AddCommand(renameTo(dms["list-operations"], "list"))
cmd.AddCommand(operationCmd)

return cmd
}
40 changes: 0 additions & 40 deletions cmd/bundle/metadata_service.go

This file was deleted.

7 changes: 0 additions & 7 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ func New(ctx context.Context) *cobra.Command {
// Add workspace subcommands.
workspaceCommands := workspace.All()
for _, cmd := range workspaceCommands {
// The auto-generated `bundle-deployments` workspace service (DMS) is
// surfaced under the DAB `bundle` command tree (cmd/bundle). Skip the
// generated top-level command; callers still have `databricks api ...`
// for the DMS endpoints.
if cmd.Name() == "bundle-deployments" {
continue
}
// Order the permissions subcommands after the main commands.
for _, sub := range cmd.Commands() {
// some commands override groups in overrides.go, leave them as-is
Expand Down
Loading