Add #expand_variable_collection to Variables::Collection
What does this MR do?
This is the sixth MR in a Russian-doll style chain of 8 MRs culminating with !48627 (merged). It:
- introduces the actual expansion logic for a
Collection, in the form of the newExpandVariables#expand_variables_collection. The method takes aCollectionand returns an array of hashes, containing the expanded variable values. If an error is detected, a newCollectioncontaining a populated#errorsproperty is returns, and the values will be unexpanded; - Modifies the
transform_variables/match_or_blank_valueprivate functions to work with a hash of variables, instead of hash of variable values. This allows us to check for theItem::rawflag to make a decision on whether to expand the variable. - Adds a
#mergemethod toItem, so that we can update the value. Come to think of it, should we just replace that with avalue=setter? It was previously used to also preserve the#depends_onvalue; - Adds a comparison operator
#==toCollection, so that we can compare a collection to another collection or to an array of variables without caring about the type (being used in test cases).
List of MRs
MR 1: MakeCollection::Sortedclass take and output aVariables::Collection;MR 2: Add#sorted_collectionmethod and#errorsproperty toVariables::Collection;MR 3: Add indexing/lookup of variables toVariables::Collection;MR 4: Add support fordepends_onproperty toVariables::Collection::Item;MR 5: Add support forrawproperty toVariables::Collection::Item;- MR 6: Add an
#expand_variables_collectionfunction toExpandVariablesto perform a full expansion of aVariables::Collection, gated by the new project-scoped:variable_inside_variablefeature flag. It will return the original object if a cyclic reference is detected; MR 7: Add error reporting toGitlab::Ci::Pipeline::Seed::Buildto let the user know when a problem occurs with variable expansion;- MR 7.5: Implement expression parser to be able to handle escaping in strings;
-
MR 8: Change
Ci::BuildRunnerPresenter#variablesto leverageExpandVariables#expand_variables_collectionso that variables sent in the job response are expanded;
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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