Allow non-literal Boolean usage with spec:inputs:rules
Given this component template in templates/publish_input_test.yml:
spec:
inputs:
publish:
type: boolean
description: 'set to false to disable publishing'
default: true
publish_stage:
type: string
description: name of the publish stage
rules:
- if: '"$[[ inputs.publish ]]" == "true"'
default: 'publish'
- if: '"$[[ inputs.publish ]]" == "false"'
default: 'test'
- default: 'publish'
---
debug_publish:
stage: "$[[ inputs.publish_stage ]]"
script:
- 'echo "publish: $[[ inputs.publish ]]"'
- 'echo "publish stage: $[[ inputs.publish_stage ]]"'
And this pipeline in the CI/CD catalog's .gitlab-ci.yml:
---
stages:
- test
include:
- component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/publish_input_test@$CI_COMMIT_SHA
inputs:
publish: false
The pipeline fails with the message that the publish stage does not exist. Adding the publish stage resolves the error and debug output confirms that publish is false and publish_stage is publish.
Expected result: since the publish input is false, the publish_stage input should default to test.
Switching from a boolean to string input and/or modifying the 'if' syntax did not resolve the issue.
Edited by Laura Montemayor