davo777
davo777

Reputation: 336

yq returning item is referenced but not assigned in nix script

I'm trying to merge 2 yaml files with a similar key in both files. I've tried a variety of yq commands and have ultimately managed to get the following command to work locally.

yq eval-all '. as $item ireduce ({}; . *+ $item)' values.yaml values.dev.yaml

values.yaml

environmentVariables:
  - name: test_var
    value: "true"

values.dev.yaml

environmentVariables:
  - name: test_var2
    value: "true"

expected outcome: values.yaml

environmentVariables:
  - name: test_var
    value: "true"
  - name: test_var2
    value: "true"

Locally I do receive this output, however in my nix flake an error is thrown ^---^ SC2154 (warning): item is referenced but not assigned. Silencing the warning does cause it to then throw the expected error.

I'm wondering if there as a solution for this, or perhaps another way of merging the yaml files so than $item or another var isn't used.

I've also tried deep merging like so: yq '. *d load("values.yaml")' values.dev.yaml however this doesn't behave as expected with more values present.

Edit: Fixed an incorrect cp for the $item var nix package is yq-go Locally yq (https://github.com/mikefarah/yq/) version v4.44.2

Upvotes: 0

Views: 71

Answers (0)

Related Questions