Multi-environment config via named contexts#3547
Open
kichristensen wants to merge 4 commits intogetporter:mainfrom
Open
Multi-environment config via named contexts#3547kichristensen wants to merge 4 commits intogetporter:mainfrom
kichristensen wants to merge 4 commits intogetporter:mainfrom
Conversation
Add kubectl-style multi-context support to the Porter config file using a new schemaVersion: "2.0.0" format. Users can define multiple named contexts in a single config file and select between them at runtime. Changes: - New config format: schemaVersion, current-context, contexts[] - --context flag and PORTER_CONTEXT env var for context selection - Context selection priority: flag > env var > current-context field in file > "default" - Legacy flat format still supported; hard error if --context used with it - porter config context list: list contexts, mark active one - porter config context use <name>: update current-context - ConfigContextList uses viper (format-agnostic: TOML/JSON/HCL) - defaultConfigTemplate updated to new versioned format - Integration tests + CI workflow jobs added Signed-off-by: Kim Christensen <kimworking@gmail.com>
7685a36 to
cb5e0e3
Compare
Adds `porter config migrate` to convert a legacy flat config file to the multi-context format (schemaVersion: "2.0.0"). - Existing settings are wrapped under a "default" context - Text-based transformation preserves Liquid template vars - TOML/JSON/HCL files get a hard error with manual guidance - No-op if file already uses the multi-context format - Unit tests (4) and integration test added Signed-off-by: Kim Christensen <kimworking@gmail.com>
New page: docs/configuration/multi-context.md covering - config file format (schemaVersion 2.0.0) - context selection priority (flag > env > current-context > default) - porter config context list/use commands - porter config migrate for upgrading legacy files Updated configuration.md to link to the new page. Signed-off-by: Kim Christensen <kimworking@gmail.com>
Signed-off-by: Kim Christensen <kimworking@gmail.com>
6494231 to
7515fe2
Compare
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.
What does this change
Adds kubectl-style multi-context support to the Porter config file. Users can define multiple named environments in a single config file and switch between them at runtime.
New
schemaVersion: "2.0.0"format:Context selection (highest to lowest priority):
--context prodflagPORTER_CONTEXT=prodenv varcurrent-context:field in the config file"default"New commands:
Legacy flat config files continue to work unchanged. Using
--contextwith a legacy file is a hard error with a clear message.What issue does it fix
Closes #3523
Notes for the reviewer
ConfigContextUsedoes a targeted regex replace of thecurrent-context:line to preserve Liquid template variables elsewhere in the filedefaultConfigTemplate(used byporter config editwhen no file exists) now generates the new versioned formatChecklist