goss-org / goss

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

Dinamic variables and envs #866

Open legolego621 opened 5 months ago

legolego621 commented 5 months ago

Hello, can I use dinamic variables and envs like this?

command:
  kubectl get nodes:
    exit-status: 0
    stdout:
      not:
        match-regexp: 'NotReady'
  export test="a":
    exit-status: 0

http:
  '{{.Env.test}}':
    status: 200
    timeout: 5000
aelsabbahy commented 5 months ago

Using a command output as a variable isn't supported currently. You would have to generate the vars.yaml file prior to running Goss.

This isn't a bad feature request, it's somewhat related to #784

If the vars.yaml supported a simple interface that ran a command to set the car to its stdout.. would that sufficiently solve #784 or does it add too much complexity?

aelsabbahy commented 5 months ago

Cc: @uk-bolly (meant to tag you on last comment)

uk-bolly commented 4 months ago

thanks @aelsabbahy @legolego621

I like the idea and does cover off some of the idea of #784

However i would be using some some discovered variables multiple times, so it would require a running order, alternatively a wrapper script to set all the variables that could be inherited, if that would work? The simplicity of goss and modules would be lost somewhat with a wrapper script at that level.