Configuration Merging Strategy via yq#105
Draft
mlorenzofr wants to merge 1 commit intovalidatedpatterns:mainfrom
Draft
Configuration Merging Strategy via yq#105mlorenzofr wants to merge 1 commit intovalidatedpatterns:mainfrom
mlorenzofr wants to merge 1 commit intovalidatedpatterns:mainfrom
Conversation
Signed-off-by: Manuel Lorenzo <mlorenzofr@redhat.com>
Collaborator
|
I like this approach. Having configuration file for each scenario is not a problem, it's even good idea, because project will grow over the time. |
Contributor
|
Love this approach +1. |
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.
Overview
As our configuration requirements for
values-hub.yamlgrow more complex, we require a robust method to overlay scenario-specific configurations (e.g., supply-chain) without duplicating the base boilerplate or losing existing comments.I propose implementing a merging strategy using
yqto perform a deep, additive merge of YAML structures.Proposed Solution
The implementation utilizes the
eval-all(orea) yq command to process multiple files as a single stream, applying a reduction operator to combine them.Implementation Command
How it works
eval-all: Loads all input files into memory before processing, allowing cross-file operations.. as $item ireduce ({}; ...): This initializes an empty object{}and iterates through each file, assigning the current file to the variable$itemand merging it into the accumulator.*+(Deep Additive Merge): Unlike the standard merge operator (*), the*+operator:Comparison:
yqvs.diff/patchdiff/patchyq(Structural Merge)yqmaintains head/foot comments).Strengths & Benefits
values-hub.yamland only define the delta in the scenario-specific configurations.yqis specifically designed to retain documentation comments, which is critical for our "Example-driven" configuration style.Weaknesses & Considerations
*+will result in a duplicate entry. This can be mitigated by piping touniqueif necessary.