There is a need to get a version of the dependency chart based on the name in the Helm umbrella chart structure. How can it be done by using yq tool? Input file example:
apiVersion: v2
name: application1
type: application
version: 0.1.1
dependencies:
- name: chart1
version: v1.13.0
repository: some-repo
- name: chart2
version: v0.11.0
repository: some-repo
the expected output is the version based on the name of the chart. So I want to be able to pass the chart name(chart1/chart2) and get the version of it:
if name: chart1 output --> v1.13.0
if name: chart2 output --> v0.11.0
CodePudding user response:
With mikefarah/yq, you could use a combination of select
and strenv
helpers to pass the required version argument as a string and retrieve the corresponding value of version
cname="chart1" yq '.dependencies[]|select(.name == strenv(cname)).version' yaml