Allow predefined functions in CI config interpolation; add truncate fxn
What does this MR do and why?
This MR adds support for functions to be specified in the Ci interpolation block. The syntax supported is:
$[[ <access> | <func1> | <func2> | ... <funcN> ]]
where <access>
specifies the value to retrieve (e.g. inputs.key
) and funcX
are optional functions that you can provide with or without arguments.
The truncate(<offset>,<length>)
function was also created so that it can be used to test this implementation.
Resolves #409462 (closed) (Step 1) as well as Step 3 (#409462 (closed)).
How to set up and validate locally
- Enable the FF:
Feature.enable(:ci_include_components)
. - Create a component file with the following contents:
components/component-1/template.yml
spec:
inputs:
test:
default: 012345678
---
test-job-1:
script: echo $[[ inputs.test | truncate(1,3) ]]
- In the Pipeline editor, update the config with the following. (Adjust the component path as needed.)
include:
- component: gdk.test:3000/group-a/project-6/components/component-1@master
- Observe that the Full configuration shows the input value truncated to 3 letters and offset by 1:
- You can also test the following scenarios:
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #409462 (closed)
Edited by Leaminn Ma