Skip to content

Backend: Create a SSOT for CI config loading

Problem

Right now we load CI config in several locations in the codebase, but by default the Gitlab::Ci::Config::Yaml does not interpolate input parameters. This means we need to do interpolation everywhere.

Proposal

Create a SSoT class Gitlab::Ci::Config::Yaml::Loader that takes care of the interpolation and represents a safe abstraction to be used to load any CI configurations.

  1. We move Config::External::Interpolator to Config::Yaml::Interpolator
  2. We stop using module methods in Gitlab::Ci::Config::Yaml
  3. We move Gitlab::Ci::Config::Yaml::Loader into its own file lib/gitlab/ci/config/yaml/loader.rb and use it as the SSOT for GitLab CI configuration loading
  4. We give Gitlab::Ci::Config::Yaml::Loader a load! method that returns the interpolated content of the configuration
  5. We allow Gitlab::Ci::Config::Yaml::Loader to take an optional logger that can be used to track uses of interpolation

Details

We plan to support spec:inputs in .gitlab-ci.yml to enable pipeline inputs and replace prefilled variables for Run Pipeline form. We also want to support Compliance features built on top of templates and if a template defines spec:inputs we must load it and interpolate correctly.

Note: the presence of spec:inputs doesn't necessarily means that include:inputs must be used. The template could specify spec:inputs having all default values so passing include:inputs is not mandatory.

Implementation Plan

Step MR
1. Move all CI config loading classes under Ci::Config::Yaml module !121409 (merged)
2. Only call Interpolator from Loader !122092 (merged)
3. Update YAML loading in groupdynamic analysis classes !129387 (merged)
4. Update YAML loading in groupenvironments classes !129377 (merged)
5. Update YAML loading for simple cases in Verify classes !129720 (merged)
6. Spike: Update YAML loading for Ci::Config !129739 (closed)
Edited by Avielle Wolfe