diff --git a/regression-tests/__snapshots__/regresion.test.js.snap b/regression-tests/__snapshots__/regresion.test.js.snap index 45c10b7..9af9fff 100644 --- a/regression-tests/__snapshots__/regresion.test.js.snap +++ b/regression-tests/__snapshots__/regresion.test.js.snap @@ -2770,6 +2770,70 @@ Array [ "path": "./regression-tests/pipeline-test.yaml", "rule": "prefer-kebab-case", }, + Object { + "level": "error", + "loc": Object { + "endColumn": 19, + "endLine": 10, + "range": Array [ + 153, + 157, + ], + "startColumn": 15, + "startLine": 10, + }, + "message": "Pipeline 'prefer-when-expression' references task 'task' but the referenced task cannot be found. To fix this, include all the task definitions to the lint task for this pipeline.", + "path": "./regression-tests/prefer-when-expression.yaml", + "rule": "no-missing-resource", + }, + Object { + "level": "warning", + "loc": Object { + "endColumn": 5, + "endLine": 13, + "range": Array [ + 184, + 214, + ], + "startColumn": 9, + "startLine": 12, + }, + "message": "Task 'task-1' in Pipeline 'prefer-when-expression' is guarded by condition(s) ('condition'). Conditions are deprecated, use WhenExpressions instead.", + "path": "./regression-tests/prefer-when-expression.yaml", + "rule": "prefer-when-expression", + }, + Object { + "level": "error", + "loc": Object { + "endColumn": 1, + "endLine": 13, + "range": Array [ + 186, + 210, + ], + "startColumn": 11, + "startLine": 12, + }, + "message": "Pipeline 'prefer-when-expression' references Condition 'condition' but the referenced Condition cannot be found. To fix this, include all the Condition definitions to the lint task for this pipeline.", + "path": "./regression-tests/prefer-when-expression.yaml", + "rule": "no-missing-resource", + }, + Object { + "level": "error", + "loc": Object { + "endColumn": 19, + "endLine": 15, + "range": Array [ + 258, + 262, + ], + "startColumn": 15, + "startLine": 15, + }, + "message": "Pipeline 'prefer-when-expression' references task 'task' but the referenced task cannot be found. To fix this, include all the task definitions to the lint task for this pipeline.", + "path": "./regression-tests/prefer-when-expression.yaml", + "rule": "no-missing-resource", + }, Object { "level": "error", "loc": Object { diff --git a/regression-tests/prefer-when-expression.yaml b/regression-tests/prefer-when-expression.yaml new file mode 100644 index 0000000..1e1f7f4 --- /dev/null +++ b/regression-tests/prefer-when-expression.yaml @@ -0,0 +1,37 @@ +--- +apiVersion: tekton.dev/v1beta +kind: Pipeline +metadata: + name: prefer-when-expression +spec: + tasks: + - name: task-1 + taskRef: + name: task + conditions: + - conditionRef: condition + - name: task-2 + taskRef: + name: task +--- +apiVersion: tekton.dev/v1alpha1 +kind: TriggerTemplate +metadata: + name: prefer-when-expression +spec: + resourcetemplates: + - apiVersion: tekton.dev/v1beta + kind: PipelineRun + metadata: + name: prefer-when-expression-run + spec: + pipelineSpec: + tasks: + - name: task-1 + taskRef: + name: task + conditions: + - conditionRef: condition + - name: task-2 + taskRef: + name: task