Skip to content

feat: add inventory apply for declarative population#6

Merged
ecv merged 1 commit into
mainfrom
feat/inventory-apply
Jun 12, 2026
Merged

feat: add inventory apply for declarative population#6
ecv merged 1 commit into
mainfrom
feat/inventory-apply

Conversation

@ecv

@ecv ecv commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What

Adds datumctl inventory apply -f FILE — an idempotent, declarative upsert of inventory objects for populating the inventory from declared config. The plugin half of replacing bin/load-inventory (#2).

Behavior

  • Reads multi-doc YAML/JSON from -f files or stdin (-); decodes into typed objects (client-side validation; unsupported kinds rejected with a clear error).
  • Applies in dependency order — provider → region → site → cluster → node — regardless of order in the file.
  • Idempotent server-side apply (field manager datumctl-inventory); re-applying the same manifest makes no changes.
  • --dry-run=server validates against the API without persisting.
  • Population only — no fleet-management/lifecycle ops (assign/cordon/decommission/delete), per Native datumctl inventory apply to replace bin/load-inventory #2 scope.

Accepts Provider, Region, Site, Cluster, Node.

Verification

Unit tests: multi-doc parse, dependency ordering, unsupported-kind rejection, empty input, GVK-set-for-SSA.

Against prod (--dry-run=server, read-only — no writes): re-applied provider+region+site; confirmed dependency reordering (input site,provider,region → applied provider,region,site), SSA + webhook validation pass, stdin path works, unsupported-kind rejected:

applied provider/netactuate (server dry-run)
applied region/us-central-1 (server dry-run)
applied site/us-central-1a (server dry-run)

Remaining for #2 (separate, infra-side)

Collapse bin/load-inventory (datum-cloud/infra) into a renderer that pipes manifests to datumctl inventory apply -f -, retiring its hand-rolled datumctl apply plumbing. Not in this repo.

Add `datumctl inventory apply -f FILE` — an idempotent, declarative upsert
of inventory objects (Provider, Region, Site, Cluster, Node) for populating
the inventory from declared configuration.

This is the plugin half of the bin/load-inventory replacement: the loader
shells out to `datumctl apply` of hand-rendered YAML today; apply gives the
plugin a native, typed load path so it owns inventory population.

Key features:
- Reads multi-doc YAML/JSON from -f files or stdin (-), decoded into typed
  objects (client-side validation, unsupported kinds rejected)
- Applies in dependency order (provider, region, site, cluster, node)
  regardless of input order
- Idempotent server-side apply, field manager "datumctl-inventory"
- --dry-run=server validates against the API without persisting
- Population only — no fleet-management/lifecycle operations

Part of #2.
@ecv ecv requested review from a team and scotwells and removed request for a team and scotwells June 12, 2026 15:28
@ecv ecv merged commit e5cad8d into main Jun 12, 2026
2 checks passed
@ecv ecv deleted the feat/inventory-apply branch June 12, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants