bundle: surface read-only DMS commands under DAB sub-groups#5313
Conversation
The SDK v0.135 added a workspace-level `bundle` (Deployment Metadata Service) whose auto-generated cobra commands live at cmd/workspace/bundle/. The previous PR (#5311) filters that workspace root out of top-level registration because `bundle` collides with the DAB command tree. This commit brings the read-side verbs back, grouped under the noun parents under `databricks bundle`: databricks bundle deployment {get, list} databricks bundle version {get, list} databricks bundle resource {get, list} databricks bundle operation {get, list} Aliases (`deployments`, `versions`, `resources`, `operations`) are attached on each group so cobra renders the noun/nouns pair in the help header and either form routes the same way. Mutating verbs (create-deployment, create-version, create-operation, delete-deployment, complete-version, heartbeat) are intentionally not surfaced -- they have no user-facing workflow yet and stay in the filtered-out workspace tree. The `deployment` group is additive: the new read-side verbs sit alongside the existing `bind`, `unbind`, `migrate` from cmd/bundle/deployment/. Help output renders both sets together with the alias header on top. Implementation lives in cmd/bundle/metadata_service.go: a small helper calls `workspacebundle.New()` once, detaches each subcommand from the (discarded) workspace root, and exposes them via a map keyed by their original cobra Name. cmd/bundle/bundle.go pulls only the four read-side entries from the map and renames each from `<verb>-<noun>` to `<verb>` via `renameTo`, which preserves the trailing positional-arg syntax that cobra renders in usage strings. Co-authored-by: Isaac
a79fd4a to
96e0aad
Compare
The previous commit adds `operation`, `resource`, `version` as new top-level rows in `databricks bundle --help`, and `get`/`list` as new verbs under `bundle deployment`. Update the two `bundle/help` golden outputs to match (test was passing under -update; verified with a re-run without -update). Co-authored-by: Isaac
|
Commit: f063e2b |
Removes the `deployments`/`versions`/`resources`/`operations` plural aliases from the four sub-groups. Cobra still routes the singular form (matching the SDK / API convention); we can revisit aliasing once the read-only surface lands and we see what users prefer. `bundle-deployment` help golden refreshed -- the `Aliases:` header in the help output is what changes. Co-authored-by: Isaac
Eight stubbed REST endpoints and one consolidated script exercise the
new `bundle {deployment,version,resource,operation} {get,list}` commands
end to end against the local testserver. The DMS APIs aren't on test
workspaces yet, so this test is `Cloud = false` -- it only runs in the
in-process matrix.
Stubbed response shapes match the SDK v0.136 `bundle` service models;
the golden captures the rendered output for each command in order:
list-then-get for each of the four nouns.
Co-authored-by: Isaac
Mark every auto-generated DMS read command (`get`, `list` under each of deployment/version/resource/operation) and the three new noun groups (version/resource/operation) as `Hidden: true`. The commands still route through cobra so callers who know to invoke them get the same behavior; help just no longer advertises the surface until DMS is documented as a user-facing CLI feature. The existing `deployment` group stays visible because it still has `bind`/`unbind`/`migrate`; only its two new `get`/`list` children are hidden. Help goldens refreshed: - bundle/help/bundle: drop the version/resource/operation rows - bundle/help/bundle-deployment: drop the get/list rows The local-only `cmd/bundle/dms-read-only` acceptance test continues to pass without -update (Hidden=true doesn't affect routing, only the help renderer). Co-authored-by: Isaac
Approval status: pending
|
The previous commit set `sub.Hidden = true` inside `metadataServiceCommands()`, which made the hide invisible at the call site -- reading `bundle.go` you couldn't tell that the deployment `get` and `list` rows wouldn't show up in help. Move the hide into the call site: a single loop over the returned `dms` map flips `Hidden` on all eight commands right where the wiring lives. `metadataServiceCommands()` is now opinion-free -- it just detaches and indexes -- and the visibility policy is colocated with the wiring. No behavior change: same set of commands hidden, same help output, existing acceptance tests still pass without `-update`. Co-authored-by: Isaac
ilyakuz-db
left a comment
There was a problem hiding this comment.
Could you elaborate how these commands work, it's not clear from this PR, is this proxy for DMS CRUD commands?
I'd expect databrick bundle * commands to be context-aware, i.e. if the command is triggered from bundle folder it shows me list of deployments of this bundle, not all workspace deployments.
If this is not expected to be context aware probably it should be databricks deployments list, similar to databricks jobs list or databricks clusters list
|
@ilyakuz-db Good feedback, your suggestion makes sense thuogh it does break precedent for worksapce API commands. At this moment all deployments will be listed, and GET requires all the deployment_id. Implementing bundle aware commands requires client side filtering because the server does not provide them. What you are suggesting is cleaner, though we'll need to work out the command paths and requires a ODD to align. I'll proceed with merging this because it's all hidden, but lets properly design and implement the commands to make sure the final version is more intentional. |
Sounds good |
|
Commit: 4aa26fa |
|
Commit: 4aa26fa |
Stacked on #5311 (the SDK v0.136 bump). Retarget to
mainonce that lands.Why
SDK v0.135 added a workspace-level
bundleservice (DMS). Its auto-generated CLI commands sit at the rootdatabricks bundle <verb>and collide with the DABbundlecommand tree, so PR #5311 filters them out of top-level registration. This PR brings the read-side commands back, grouped under the existing DABbundlenamespace.Layout
| Group | Commands |
|---|---|---|
|
bundle deployment|get,list-- additive next to existingbind,unbind,migrate||
bundle version|get,list||
bundle resource|get,list||
bundle operation|get,list|Mutating verbs are intentionally out of scope (create / delete / complete / heartbeat). They have no user-facing workflow yet; we'll add them when the DMS write-path becomes a documented feature. Until then they remain in the filtered-out
cmd/workspace/bundletree.Wiring
The DAB
deploymentgroup is additive -- the newget/listverbs join the existingbind/unbind/migrateunder one parent. The other three groups are brand new.Implementation lives in
cmd/bundle/metadata_service.go:metadataServiceCommands()callsworkspacebundle.New()once, detaches every subcommand from the discarded workspace root, and returns them in a map keyed by their original cobraName(e.g.\"get-deployment\").renameTo(c, newName)rewrites the first whitespace-separated token of cobra'sUsefield while preserving the trailing positional-arg syntax. So\"get-deployment NAME\"becomes\"get NAME\"and cobra still renders the usage string correctly.cmd/bundle/bundle.gopulls only the four read-side entries (get-deployment,list-deployments,get-version,list-versions,get-resource,list-resources,get-operation,list-operations) out of the map and attaches them to the right parent. The workspacebundlefilter incmd/cmd.gostays in place, so the mutating verbs do not leak to the root.Test plan
go build ./...go test ./cmd/... ./bundle/...(all green)go vet ./...cleandatabricks bundle {deployment,version,resource,operation} --helpshow the expected commands + alias pairdatabricks bundle deployments get --help(plural alias) routes correctlydatabricks bundle debug refschema --helpunaffected