Skip to content

Automatically read file variables and pass to specs container

Mark Lapierre requested to merge ml-mount-ci-project-dir into master

What does this MR do and why?

This MR reads the contents of file variables and passes the contents to the specs container instead of passing the file path. This requires that file variables are declared as such via type: :file. For example, instead of adding a variable to ENV_VARIABLES like 'WORKSPACES_DOMAIN_CERT' => :workspaces_domain_cert, you would declare it as a file variable like this:

ENV_VARIABLES = {
  ...
  'WORKSPACES_DOMAIN_CERT' => { name: :workspaces_domain_cert, type: :file },
  ...
}.freeze

How to set up and validate locally

echo 'foo' > fake_cert # we need a real file
export WORKSPACES_DOMAIN_CERT=fake_cert
export QA_SKIP_PULL=true # We're not running tests so we don't need the latest image (don't export this if you don't have a nightly image downloaded yes)
exe/gitlab-qa Test::Instance::Any EE http://gdk.test

That will output the Docker command to start the tests in a QA Docker container.

Check that the Docker command includes the masked variable. Something like:

[Sep 19 2023 13:53:07 AEST (Gitlab QA)] INFO  -- Shell command: `docker run ... --env WORKSPACES_DOMAIN_CERT="*****" ... --name gitlab-ee-qa-34a83d38 gitlab/gitlab-ee-qa:nightly Test::Instance::All http://gdk.test`

And you can check the value of the variable inside the container with the following command (substitute the container name):

❯ docker exec gitlab-ee-qa-34a83d38 bash -c 'echo $WORKSPACES_DOMAIN_CERT'
foo

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mark Lapierre

Merge request reports