Skip to content

conditionally update from values in a second file #2255

Answered by mikefarah
dnlwgnd asked this question in Q&A
Discussion options

You must be logged in to vote

I made a slight change to the trigger_payload, to make it easier to update by looking up the ids given a key:

some-backend:
  image_id: 22aa
some-frontend:
  image_id: 56ab

Then we can update the original given the trigger by doing:

# use ea to load up both files into memory
./yq ea '
    # file[1] is the reference/trigger yaml, lets call that $trig
     select(fi==1) as $trig | 
    # we only want to output the contents of the first file, so select that
     select(fi==0) | 
    # now lets update the container entries
     with(.spec.template.spec.containers[];
        # here we find the image id in the trigger
         $trig[.name].image_id as $newImageId | 
        # if the trigger exi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dnlwgnd
Comment options

Answer selected by dnlwgnd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants