Open scastria opened 1 month ago
I CAN get it to work if I use hardcoded indicies which I would like to avoid:
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.all
---
pipelines:
branches:
#@overlay/match by=overlay.all
_:
#@overlay/match by=overlay.index(1)
- parallel:
#@overlay/match by=overlay.index(0)
- step:
#@overlay/match missing_ok=True
new: "value"
This seems to work by using a custom matcher function, but is this efficient? Plus, I would like to match on other step names. Is there a way to reuse my matcher function but pass in a fourth parameter on what step name to look for?
#@ load("@ytt:overlay", "overlay")
#@ def parallel(i, l, r):
#@ for s in l["parallel"]:
#@ if s["step"]["name"] == "Plan_Containers_development":
#@ return True
#@ end
#@ end
#@ return False
#@ end
#@ def step(i, l, r):
#@ return l["step"]["name"] == "Plan_Containers_development"
#@ end
#@overlay/match by=overlay.all
---
pipelines:
branches:
#@overlay/match by=overlay.all
_:
#@overlay/match by=parallel
- parallel:
#@overlay/match by=step
- step:
#@overlay/match missing_ok=True
new: "value"
@scastria You can pass stepname using closure. I will see if this can be done in a better way somehow.
#@ load("@ytt:overlay", "overlay")
#@ def parallelc(stepname):
#@ def parallel(i, l, r):
#@ for s in l["parallel"]:
#@ if s["step"]["name"] == stepname:
#@ return True
#@ end
#@ end
#@ return False
#@ end
#@ return parallel
#@ end
#@ def stepc(stepname):
#@ def step(i, l, r):
#@ return l["step"]["name"] == stepname
#@ end
#@ return step
#@ end
#@overlay/match by=overlay.all
---
pipelines:
branches:
#@overlay/match by=overlay.all
_:
#@overlay/match by=parallelc("Plan_Containers_development")
- parallel:
#@overlay/match by=stepc("Plan_Containers_development")
- step:
#@overlay/match missing_ok=True
new: "value"
I have watched the primer youtube video, but I don't think any of those examples apply to my situation. I am trying to add a map item to ONLY the Plan_Containers_development step without using hardcoded indexes since the Plan_Containers_development step could be anywhere. The issue, I think, is that I have arrays of maps of arrays of maps of maps.
My source yaml is:
My current overlay is: