merge two files Yaml #1713
Unanswered
anouarbouayad
asked this question in
Q&A
Replies: 1 comment
-
Sorry missed this. yq has merge flags that can be used, one of which specifies to merge arrays However, there is an issue - the first file Best thing I can think to do is use yq to change it to an array, and then merge them:
Explanation:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to merge two yaml files file_dest.yml and file_source.yml.
"file_dest.yml"
type: PortalConfiguration
fields:
apiregAuthenticationPolicies: /Policies/YAML_PROJECT_120623/SECU_YAML_PROJECT_120623
"file_source.yml"
type: PortalConfiguration
fields:
apiregAuthenticationPolicies:
- /Policies/COMMUN/SECURITE/API_KEY/SECU_APIKEY_SECRET
- /Policies/BIG/SECURITY_POLICIES/SECU_BIG
I use the following query:
yq eval-all 'select(fileIndex == 0) *+ select(fileIndex == 1)' "file_dest.yml" "file_source.yml"
The result of this request is
type: PortalConfiguration
fields:
apiregAuthenticationPolicies: /Policies/YAML_PROJECT_120623/SECU_YAML_PROJECT_120623
I want to produce the following file the merge of two files.
type: PortalConfiguration
fields:
apiregAuthenticationPolicies:
- /Policies/COMMUN/SECURITE/API_KEY/SECU_APIKEY_SECRET
- /Policies/BIG/SECURITY_POLICIES/SECU_BIG
- /Policies/YAML_PROJECT_120623/SECU_YAML_PROJECT_120623
Help me
Beta Was this translation helpful? Give feedback.
All reactions