feat(config): fold environment config into the environments list with explicit roles - #568
Merged
Merged
Conversation
… explicit roles
The separate environment_config map is folded into the environments list, which
becomes a list of objects: each entry is a bare string (- dev) for a config-free
environment or a mapping (- {name: dev, wait_timer: 5, ...}) carrying that
environment's inline settings. A custom UnmarshalYAML on the entry accepts both
forms; MarshalYAML collapses a config-free entry back to the bare string. The
top-level environment_config key is removed and now reports as an unknown field
with a did-you-mean pointing at environments.
List order still defines the promotion ladder. An optional role: (prerelease or
release) on an entry overrides the positional default (last = release,
second-from-last = prerelease); an unset role keeps the index-based behavior, so
manifests without roles are unchanged. Component environments still whole-replace
the inherited ladder, now carrying inline settings with them.
Migrates every in-repo manifest, the JSON schema (three byte-identical copies),
docs, and adds e2e scenarios for the folded object shape and the role override.
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
…d cascade path The role: override was only partially honored: some paths used the role-aware accessors while others still assumed the positional last/second-from-last, so the two disagreed under a role override. - The generated prod deploy job derived its target environment positionally (Environments[len-1]) while the runtime prod-deployment gate uses ReleaseEnvironment(); with role: release on a non-last env the job deployed the release SHA to the wrong native environment. Derive it from ReleaseEnvironment(). - The cascade promotion path derived prerelease/publish/prod positionally, so a dev-to-prod cascade disagreed with the role-aware single-step (default) path for the same manifest. Route it through PrereleaseEnvironment()/ReleaseEnvironment(). - The promote workflow's release-states comment now reads from the accessors rather than asserting position. IsLastEnvironment stays a positional query (no production consumer) with a doc note that release-stage decisions must use ReleaseEnvironment. Adds fail-before/pass-after tests: the generated prod deploy job targets the role env, and default and cascade modes agree on the release/prerelease markers for a role-annotated manifest. The no-role baseline golden changes only in the reworded comment (env assignments unchanged). Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
Contributor
|
All PR Validation checks passed. |
…nt change Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
…ents shape The harness scenario Config is a direct alias of config.TrunkConfig, so Config.Environments is now []EnvironmentEntry. The scenario parser handles the folded shape correctly; only the test assertions comparing it to []string were stale. Route them through EnvironmentNames(). All 99 scenarios parse under the harness and every migrated scenario (29, 31, 60, 61) validates. Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
environments(an ordered[]string) andenvironment_config(a map keyed by env name) were two separate top-level keys that had to be kept in sync, and promotion roles (release/prerelease) were purely positional, so reordering the list silently changed which environment published.Fix
Fold the two into one
environmentslist of objects:- dev, sugar for a config-free environment) or a mapping (- {name: dev, wait_timer: 5, ...}) carrying that environment's inline settings. A customUnmarshalYAMLon the entry accepts both forms; aMarshalYAMLcollapses a config-free entry back to the bare string for a faithful round trip.environment_configkey is removed; it now reports as an unknown field with a did-you-mean pointing atenvironments.role:(prereleaseorrelease) overrides the positional default (last = release, second-from-last = prerelease). An unset role keeps the index-based behavior, so manifests without roles generate byte-identical output.environmentsstill whole-replace the inherited ladder (arrays replace under deep-merge), now carrying their inline settings with them, preserving the pre-fold slice-replace semantics.Verification
go build,go test,go test -race, andgolangci-lintall clean at the root;e2emodule builds and vets clean.environment_urlsinks).environment_configrejection, unknown-entry-field rejection, duplicate/empty names, invalid/duplicate roles, role overriding the promotion graph, component subset whole-replace, and marshal round-trip.reference/manifest.md,guides/environments.md,guides/components.md,reference/cli.md,security.md,internals/architecture.md); docs site builds.60-environments-folded-object(folded inline config reaching native deployment output) and61-environment-role-override(explicitrole:on a non-last environment).