Configuration file template for registration
(All cribbed from the existing MR)
Problem to Solve
Some of configuration settings of Runner can't be set with env variables or command line options. Env variables are for example not supporting slices. And for some settings (e.g. the whole K8S executor volumes tree) we intentionally didn't provide even the command line options support.
This however becomes a problem in automatically manage environments (e.g. when using GitLab Runner's official Docker images or Helm Chart for Runner deployment). And in such cases the only solution for now is to manually update the
config.toml file after the Runner was registered. This is hacky, this is error prone and this is definitely not reliable - especially when more than one registration for the same Runner installation is done.
Approach to solution
The linked MR tries to solve this problem in a way that will be generic for all environments. The
register command got a
--template-config command line option (that can be also set with the
TEMPLATE_CONFIG_FILE environment variable). When it's set it expects that a path to a configuration file template will be given as the value for this flag.
The configuration template file supports the subset of Runner's
config.toml file: it's restricted to support only
[[runners]] section and all it descendants. For the PoC implementation the global options are not supported.
Additionally the configuration template requires that only one
[[runners]] section is present in the file.
--template-config is used, then the configuration of
[[runners]] entry is merged into the configuration of newly created
[[runners]] entry in the regular
config.toml file. The merging is done only for options that were empty (so empty strings, nulls/non existing entries, zeroes). With this all configuration provided with command line options and/or environment variables during the
register command call take the precedence, and the template fills the gaps and adds additional settings.