goss-org / goss

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

Allow setting environment variables for command tests #602

Open kasimon opened 4 years ago

kasimon commented 4 years ago

Describe the feature: Add the ability to specify environment variables for command checks.

Describe the solution you'd like

command:
  vault status:
    exit-status: 0
    environment:
      VAULT_ADDR: "https://....:8200"
      VAULT_CACERT: "/etc/ssl/my-internal-ca.pem"
    timeout: 10000

Describe alternatives you've considered Create a wrapper script that sets the environment variables and is called by goss. Possible but not as elegant as if this feature was provided by goss itself.

aelsabbahy commented 4 years ago

Another way to do it today if you want to avoid a wrapper script is.

exec: "VAULT_ADDR=.. VAULT_CACERT=.. vault status"

That said, this sounds like a good enhancement to have, marking it as approved.