happytal / substitute-variables

Azure DevOps task for substituting variables in plain JSON and YAML files
MIT License
1 stars 0 forks source link

NGINX annotations #8

Closed vvyas2 closed 3 years ago

vvyas2 commented 3 years ago

Is it possible to substitute NGINX annotations?

image

It does the non "/" type keys beautifully but is not able to detect the ones with "/" and I am unable to substitute ingress.class

2021-07-02T20:02:31.6917653Z Substituting variable spec.tls.0.secretName as string 2021-07-02T20:02:31.6948719Z Substituting variable spec.rules.0.host as string 2021-07-02T20:02:31.6952363Z Substituting variable spec.tls[0].hosts[0] as string

fhervieux commented 3 years ago

Hi!

I don't remember using it myself but I added a test case and it seems to work. Though sometimes test cases behave a bit differently than when running in a pipeline. Also, the slash should be fine it is the dot that is considered a special character in a JSONPath. Those variables should be referenced using square brackets:

metadata.annotations['kubernetes.io/ingress.class']

Can you try that?

vvyas2 commented 3 years ago

Thanks François !

I tried - metadata.annotations."kubernetes.io"/ingress.class & metadata.annotations.["kubernetes.io"]/ingress.class trying to borrow from yq but didn't try with single quotes, this works. Appreciate it!

Thanks for this nifty task, very useful, makes it easy for anyone to modify Kubernetes manifest file.