-
I've got a main configuration file that I want to merge some overrides into, so I followed the example "Merge / combine all documents into one" which outlines the following approach: yq ea -i '. as $item ireduce ({}; . * $item )' file1.yml file2.yml And it works well as long as file2.yml doesnt attempt to modify any entries that use tags like file1.yml Globals:
Function:
Environment:
Variables:
API_BASE_PATH: !Sub ${PROJECT} file2.yml Globals:
Function:
Environment:
Variables:
API_BASE_PATH: !If
- IsProd
- ""
- !Sub ${PROJECT} The result is an interesting hybrid: Globals:
Function:
Environment:
Variables:
API_BASE_PATH: !Sub
- IsProd
- ""
- !Sub ${PROJECT} The list of arguments for the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I tried skipping the tag entirely in file2.yml to use the longform Fn::If which should be interpreted as a regular map: Globals:
Function:
Environment:
Variables:
API_BASE_PATH:
Fn::If:
- IsProd
- ""
- !Sub ${PROJECT} but the Globals:
Function:
Environment:
Variables:
API_BASE_PATH: !Sub
Fn::If:
- IsProd
- ""
- !Sub ${PROJECT} |
Beta Was this translation helpful? Give feedback.
-
The latest 4.27.3 release has a new merge flag 'c' to 'clobber' custom tags - give it a go yq ea -i '. as $item ireduce ({}; . *c $item )' file1.yml file2.yml |
Beta Was this translation helpful? Give feedback.
The latest 4.27.3 release has a new merge flag 'c' to 'clobber' custom tags - give it a go
yq ea -i '. as $item ireduce ({}; . *c $item )' file1.yml file2.yml