Problem
Tekton supports optional workspaces — a task can declare a workspace as optional, and the pipeline can choose not to bind it. Steps can check whether an optional workspace is bound using when expressions or $(workspaces.name.bound).
Currently chisel/mallet does not handle the optional: true field on workspace declarations.
Tekton Spec
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: my-task
spec:
workspaces:
- name: credentials
optional: true
steps:
- name: check
image: alpine
script: |
if [ "$(workspaces.credentials.bound)" = "true" ]; then
echo "Using credentials from workspace"
else
echo "No credentials provided, using defaults"
fi
Also works in when expressions:
when:
- input: $(workspaces.credentials.bound)
operator: in
values: ["true"]
Upstream examples
optional-workspaces.yaml
using-optional-workspaces-in-when-expressions.yaml
Implementation
- Parse
optional: true on workspace declarations
- Don't error when an optional workspace is not bound
- Substitute
$(workspaces.name.bound) with true/false
- When not bound,
$(workspaces.name.path) should resolve to empty string or a defined sentinel
Acceptance Criteria
optional: true workspaces don't require binding
$(workspaces.name.bound) resolves to true/false
- Unbound optional workspace doesn't cause errors
- Works in when expressions
optional-workspaces* upstream examples pass
- Works with both chisel and mallet
Jira: SRVKP-11415 (sub-gap)
Parent tracking: #41
Problem
Tekton supports optional workspaces — a task can declare a workspace as optional, and the pipeline can choose not to bind it. Steps can check whether an optional workspace is bound using when expressions or
$(workspaces.name.bound).Currently chisel/mallet does not handle the
optional: truefield on workspace declarations.Tekton Spec
Also works in when expressions:
Upstream examples
optional-workspaces.yamlusing-optional-workspaces-in-when-expressions.yamlImplementation
optional: trueon workspace declarations$(workspaces.name.bound)withtrue/false$(workspaces.name.path)should resolve to empty string or a defined sentinelAcceptance Criteria
optional: trueworkspaces don't require binding$(workspaces.name.bound)resolves totrue/falseoptional-workspaces*upstream examples passJira: SRVKP-11415 (sub-gap)
Parent tracking: #41