Shell variable subsitution in makefile

I would like to have command in Makefile that allows me to change service’s target in docker-compose.yaml respectively to target given command parameter. I have something like this: example: @[[ "$${target:-dev}" == @(dev|test|release) ]] || exit 1 yq -y -i ‘.services."$(service)".build.target = "$(target)"’ docker-compose.yaml This almost do the job, but I have this parameter to… Read More Shell variable subsitution in makefile

Update value in yaml using yq and returning the whole yaml content

spec: templates: – name: some_step1 script: image: some_image imagePullPolicy: IfNotPresent – name: some_step2 activeDeadlineSeconds: 300 script: image: some_image imagePullPolicy: IfNotPresent env: – name: HOST value: "HOST" – name: CONTEXT value: "CONTEXT" I would like to update the value for CONTEXT. The following command updates the value however it does not return the whole yaml: yq… Read More Update value in yaml using yq and returning the whole yaml content

Update value in yaml using yq and returning the whole yaml content

spec: templates: – name: some_step1 script: image: some_image imagePullPolicy: IfNotPresent – name: some_step2 activeDeadlineSeconds: 300 script: image: some_image imagePullPolicy: IfNotPresent env: – name: HOST value: "HOST" – name: CONTEXT value: "CONTEXT" I would like to update the value for CONTEXT. The following command updates the value however it does not return the whole yaml: yq… Read More Update value in yaml using yq and returning the whole yaml content

yq for merge strings

I have following prod.yaml file configMap: data: env: APP_1: "{{ .Data.data.app_1 }}" APP_2: "{{ .Data.data.app_2 }}" APP_3: "{{ .Data.data.app_3 }}" APP_4: "{{ .Data.data.app_4 }}" and updated.yaml file: APP_1: APP_2: APP_3: APP_4: APP_5: LOG_DIR: The expected result is: configMap: data: env: APP_1: "{{ .Data.data.app_1 }}" APP_2: "{{ .Data.data.app_2 }}" APP_3: "{{ .Data.data.app_3 }}" APP_4: "{{ .Data.data.app_4… Read More yq for merge strings

Is there a way to search through a yaml file for any instance of a key

I am currently trying to solve a problem with yq where we are updating the values file of a helm chart with an automated process. Most values files have the image tag in the following format: image: repository: repo-name tag: 0.0.1 which we were updating with: yq -i e ‘.image.tag = env(TAG)’ chart-name/values.yaml however not… Read More Is there a way to search through a yaml file for any instance of a key

yq filter with select from different map/list

example_a: – key: sa01 name: sa match_a: sa_key: sa01 This one works: yq ‘.example_a[] |select(.key == "sa01")’ Is it possible to make it work this way: yq ‘.example_a[] |select(.key == .match_a.sa_key)’ >Solution : Yes, that’s possible using a variable on the key: yq ‘.match_a.sa_key as $key | .example_a[] |select(.key == $key)’ i.yaml So we save… Read More yq filter with select from different map/list