Skip to content

feat(config,cli): add assets-layout tooling and gridpool enterprise ownership - #130

Open
cwasicki wants to merge 11 commits into
frequenz-floss:v0.x.xfrom
cwasicki:cli
Open

feat(config,cli): add assets-layout tooling and gridpool enterprise ownership#130
cwasicki wants to merge 11 commits into
frequenz-floss:v0.x.xfrom
cwasicki:cli

Conversation

@cwasicki

@cwasicki cwasicki commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Rounds out gridpool-cli for the assets config layout and adds gridpool enterprise ownership to the config model. The CLI can now generate, validate, patch, and query merged config files.

  • Enterprise ownership: adds GridpoolConfig entries under assets.gridpools. AssetsConfig.find_enterprise() returns the declared owner or infers it from related microgrids. Whole-document validation rejects conflicting enterprise assignments.

  • Assets API enterprise metadata: configs derived from the Assets API now include each microgrid's enterprise_id.

  • find-enterprise command: gridpool-cli find-enterprise <gridpool_id> <files> prints the enterprise owning a gridpool from a merged config stack and exits non-zero when it cannot be determined.

  • Credential fallbacks: accepts FREQUENZ_API_KEY / FREQUENZ_API_SECRET when the Assets-specific credentials are unset. Credential pairs are never mixed between sources.

  • validate command: validates each config file independently and then validates the merged stack, enabling config-repository CI checks.

  • Current config output: generate-config writes the assets.microgrids layout and stamps assets.version.

  • Safe in-place updates: generate-config --inplace refreshes managed values while preserving formatting. --fill-missing only adds absent values, generated patches are validated before writing, and legacy layouts are rejected.

@cwasicki
cwasicki requested review from a team as code owners August 27, 2026 14:21
@cwasicki
cwasicki requested review from Linus404 and daniel-zullo-frequenz and removed request for a team August 27, 2026 14:21
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests labels Aug 27, 2026
@cwasicki cwasicki changed the title feat(cli): assets-layout config tooling: dump, validate, in-place patch feat(config,cli): add assets-layout tooling and gridpool enterprise ownership Aug 28, 2026
Reuse the platform-wide Frequenz API credentials when the Assets-specific
`ASSETS_API_AUTH_KEY` and `ASSETS_API_SIGN_SECRET` are unset.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Validate config files offline via `AssetsConfig.load_from_files`, exiting
non-zero on the first error so a config repo can gate PRs. Each file is checked
on its own first, so a partial record that only completes after a merge is
rejected: every committed file must name its own key and required fields. The
merged pass then adds the cross-record checks.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Emit `assets.microgrids.<id>` entries and stamp `assets.version` so the
generated file loads back without a migration.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
In-place patching overwrites the managed leaves by default; pass
`--fill-missing` to only add the ones the file lacks.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
In-place patching navigates the current `assets.microgrids` layout, so a
top-level or `meta`-nested file would be duplicated rather than edited.
Refuse it with a clear message pointing at a full rebuild.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
A gridpool always belongs to one enterprise, so `assets.gridpools.<id>` names
its `enterprise_id`. `AssetsConfig.enterprise_of` looks the owner up. Each
entry must name its enterprise and be filed under its own `gridpool_id`.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
`gridpool-cli find-enterprise <gridpool_id> <files>` prints the enterprise that
owns the gridpool, read from the merged config. Exits non-zero when no
`gridpools` entry names it.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
`get_microgrid` already carries the owning enterprise, so a config built from
the API now fills `MicrogridConfig.enterprise_id` instead of leaving it unset.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
A gridpool shares its enterprise with the microgrids its relations name, so
`enterprise_of` falls back to that when no `gridpools` entry is declared. A
declared entry still wins; disagreeing microgrids raise.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
`check` now enforces the one-enterprise-per-gridpool invariant: a gridpool's
microgrids may not disagree on the enterprise, and a declared `gridpools`
enterprise must match the one its microgrids imply.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant