Skip to content

Add lookup methods in Variables::Collection

What does this MR do?

This is the third MR in a Russian-doll style chain of 8 MRs culminating with !48627 (merged). It:

  1. Adds a @variables_by_key field to Variables::Collection to store an index of the items for quicker subsequent lookup when resolving variable references;
  2. Adds specialized #[] and #size methods to Variables::Collection to take advantage of new internal state (@var_hash);
  3. Adds helper #value property to Collection::Item.

List of MRs

  • MR 1: Make Collection::Sorted class take and output a Variables::Collection;
  • MR 2: Add #sorted_collection method and #errors property to Variables::Collection;
  • MR 3: Add indexing/lookup of variables to Variables::Collection;
  • MR 4: Add support for depends_on property to Variables::Collection::Item;
  • MR 5: Add support for raw property to Variables::Collection::Item;
  • MR 6: Add an #expand_variables_collection function to ExpandVariables to perform a full expansion of a Variables::Collection, gated by the new project-scoped :variable_inside_variable feature flag. It will return the original object if a cyclic reference is detected;
  • MR 7: Add error reporting to Gitlab::Ci::Pipeline::Seed::Build to let the user know when a problem occurs with variable expansion;
  • MR 8: Change Ci::BuildRunnerPresenter#variables to leverage ExpandVariables#expand_variables_collection so that variables sent in the job response are expanded;

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

Part of gitlab-runner#26345 (closed)

Edited by Kamil Trzciński

Merge request reports