Skip to content

Expand variables in Rails by topologically sorting them

What does this MR do?

This MR does the following:

  1. Adds variable_inside_variable feature flag (off by default)
  2. Adds ExpandVariables.each_variable_reference function to enable walking the variable references inside a variable value
  3. Changes Gitlab::Ci::Variables::Collection.to_runner_variables to support the new feature flag and return a topologically sorted/expanded array of variables. It will raise a new Gitlab::Ci::Variables::CyclicVariableReference exception if a cyclic reference is detected.
  4. Adds tests for new functionality in ExpandVariables and Gitlab::Ci::Variables::Collection, additionally with tests for both feature flag disabled and enabled (cyclic reference detection, topological sorting expectations, variable expansion).

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes gitlab-runner#26345 (closed)

Merge request reports