I have the following yaml
items:
- itemName: a
awesome: true
- itemName: b
- itemName: c
awesome: false
I need a function that gets a
as an output, since item a
has the attribute awesome == true
. How do I do that?
Approach that does not work:
{{- $result := "nope" }}
{{- range $i := $items }}
{{- if and (and (hasKey $i. awesome) ($i.awesome)) !($result -eq "nope") }}
{{- $result := $i.itemName }}
{{- end }}
{{- end }}
Have not tried the above approach, but am confident that this does not work (see this post). What I'd need is a default function that works for lists. I could not find any in sprig. Any Idea?