goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.57k stars 472 forks source link

goss render question. How to access {{ meta.jiranumber }} data from variables file, and merge to template? #698

Closed BeerOpsHQ closed 3 years ago

BeerOpsHQ commented 3 years ago

YAML templating question. I'm using (golang) "goss" to run some http checks. I'm using a variables file, and rendering/merging it into a yaml template as below. My question is how to access nested keys. ie I can easily grab {{.url}} but, how to grab {{ meta.rewriterule}} and {{ meta.jiranumber }}?

INPUT FILE (VARIABLE SOURCE)

nonprod: http:

TEMPLATE FILE

http: {{range index .Vars .Env.TESTS "http"}} {{.url}}: title: {{.title}} status: {{.status}} allow-insecure: false no-follow-redirects: true timeout: 5000 meta: rewriterule: {{ how to access this key? }} jiranumber: {{ how to access this key? }} body:

I can access the above "url" using {{.url}} in my template above.

Using the following for example....

meta:
  rewriterule: {{ .rewriterule }}
  jiranumber: {{ .jiranumber }}

I get the following error...

****> executing "test" at <.rewriterule>: map has no entry for key "rewriterule"

...presumably because it should be something like {{ meta.rewriterule }}...which also didn't work :(

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.