feat(cli): add datumctl-inventory plugin#41
Conversation
Add a datumctl plugin that provides a read view over the inventory served by this operator. Invoked as `datumctl inventory ...` once installed. Replaces the approach of baking the command into datumctl core (datum-cloud/datumctl#212) — per review, the CLI lives with the service that owns the API. Key features: - List subcommands per kind (providers, regions, sites, clusters, nodes) with curated columns and -o table/json/yaml - Filter flags --region/--site/--cluster resolve server-side via the topology.inventory.miloapis.com/* labels the operator propagates; --provider matches the site providerRef client-side - `inventory tree` prints the region -> site -> node hierarchy with per-region clusters; `inventory summary` prints fleet-wide counts - Uses this repo's typed api/v1alpha1 client against the platform root, with credentials fetched on demand via the datumctl SDK helper - Implements the datumctl plugin contract (--plugin-manifest, DATUM_* context, go.datum.net/datumctl/plugin SDK)
Add goreleaser config + workflow to publish datumctl-inventory release
archives so it installs via `datumctl plugin install milo-os/datumctl-inventory`.
Plugin releases are decoupled from the operator: they trigger on a
`datumctl-inventory/vX.Y.Z` tag prefix and build only the plugin binary.
The operator's publish.yaml is guarded so plugin tags and the plugin's
GitHub release do not rebuild the operator image.
Key changes:
- .goreleaser.datumctl-inventory.yaml: builds ./cmd/datumctl-inventory for
linux/darwin/windows x amd64/arm64; archives named
datumctl-inventory_{OS}_{Arch}; checksums.txt; version via -X main.version
- release-datumctl-inventory.yaml: triggers on datumctl-inventory/v* tags;
GORELEASER_CURRENT_TAG strips the prefix so the plugin gets its own version
- publish.yaml: tags-ignore datumctl-inventory/** on push, and skip the
release-published jobs when the release tag carries the plugin prefix
Closes #42
|
Added release wiring (closes #42) and set this back to draft pending the operator/plugin separation discussion. Release wiring added:
Open design point for the separation discussion (why it's draft): OSS goreleaser has no monorepo/tag-prefix support (Pro-only). I worked around it with a |
|
@scotwells — need your call on packaging before this leaves draft. You asked for the CLI to live with the service that owns the API, so I put it here as Two honest options: Option A — same repo + tag prefix (what this PR does)
Option B — dedicated repo
A third option if you have Pro: real goreleaser monorepo support makes Option A clean (no My lean: A if we value API+CLI living together (your original steer) and accept the tag-prefix quirk; B if you'd rather the plugin version and release flow be fully independent of the operator. Which do you prefer? |
|
Can't we use the same tag between the operator and the CLI plugin? |
Per review, the plugin shares the operator's version and tag instead of
using a separate tag prefix. On `release: published`, goreleaser builds the
plugin and appends datumctl-inventory_{OS}_{Arch} archives + checksums.txt
to the same GitHub release as the operator image.
Removes the tag-prefix trigger, the GORELEASER_CURRENT_TAG workaround, and
the publish.yaml guards (no longer needed — both build on the same tag).
|
Reworked release wiring per @scotwells — plugin shares the operator's tag/version (no separate tag prefix).
Note for the curated-index follow-on: since archives live on |
|
I'm thinking it's weird that milo-os/inventory contain any reference to datum at all. Reviewing pattern. |
Reconsidering where this plugin lives (org separation)Surveyed where existing datumctl plugins live:
Two principles in tension
These collide here specifically because the inventory service itself is milo ( ResolutionMoving the plugin to a dedicated
This PR will be closed once the new repo is up. cc @scotwells — this supersedes the same-repo approach you steered earlier; flagging since it reverses that call on org-separation grounds. |
|
Proceeding but naming my plugin's repository datum-cloud/inventory. |
|
Superseded by datum-cloud/inventory (new repo): https://github.com/datum-cloud/inventory Moved the plugin out of the milo repo to honor datum/milo separation — Closing; nothing merges here. |
What
Adds
cmd/datumctl-inventory— a datumctl plugin providing a read view over the inventory this operator serves (inventory.miloapis.com/v1alpha1). Invoked asdatumctl inventory ...once installed.This supersedes datum-cloud/datumctl#212, which baked the command into datumctl core. Per @scotwells' review there, the CLI should live with the service that owns the API — so it lives here as a plugin, using this repo's own typed API.
Commands
inventory providers|regions|sites|clusters|nodes-o table/json/yamlinventory tree [--region]inventory summaryDesign
api/v1alpha1+ controller-runtime client = compile-safe field access (the upside of living in this repo vs unstructured in datumctl core).DATUM_API_HOST; no org/project scope.--region/--site/--clusterresolve server-side via thetopology.inventory.miloapis.com/*labels the controllers propagate;--providermatches the siteproviderRefclient-side.--plugin-manifest,DATUM_*env context, on-demand token via the credentials helper — using thego.datum.net/datumctl/pluginSDK. No datumctl core changes.Tests
go test ./cmd/datumctl-inventory/— covers ready-condition mapping, table rendering, tree hierarchy +--regionscoping, and summary tallies.Verified against prod (read-only)
Built the binary, injected the same
DATUM_*context datumctl sets, ran against prod:sites --region us-central-1→ 2 (server-side label) ✓sites --provider gcp→gcp-us-east4(client-side providerRef) ✓nodes --cluster us-central-1-lab→ cluster label filter ✓tree --region,summary,-o yaml, invalid-format error path all ✓(Fleet now includes freshly-loaded GKE/GCP inventory —
gcp-us-east4, 20 nodes — rendered correctly.)Follow-ups (not in this PR)
checksums.txtsodatumctl plugin install milo-os/datumctl-inventoryworks, and list it in datum-cloud/datumctl-plugins. Until then it installs as an unmanaged/trusted plugin.Closes datum-cloud/enhancements#713 (datumctl view portion) — tracked via datum-cloud/datumctl#211.