Add map type for CI component input
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you can request access to GitLab Duo.
What does this MR do and why?
This merge request allows to pass a hash-map (for variables) as input to the component:
spec:
inputs:
variables:
type: map # new type
default:
SOME_VARIABLE: "This is the example content of a variable"
ANOTHER_VARIABLE: $CI_PROJECT_DIR/another/path
In my ci component i have a kinda LAMP stack (Linux, Apache/NGINX, MySQL/MariaDB/Postgres PHP) that runs as a service. A user might add redis or solr to the stack. These images are configurable through environment variables.
This will allow my component to have a services and variables added to run these additional services if need.
References
- Simple example: https://gitlab.com/ochorocho/ci-component-minimal
- Fixes: Allow spec:input type of hash or allow variable... (#452451)
- Component job override to add variables: https://gitlab.com/ochorocho/lamp-acceptance-testing#typo3-usage-example
- Example usage in a template: https://gitlab.com/ochorocho/lamp-acceptance-testing/-/blob/8da989238f2066cd99e4caf3e6f529c4c22b5d96/templates/lamp/template.yml#L59-66
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Example below:
- Use a component and define
spec.input.<something>
and set it to typemap
(see code block above) - Add variables when including the job
- component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/example-variables@$CI_COMMIT_SHA inputs: variables: SOME_VARIABLE: "This is some variable."
- Check the jobs logs. to see the variables available in the component.
Edited by Jochen