container-structure-test icon indicating copy to clipboard operation
container-structure-test copied to clipboard

Passing secret from the outside using env variables

Open gavvvr opened this issue 2 years ago • 2 comments

Hi. Suppose my test command needs a secret (The real-life command is a one-liner for making sure that the language runtime can successfully connect to a real database instance using db driver installed into the image under test). Is it possible to pass the secret to container under test?

I tried the following test:

schemaVersion: '2.0.0'
commandTests:
  - name: 'Env variable can be passed to CST from the outside'
    envVars:
      - key: "PASSWORD"
        value: "${PASSWORD}"
    command: "env"
    expectedOutput: ["s3cr3t"]

And executed the test with PASSWORD=s3cr3t container-structure-test test --config tests.yaml --image my-image-under-test. Unfortunately the test fails, because it does not substitute the ${PASSWORD} with the value I provide.

Would be very helpful to have an option to pass sensitive data to container under test from the outside.

gavvvr avatar Oct 13 '21 19:10 gavvvr

I have the same use case with token to SDM tahat I want to pass from env var exported.

Dysproz avatar Mar 24 '22 09:03 Dysproz

I also has trouble with this issue. If I make the pull request, will someone review it? If the answer is yes, I probably could do it on near weekends.

bananaappletw avatar Oct 11 '22 02:10 bananaappletw