GoogleContainerTools / container-structure-test

validate the structure of your container images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing secret from the outside using env variables

gavvvr opened this issue · 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.

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

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.