Configuration Merging Strategy via yq#105
Configuration Merging Strategy via yq#105mlorenzofr wants to merge 2 commits intovalidatedpatterns:mainfrom
Conversation
|
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. |
|
Love this approach +1. |
Signed-off-by: Manuel Lorenzo <mlorenzofr@redhat.com>
Signed-off-by: Manuel Lorenzo <mlorenzofr@redhat.com>
|
This is a very lightweight method for quick manual merge. I have a few points:
|
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.