diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 816eecfe1eb..980f2d94199 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -51,7 +51,6 @@ var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ v1alpha1.SchemeGroupVersion.WithKind("ClusterTask"): &v1alpha1.ClusterTask{}, v1alpha1.SchemeGroupVersion.WithKind("TaskRun"): &v1alpha1.TaskRun{}, v1alpha1.SchemeGroupVersion.WithKind("PipelineRun"): &v1alpha1.PipelineRun{}, - v1alpha1.SchemeGroupVersion.WithKind("Condition"): &v1alpha1.Condition{}, v1alpha1.SchemeGroupVersion.WithKind("PipelineResource"): &v1alpha1.PipelineResource{}, v1alpha1.SchemeGroupVersion.WithKind("Run"): &v1alpha1.Run{}, // v1beta1 diff --git a/config/300-condition.yaml b/config/300-condition.yaml deleted file mode 100644 index fa76b8558c6..00000000000 --- a/config/300-condition.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2019 The Tekton Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: conditions.tekton.dev - labels: - app.kubernetes.io/instance: default - app.kubernetes.io/part-of: tekton-pipelines - pipeline.tekton.dev/release: "devel" - version: "devel" -spec: - group: tekton.dev - versions: - - name: v1alpha1 - served: true - storage: true - schema: - openAPIV3Schema: - type: object - # One can use x-kubernetes-preserve-unknown-fields: true - # at the root of the schema (and inside any properties, additionalProperties) - # to get the traditional CRD behaviour that nothing is pruned, despite - # setting spec.preserveUnknownProperties: false. - # - # See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/ - # See issue: https://github.com/knative/serving/issues/912 - x-kubernetes-preserve-unknown-fields: true - # Opt into the status subresource so metadata.generation - # starts to increment - subresources: - status: {} - names: - kind: Condition - plural: conditions - singular: condition - categories: - - tekton - - tekton-pipelines - scope: Namespaced diff --git a/docs/conditions.md b/docs/conditions.md index b28ea42cbe8..7998558fe0a 100644 --- a/docs/conditions.md +++ b/docs/conditions.md @@ -6,99 +6,7 @@ weight: 2100 --> # Conditions -**Note:** `Conditions` are deprecated, use [`when` expressions](pipelines.md#guard-task-execution-using-when-expressions) instead. - -- [Overview](#overview) -- [Configuring a `Condition`](#configuring-a-condition) - - [Specifying the condition `check`](#specifying-the-condition-check) - - [Specifying `Parameters`](#specifying-parameters) - - [Specifying `Resources`](#specifying-resources) -- [Code examples](#code-examples) - -## Overview - -A `Condition` resource in Tekton allows you to conditionalize the execution of `Tasks` within a `Pipeline`. -You define each `Condition` within your [`PipelineRun` definition](pipelineruns.md) and then conditionalize -each desired [`Task`](tasks.md) in the corresponding `Pipeline` definition. - -The `Condition` resource runs its own container image that executes the logic that evaluates your chosen condition. -This container runs to completion and must return an exit code value of `0` for the `check` to be successful; otherwise -the conditionalized `Task` as well as its `Task` dependencies (defined via `runAfter`) and `Resource` dependencies -(such as results) do not execute. - -**Note:** [Labels](labels.md) and annotations specified in the `Condition's` metadata are automatically -propagated to the `Pod`. - -## Configuring a `Condition` - -A `Condition` definition supports the following fields: - -- Required: - - [`apiVersion`][kubernetes-overview] - Specifies the API version, for example - `tekton.dev/v1alpha1`. - - [`kind`][kubernetes-overview] - Identifies this resource object as a `Condition` object. - - [`metadata`][kubernetes-overview] - Specifies metadata that uniquely identifies this - `Condition` object. For example, a `name`. - - [`spec`][kubernetes-overview] - Specifies the configuration information for - this `Condition` resource object. This must include: - - [`check`](#check) - Specifies a container that you want to run for evaluating this `Condition`. - - [`description`](#description) - Provides a meaningful description of this `Condition` object. - -[kubernetes-overview]: - https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/#required-fields - -### Specifying the condition `check` - -The `check` field (required) specifies a single piece of evaluation logic that you want to run before the -corresponding `Task` in your `Pipeline` can execute. This field must specify a [`Step`](./tasks.md#steps). - -### Specifying `Parameters` - -You can specify parameters to pass to the `Condition's` evaluation logic at run time. -Sub-fields within the `check` field can access these parameter values using Tekton's templating -syntax as follows: - -```yaml -spec: - parameters: - - name: image - default: ubuntu - check: - image: $(params.image) -``` - -Parameter names: -- Must only contain alphanumeric characters, hyphens (`-`), and underscores (`_`). -- Must begin with a letter or an underscore (`_`). - -For example, `fooIs-Bar_` is a valid parameter name, but `barIsBa$` or `0banana` are not. - -Each declared parameter has a `type` field, which can be set to either `array` or `string`, and -defaults to `string` if you don't specify a value. The `description` and `default` fields for a -`Parameter` are optional. The `array` type is useful in situations such as checking that a pushed -branch name doesn't collide with any of the specified protected branch names. - -### Specifying `Resources` - -> :warning: **`PipelineResources` are [deprecated](deprecations.md#deprecation-table).** -> -> Consider using replacement features instead. Read more in [documentation](migrating-v1alpha1-to-v1beta1.md#replacing-pipelineresources-with-tasks) -> and [TEP-0074](https://github.com/tektoncd/community/blob/main/teps/0074-deprecate-pipelineresources.md). - -You can specify input [`PipelineResources`](resources.md) in your `Condition` definition to -provide the `Condition's` container step with data or context necessary to run the evaluation logic. - -`Resources` in `Conditions` behave the same way as in `Tasks`: -- You can access them via [variable substitution](resources.md#variable-substitution). -- You can use the `targetPath` field to [specify a mount point](resources.md#controlling-where-resources-are-mounted). - -### Adding a `description` - -The `description` field (optional) allows you to specify a meaningful description for your `Condition`. - -## Code examples - -For a better understanding of `Conditions`, study [our code examples](https://github.com/tektoncd/pipeline/tree/main/examples). +**Note:** `Conditions` have been removed as of Pipeline 0.37.0, use [`when` expressions](pipelines.md#guard-task-execution-using-when-expressions) instead. --- diff --git a/docs/labels.md b/docs/labels.md index 0d028e26da2..fdb80a5aef0 100644 --- a/docs/labels.md +++ b/docs/labels.md @@ -36,8 +36,6 @@ and then to the associated `Pods`. As for `Pipeline` and `PipelineRun`, if a lab propagate from the [referenced `Task`](taskruns.md#specifying-the-target-task), if one exists, to the corresponding `TaskRun`, and then to the associated `Pod`. The same as above applies. -- For `Conditions`, labels propagate to the corresponding `TaskRuns`, and then to the associated `Pods`. - ## Automatic labeling Tekton automatically adds labels to Tekton entities as described in the following table. @@ -135,5 +133,3 @@ and then to the associated `Pods`. As for `Pipeline` and `PipelineRun`, if a ann - For standalone `TaskRuns` (that is, ones not executing as part of a `Pipeline`), annotations propagate from the [referenced `Task`](taskruns.md#specifying-the-target-task), if one exists, to the corresponding `TaskRun`, and then to the associated `Pod`. The same as above applies. - -- For `Conditions`, annotations propagate to the corresponding `TaskRuns`, and then to the associated `Pods`. diff --git a/docs/pipelineruns.md b/docs/pipelineruns.md index 8bfe4fd8b3a..7c745a45172 100644 --- a/docs/pipelineruns.md +++ b/docs/pipelineruns.md @@ -893,7 +893,6 @@ Your `PipelineRun`'s `status` field can contain the following fields: - `childReferences` - A list of references to each `TaskRun` or `Run` in this `PipelineRun`, which can be used to look up the status of the underlying `TaskRun` or `Run`. Each entry contains the following: - [`kind`][kubernetes-overview] - Generally either `TaskRun` or `Run`. - [`apiVersion`][kubernetes-overview] - The API version for the underlying `TaskRun` or `Run`. - - `conditionChecks` - A list of [condition checks](conditions.md) performed for this `TaskRun`. `conditions` are deprecated and this will be removed in the future. - [`whenExpressions`](pipelines.md#guard-task-execution-using-when-expressions) - The list of when expressions guarding the execution of this task. ### Configuring usage of `TaskRun` and `Run` embedded statuses @@ -915,7 +914,7 @@ information on feature flags. The possible values for `embedded-status` are: As your `PipelineRun` executes, its `status` field accumulates information on the execution of each `TaskRun` as well as the `PipelineRun` as a whole. This information includes the name of the pipeline `Task` associated to a `TaskRun`, the complete [status of the `TaskRun`](taskruns.md#monitoring-execution-status) and details -about `Conditions` that may be associated to a `TaskRun`. +about `whenExpressions` that may be associated to a `TaskRun`. The following example shows an extract from the `status` field of a `PipelineRun` that has executed successfully: diff --git a/docs/pipelines.md b/docs/pipelines.md index 46cef48193f..86d1f7aa5eb 100644 --- a/docs/pipelines.md +++ b/docs/pipelines.md @@ -26,7 +26,6 @@ weight: 400 - [Cascade `when` expressions to the specific dependent `Tasks`](#cascade-when-expressions-to-the-specific-dependent-tasks) - [Compose using Pipelines in Pipelines](#compose-using-pipelines-in-pipelines) - [Guarding a `Task` only](#guarding-a-task-only) - - [Guard `Task` execution using `Conditions`](#guard-task-execution-using-conditions) - [Configuring the failure timeout](#configuring-the-failure-timeout) - [Using variable substitution](#using-variable-substitution) - [Using the `retries` and `retry-count` variable substitutions](#using-the-retries-and-retry-count-variable-substitutions) @@ -51,7 +50,6 @@ weight: 400 - [Known Limitations](#known-limitations) - [Specifying `Resources` in `finally` tasks](#specifying-resources-in-finally-tasks) - [Cannot configure the `finally` task execution order](#cannot-configure-the-finally-task-execution-order) - - [Cannot specify execution `Conditions` in `finally` tasks](#cannot-specify-execution-conditions-in-finally-tasks) - [Cannot configure `Pipeline` result with `finally`](#cannot-configure-pipeline-result-with-finally) - [Using Custom Tasks](#using-custom-tasks) - [Specifying the target Custom Task](#specifying-the-target-custom-task) @@ -101,8 +99,6 @@ A `Pipeline` definition supports the following fields: `Tasks` without output linking. - [`retries`](#using-the-retries-field) - Specifies the number of times to retry the execution of a `Task` after a failure. Does not apply to execution cancellations. - - [`conditions`](#guard-task-execution-using-conditions) - Specifies `Conditions` that only allow a `Task` - to execute if they successfully evaluate. - [`when`](#guard-finally-task-execution-using-when-expressions) - Specifies `when` expressions that guard the execution of a `Task`; allow execution only when all `when` expressions evaluate to true. - [`timeout`](#configuring-the-failure-timeout) - Specifies the timeout before a `Task` fails. @@ -602,8 +598,6 @@ tasks: For an end-to-end example, see [PipelineRun with `when` expressions](../examples/v1beta1/pipelineruns/pipelinerun-with-when-expressions.yaml). -When `when` expressions are specified in a `Task`, [`Conditions`](#guard-task-execution-using-conditions) should not be specified in the same `Task`. The `Pipeline` will be rejected as invalid if both `when` expressions and `Conditions` are included. - There are a lot of scenarios where `when` expressions can be really useful. Some of these are: - Checking if the name of a git branch matches - Checking if the `Result` of a previous `Task` is as expected @@ -823,72 +817,6 @@ would be unblocked regardless: - if `manual-approval` specifies a default `approver` `Result`, such as "None", then `slack-msg` would be executed ([supporting default `Results` is in progress](https://github.com/tektoncd/community/pull/240)) -### Guard `Task` execution using `Conditions` - -**Note:** `Conditions` are [deprecated](./deprecations.md), use [`when` expressions](#guard-task-execution-using-when-expressions) instead. - -To run a `Task` only when certain conditions are met, it is possible to _guard_ task execution using -the `conditions` field. The `conditions` field allows you to list a series of references to -[`Condition`](./conditions.md) resources. The declared `Conditions` are run before the `Task` is run. -If all of the conditions successfully evaluate, the `Task` is run. If any of the conditions fails, -the `Task` is not run and the `TaskRun` status field `ConditionSucceeded` is set to `False` with the -reason set to `ConditionCheckFailed`. - -In this example, `is-master-branch` refers to a [Condition](conditions.md) resource. The `deploy` -task will only be executed if the condition successfully evaluates. - -```yaml -tasks: - - name: deploy-if-branch-is-master - conditions: - - conditionRef: is-master-branch - params: - - name: branch-name - value: my-value - taskRef: - name: deploy -``` - -Unlike regular task failures, condition failures do not automatically fail the entire `PipelineRun` -- -other tasks that are **not dependent** on the `Task` (via `from` or `runAfter`) are still run. - -In this example, `(task C)` has a `condition` set to _guard_ its execution. If the condition -is **not** successfully evaluated, task `(task D)` will not be run, but all other tasks in the pipeline -that not depend on `(task C)` will be executed and the `PipelineRun` will successfully complete. - - ``` - (task B) — (task E) - / - (task A) - \ - (guarded task C) — (task D) - ``` - -Resources in conditions can also use the [`from`](#using-the-from-field) field to indicate that they -expect the output of a previous task as input. As with regular Pipeline Tasks, using `from` -implies ordering -- if task has a condition that takes in an output resource from -another task, the task producing the output resource will run first: - -```yaml -tasks: - - name: first-create-file - taskRef: - name: create-file - resources: - outputs: - - name: workspace - resource: source-repo - - name: then-check - conditions: - - conditionRef: "file-exists" - resources: - - name: workspace - resource: source-repo - from: [first-create-file] - taskRef: - name: echo-hello -``` - ### Configuring the failure timeout You can use the `Timeout` field in the `Task` spec within the `Pipeline` to set the timeout @@ -1304,22 +1232,22 @@ With `finally`, `PipelineRun` status is calculated based on `PipelineTasks` unde Without `finally`: -| `PipelineTasks` under `tasks` | `PipelineRun` status | Reason | -|--------------------------------------------------------------------------|----------------------|-------------| -| all `PipelineTasks` successful | `true` | `Succeeded` | -| one or more `PipelineTasks` [skipped](conditions.md) and rest successful | `true` | `Completed` | -| single failure of `PipelineTask` | `false` | `failed` | +| `PipelineTasks` under `tasks` | `PipelineRun` status | Reason | +|---------------------------------------------------------------------------------------------------------|----------------------|-------------| +| all `PipelineTasks` successful | `true` | `Succeeded` | +| one or more `PipelineTasks` [skipped](#guard-task-execution-using-when-expressions) and rest successful | `true` | `Completed` | +| single failure of `PipelineTask` | `false` | `failed` | With `finally`: -| `PipelineTasks` under `tasks` | `finally` tasks | `PipelineRun` status | Reason | -|-------------------------------------------------------------------------|----------------------------------------|----------------------|-------------| -| all `PipelineTask` successful | all `finally` tasks successful | `true` | `Succeeded` | -| all `PipelineTask` successful | one or more failure of `finally` tasks | `false` | `Failed` | -| one or more `PipelineTask` [skipped](conditions.md) and rest successful | all `finally` tasks successful | `true` | `Completed` | -| one or more `PipelineTask` [skipped](conditions.md) and rest successful | one or more failure of `finally` tasks | `false` | `Failed` | -| single failure of `PipelineTask` | all `finally` tasks successful | `false` | `failed` | -| single failure of `PipelineTask` | one or more failure of `finally` tasks | `false` | `failed` | +| `PipelineTasks` under `tasks` | `finally` tasks | `PipelineRun` status | Reason | +|--------------------------------------------------------------------------------------------------------|----------------------------------------|----------------------|-------------| +| all `PipelineTask` successful | all `finally` tasks successful | `true` | `Succeeded` | +| all `PipelineTask` successful | one or more failure of `finally` tasks | `false` | `Failed` | +| one or more `PipelineTask` [skipped](#guard-task-execution-using-when-expressions) and rest successful | all `finally` tasks successful | `true` | `Completed` | +| one or more `PipelineTask` [skipped](#guard-task-execution-using-when-expressions) and rest successful | one or more failure of `finally` tasks | `false` | `Failed` | +| single failure of `PipelineTask` | all `finally` tasks successful | `false` | `failed` | +| single failure of `PipelineTask` | one or more failure of `finally` tasks | `false` | `failed` | Overall, `PipelineRun` state transitioning is explained below for respective scenarios: @@ -1574,12 +1502,6 @@ It's not possible to configure or modify the execution order of the `finally` ta all `finally` tasks run simultaneously and start executing once all `PipelineTasks` under `tasks` have settled which means no `runAfter` can be specified in `finally` tasks. -#### Cannot specify execution `Conditions` in `finally` tasks - -`Tasks` in a `Pipeline` can be configured to run only if some conditions are satisfied using `conditions`. But the -`finally` tasks are guaranteed to be executed after all `PipelineTasks` therefore no `conditions` can be specified in -`finally` tasks. - #### Cannot configure `Pipeline` result with `finally` `finally` tasks can emit `Results` but results emitted from the `finally` tasks can not be configured in the @@ -1749,7 +1671,6 @@ Pipelines do not support the following items with custom tasks: * Pipeline Resources * [`retries`](#using-the-retries-field) * [`timeout`](#configuring-the-failure-timeout) -* Conditions (`Conditions` are deprecated. Use [`when` expressions](#guard-task-execution-using-when-expressions) instead.) ## Code examples diff --git a/docs/resources.md b/docs/resources.md index 17f01a5001e..6b107143299 100644 --- a/docs/resources.md +++ b/docs/resources.md @@ -88,8 +88,7 @@ following fields: > Consider using replacement features instead. Read more in [documentation](migrating-v1alpha1-to-v1beta1.md#replacing-pipelineresources-with-tasks) > and [TEP-0074](https://github.com/tektoncd/community/blob/main/teps/0074-deprecate-pipelineresources.md). -Resources can be used in [Tasks](./tasks.md) and -[Conditions](./conditions.md#resources). +Resources can be used in [Tasks](./tasks.md). Input resources, like source code (git) or artifacts, are dumped at path `/workspace/task_resource_name` within a mounted @@ -102,7 +101,7 @@ refer to the local path to the mounted resource. ### Variable substitution -`Task` and `Condition` specs can refer resource params as well as predefined +`Task` specs can refer resource params as well as predefined variables such as `path` using the variable substitution syntax below where `` is the resource's `name` and `` is one of the resource's `params`: @@ -116,14 +115,6 @@ Or for an output resource: $(outputs.resources..) ``` -#### In Condition Spec: - -Input resources can be accessed by: - -```shell -$(resources..) -``` - #### Accessing local path to resource The `path` key is predefined and refers to the local path to a resource on the @@ -295,12 +286,10 @@ spec: ``` You can refer to different examples demonstrating usage of optional resources in -`Task`, `Condition`, and `Pipeline`: +`Task` and `Pipeline`: - [Task](../examples/v1beta1/taskruns/optional-resources.yaml) - [Cluster Task](../examples/v1beta1/taskruns/optional-resources-with-clustertask.yaml) -- [Condition](../examples/v1beta1/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml) -- [Pipeline](../examples/v1beta1/pipelineruns/demo-optional-resources.yaml) ## Resource Types diff --git a/examples/v1alpha1/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml b/examples/v1alpha1/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml deleted file mode 100644 index 260a2af0cde..00000000000 --- a/examples/v1alpha1/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml +++ /dev/null @@ -1,85 +0,0 @@ -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: verify-no-file-exists-without-resource -spec: - params: - - name: "path" - resources: - - name: optional-workspace - type: git - optional: true - check: - image: alpine - script: 'test ! -f $(resources.optional-workspace.path)/$(params.path)' ---- -apiVersion: tekton.dev/v1alpha1 -kind: PipelineResource -metadata: - name: pipeline-git-repo -spec: - type: git - params: - - name: revision - value: main - - name: url - value: https://github.com/tektoncd/pipeline ---- -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: list-pipeline-repo-files -spec: - inputs: - resources: - - name: optional-workspace - type: git - optional: true - steps: - - name: run-ls - image: ubuntu - script: 'ls -al $(inputs.resources.optional-workspace.path)' ---- -apiVersion: tekton.dev/v1alpha1 -kind: Pipeline -metadata: - name: pipeline-list-pipeline-repo-files -spec: - resources: - - name: pipeline-source-repo - type: git - params: - - name: "path" - default: "README.md" - tasks: - - name: list-pipeline-repo-files-1 - taskRef: - name: list-pipeline-repo-files - conditions: - - conditionRef: "verify-no-file-exists-without-resource" - params: - - name: "path" - value: "$(params.path)" -# NOTE: Resource "optional-workspace" is declared as optional in Condition -# No resource specified for the condition here since its optional -# "DO NOT UNCOMMENT THE FOLLOWING RESOURCE" -# resources: -# - name: optional-workspace -# resource: pipeline-source-repo - resources: - inputs: - - name: optional-workspace - resource: pipeline-source-repo ---- -apiVersion: tekton.dev/v1alpha1 -kind: PipelineRun -metadata: - name: demo-conditional-pr-without-condition-resource -spec: - pipelineRef: - name: pipeline-list-pipeline-repo-files - serviceAccountName: 'default' - resources: - - name: pipeline-source-repo - resourceRef: - name: pipeline-git-repo diff --git a/examples/v1alpha1/pipelineruns/conditional-pipelinerun-with-same-condition-refer.yaml b/examples/v1alpha1/pipelineruns/conditional-pipelinerun-with-same-condition-refer.yaml deleted file mode 100644 index e69766bf106..00000000000 --- a/examples/v1alpha1/pipelineruns/conditional-pipelinerun-with-same-condition-refer.yaml +++ /dev/null @@ -1,73 +0,0 @@ -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: is-equal -spec: - params: - - name: left - type: string - - name: right - type: string - check: - image: alpine - script: | - #!/bin/sh - if [ $(params.left) = $(params.right) ]; then - echo "$(params.left) == $(params.right)" - exit 0 - else - echo "$(params.left) != $(params.right)" - exit 1 - fi ---- -apiVersion: tekton.dev/v1alpha1 -kind: Pipeline -metadata: - name: condition-pipeline -spec: - params: - - name: one - type: string - - name: two - type: string - tasks: - - name: process - conditions: - - conditionRef: is-equal - params: - - name: left - value: "1" - - name: right - value: $(params.one) - - conditionRef: is-equal - params: - - name: left - value: "1" - - name: right - value: $(params.two) - taskRef: - kind: Task - name: run ---- -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: run -spec: - steps: - - name: echo - image: ubuntu - script: 'echo hello' ---- -apiVersion: tekton.dev/v1alpha1 -kind: PipelineRun -metadata: - name: condition-pipelinerun -spec: - params: - - name: one - value: "1" - - name: two - value: "2" - pipelineRef: - name: condition-pipeline diff --git a/examples/v1alpha1/pipelineruns/conditional-pipelinerun.yaml b/examples/v1alpha1/pipelineruns/conditional-pipelinerun.yaml deleted file mode 100644 index c32b1fb5300..00000000000 --- a/examples/v1alpha1/pipelineruns/conditional-pipelinerun.yaml +++ /dev/null @@ -1,94 +0,0 @@ -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: file-exists -spec: - params: - - name: "path" - resources: - - name: workspace - type: git - check: - image: alpine - script: 'test -f $(resources.workspace.path)/$(params.path)' ---- -apiVersion: tekton.dev/v1alpha1 -kind: PipelineResource -metadata: - name: pipeline-git -spec: - type: git - params: - - name: revision - value: main - - name: url - value: https://github.com/tektoncd/pipeline ---- -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: create-readme-file -spec: - outputs: - resources: - - name: workspace - type: git - steps: - - name: write-new-stuff - image: ubuntu - script: 'touch $(outputs.resources.workspace.path)/README.md' ---- -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: echo-hello -spec: - steps: - - name: echo - image: ubuntu - script: 'echo hello' ---- -apiVersion: tekton.dev/v1alpha1 -kind: Pipeline -metadata: - name: conditional-pipeline -spec: - resources: - - name: source-repo - type: git - params: - - name: "path" - default: "README.md" - tasks: - - name: first-create-file - taskRef: - name: create-readme-file - resources: - outputs: - - name: workspace - resource: source-repo - - name: then-check - conditions: - - conditionRef: "file-exists" - params: - - name: "path" - value: "$(params.path)" - resources: - - name: workspace - resource: source-repo - from: [first-create-file] - taskRef: - name: echo-hello ---- -apiVersion: tekton.dev/v1alpha1 -kind: PipelineRun -metadata: - name: conditional-pr -spec: - pipelineRef: - name: conditional-pipeline - serviceAccountName: 'default' - resources: - - name: source-repo - resourceRef: - name: pipeline-git diff --git a/examples/v1alpha1/pipelineruns/demo-optional-resources.yaml b/examples/v1alpha1/pipelineruns/demo-optional-resources.yaml deleted file mode 100644 index dfdced2f112..00000000000 --- a/examples/v1alpha1/pipelineruns/demo-optional-resources.yaml +++ /dev/null @@ -1,128 +0,0 @@ -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: check-git-pipeline-resource -spec: - params: - - name: "path" - resources: - - name: git-repo - type: git - optional: true - check: - image: alpine - script: 'test -f $(resources.git-repo.path)/$(params.path)' ---- - -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: check-image-pipeline-resource -spec: - resources: - - name: built-image - type: image - optional: true - check: - image: alpine - script: 'test ! -z $(resources.built-image.url)' ---- - -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: build-an-image -spec: - inputs: - resources: - - name: git-repo - type: git - optional: true - params: - - name: DOCKERFILE - description: The path to the dockerfile to build from GitHub Repo - default: "Dockerfile" - outputs: - resources: - - name: built-image - type: image - optional: true - steps: - - name: build-an-image - image: gcr.io/kaniko-project/executor:v1.3.0 - command: - - /kaniko/executor - args: - - --dockerfile=$(inputs.params.DOCKERFILE) - - --destination=$(outputs.resources.built-image.url) ---- - -apiVersion: tekton.dev/v1alpha1 -kind: Pipeline -metadata: - name: demo-pipeline-to-build-an-image -spec: - resources: - - name: source-repo - type: git - optional: true - - name: web-image - type: image - optional: true - params: - - name: "path" - default: "README.md" - tasks: - - name: build-an-image - taskRef: - name: build-an-image - conditions: - - conditionRef: "check-git-pipeline-resource" - params: - - name: "path" - value: "$(params.path)" - resources: - - name: git-repo - resource: source-repo - - conditionRef: "check-image-pipeline-resource" - resources: - - name: built-image - resource: web-image - resources: - inputs: - - name: git-repo - resource: source-repo - outputs: - - name: built-image - resource: web-image - ---- - -apiVersion: tekton.dev/v1alpha1 -kind: PipelineRun -metadata: - name: demo-pipeline-to-build-an-image-without-resources -spec: - pipelineRef: - name: demo-pipeline-to-build-an-image - serviceAccountName: 'default' ---- - -apiVersion: tekton.dev/v1alpha1 -kind: PipelineRun -metadata: - name: demo-pipeline-to-build-an-image-without-image-resource -spec: - pipelineRef: - name: demo-pipeline-to-build-an-image - serviceAccountName: 'default' - resources: - - name: source-repo - resourceSpec: - type: git - params: - - name: revision - value: main - - name: url - value: https://github.com/tektoncd/pipeline ---- diff --git a/examples/v1alpha1/pipelineruns/pipelinerun-with-resourcespec.yaml b/examples/v1alpha1/pipelineruns/pipelinerun-with-resourcespec.yaml index 5a03eea0aac..e2c8aad8f3b 100644 --- a/examples/v1alpha1/pipelineruns/pipelinerun-with-resourcespec.yaml +++ b/examples/v1alpha1/pipelineruns/pipelinerun-with-resourcespec.yaml @@ -22,24 +22,6 @@ spec: ls -al $(inputs.resources.pipeline-git.path) --- -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: always-true-sample-condition -spec: - resources: - - name: pipeline-git - type: git - check: - image: ubuntu - command: - - bash - args: - - -c - - | - echo "Hello from Tekton Pipeline!" ---- - apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: @@ -62,14 +44,9 @@ spec: outputs: - name: pipeline-git resource: pipeline-git - - name: conditional-list-files + - name: second-list-files taskRef: name: task-to-list-files - conditions: - - conditionRef: always-true-sample-condition - resources: - - name: pipeline-git - resource: pipeline-git resources: inputs: - name: pipeline-git diff --git a/examples/v1beta1/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml b/examples/v1beta1/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml deleted file mode 100644 index 98c95b9d7e0..00000000000 --- a/examples/v1beta1/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml +++ /dev/null @@ -1,89 +0,0 @@ -# `Conditions` are deprecated, use `when` expressions instead -# https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#guard-task-execution-using-when-expressions -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: verify-no-file-exists-without-resource -spec: - params: - - name: "path" - resources: - - name: optional-workspace - type: git - optional: true - check: - image: alpine - script: 'test ! -f $(resources.optional-workspace.path)/$(params.path)' ---- -# `PipelineResources` are deprecated, consider using `Tasks` and other replacement features instead -# https://github.com/tektoncd/pipeline/blob/main/docs/migrating-v1alpha1-to-v1beta1.md#replacing-pipelineresources-with-tasks -apiVersion: tekton.dev/v1alpha1 -kind: PipelineResource -metadata: - name: pipeline-git-repo -spec: - type: git - params: - - name: revision - value: main - - name: url - value: https://github.com/tektoncd/pipeline ---- -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: list-pipeline-repo-files -spec: - resources: - inputs: - - name: optional-workspace - type: git - optional: true - steps: - - name: run-ls - image: ubuntu - script: 'ls -al $(inputs.resources.optional-workspace.path)' ---- -apiVersion: tekton.dev/v1beta1 -kind: Pipeline -metadata: - name: pipeline-list-pipeline-repo-files -spec: - resources: - - name: pipeline-source-repo - type: git - params: - - name: "path" - default: "README.md" - tasks: - - name: list-pipeline-repo-files-1 - taskRef: - name: list-pipeline-repo-files - conditions: - - conditionRef: "verify-no-file-exists-without-resource" - params: - - name: "path" - value: "$(params.path)" -# NOTE: Resource "optional-workspace" is declared as optional in Condition -# No resource specified for the condition here since its optional -# "DO NOT UNCOMMENT THE FOLLOWING RESOURCE" -# resources: -# - name: optional-workspace -# resource: pipeline-source-repo - resources: - inputs: - - name: optional-workspace - resource: pipeline-source-repo ---- -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - name: demo-conditional-pr-without-condition-resource -spec: - pipelineRef: - name: pipeline-list-pipeline-repo-files - serviceAccountName: 'default' - resources: - - name: pipeline-source-repo - resourceRef: - name: pipeline-git-repo diff --git a/examples/v1beta1/pipelineruns/conditional-pipelinerun-with-same-condition-refer.yaml b/examples/v1beta1/pipelineruns/conditional-pipelinerun-with-same-condition-refer.yaml deleted file mode 100644 index e9780040bd8..00000000000 --- a/examples/v1beta1/pipelineruns/conditional-pipelinerun-with-same-condition-refer.yaml +++ /dev/null @@ -1,75 +0,0 @@ -# `Conditions` are deprecated, use `when` expressions instead -# https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#guard-task-execution-using-when-expressions -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: is-equal -spec: - params: - - name: left - type: string - - name: right - type: string - check: - image: alpine - script: | - #!/bin/sh - if [ $(params.left) = $(params.right) ]; then - echo "$(params.left) == $(params.right)" - exit 0 - else - echo "$(params.left) != $(params.right)" - exit 1 - fi ---- -apiVersion: tekton.dev/v1beta1 -kind: Pipeline -metadata: - name: condition-pipeline -spec: - params: - - name: one - type: string - - name: two - type: string - tasks: - - name: process - conditions: - - conditionRef: is-equal - params: - - name: left - value: "1" - - name: right - value: $(params.one) - - conditionRef: is-equal - params: - - name: left - value: "1" - - name: right - value: $(params.two) - taskRef: - kind: Task - name: run ---- -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: run -spec: - steps: - - name: echo - image: ubuntu - script: 'echo hello' ---- -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - name: condition-pipelinerun -spec: - params: - - name: one - value: "1" - - name: two - value: "2" - pipelineRef: - name: condition-pipeline diff --git a/examples/v1beta1/pipelineruns/conditional-pipelinerun.yaml b/examples/v1beta1/pipelineruns/conditional-pipelinerun.yaml deleted file mode 100644 index e0eb4098bc2..00000000000 --- a/examples/v1beta1/pipelineruns/conditional-pipelinerun.yaml +++ /dev/null @@ -1,98 +0,0 @@ -# `Conditions` are deprecated, use `when` expressions instead -# https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#guard-task-execution-using-when-expressions -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: file-exists -spec: - params: - - name: "path" - resources: - - name: workspace - type: git - check: - image: alpine - script: 'test -f $(resources.workspace.path)/$(params.path)' ---- -# `PipelineResources` are deprecated, consider using `Tasks` and other replacement features instead -# https://github.com/tektoncd/pipeline/blob/main/docs/migrating-v1alpha1-to-v1beta1.md#replacing-pipelineresources-with-tasks -apiVersion: tekton.dev/v1alpha1 -kind: PipelineResource -metadata: - name: pipeline-git -spec: - type: git - params: - - name: revision - value: main - - name: url - value: https://github.com/tektoncd/pipeline ---- -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: create-readme-file -spec: - resources: - outputs: - - name: workspace - type: git - steps: - - name: write-new-stuff - image: ubuntu - script: 'touch $(resources.outputs.workspace.path)/README.md' ---- -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: echo-hello -spec: - steps: - - name: echo - image: ubuntu - script: 'echo hello' ---- -apiVersion: tekton.dev/v1beta1 -kind: Pipeline -metadata: - name: conditional-pipeline -spec: - resources: - - name: source-repo - type: git - params: - - name: "path" - default: "README.md" - tasks: - - name: first-create-file - taskRef: - name: create-readme-file - resources: - outputs: - - name: workspace - resource: source-repo - - name: then-check - conditions: - - conditionRef: "file-exists" - params: - - name: "path" - value: "$(params.path)" - resources: - - name: workspace - resource: source-repo - from: [first-create-file] - taskRef: - name: echo-hello ---- -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - name: conditional-pr -spec: - pipelineRef: - name: conditional-pipeline - serviceAccountName: 'default' - resources: - - name: source-repo - resourceRef: - name: pipeline-git diff --git a/examples/v1beta1/pipelineruns/demo-optional-resources.yaml b/examples/v1beta1/pipelineruns/demo-optional-resources.yaml deleted file mode 100644 index 1cfe651d575..00000000000 --- a/examples/v1beta1/pipelineruns/demo-optional-resources.yaml +++ /dev/null @@ -1,131 +0,0 @@ -# `Conditions` are deprecated, use `when` expressions instead -# https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#guard-task-execution-using-when-expressions -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: check-git-pipeline-resource -spec: - params: - - name: "path" - resources: - - name: git-repo - type: git - optional: true - check: - image: alpine - script: 'test -f $(resources.git-repo.path)/$(params.path)' ---- -# `Conditions` are deprecated, use `when` expressions instead -# https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#guard-task-execution-using-when-expressions -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: check-image-pipeline-resource -spec: - resources: - - name: built-image - type: image - optional: true - check: - image: alpine - script: 'test ! -z $(resources.built-image.url)' ---- - -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: build-an-image -spec: - params: - - name: DOCKERFILE - description: The path to the dockerfile to build from GitHub Repo - default: "Dockerfile" - resources: - inputs: - - name: git-repo - type: git - optional: true - outputs: - - name: built-image - type: image - optional: true - steps: - - name: build-an-image - image: gcr.io/kaniko-project/executor:v1.3.0 - command: - - /kaniko/executor - args: - - --dockerfile=$(params.DOCKERFILE) - - --destination=$(resources.outputs.built-image.url) ---- - -apiVersion: tekton.dev/v1beta1 -kind: Pipeline -metadata: - name: demo-pipeline-to-build-an-image -spec: - resources: - - name: source-repo - type: git - optional: true - - name: web-image - type: image - optional: true - params: - - name: "path" - default: "README.md" - tasks: - - name: build-an-image - taskRef: - name: build-an-image - conditions: - - conditionRef: "check-git-pipeline-resource" - params: - - name: "path" - value: "$(params.path)" - resources: - - name: git-repo - resource: source-repo - - conditionRef: "check-image-pipeline-resource" - resources: - - name: built-image - resource: web-image - resources: - inputs: - - name: git-repo - resource: source-repo - outputs: - - name: built-image - resource: web-image - ---- - -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - name: demo-pipeline-to-build-an-image-without-resources -spec: - pipelineRef: - name: demo-pipeline-to-build-an-image - serviceAccountName: 'default' ---- -# `PipelineResources` are deprecated, consider using `Tasks` and other replacement features instead -# https://github.com/tektoncd/pipeline/blob/main/docs/migrating-v1alpha1-to-v1beta1.md#replacing-pipelineresources-with-tasks -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - name: demo-pipeline-to-build-an-image-without-image-resource -spec: - pipelineRef: - name: demo-pipeline-to-build-an-image - serviceAccountName: 'default' - resources: - - name: source-repo - resourceSpec: - type: git - params: - - name: revision - value: main - - name: url - value: https://github.com/tektoncd/pipeline ---- diff --git a/examples/v1beta1/pipelineruns/pipeline-result-conditions.yaml b/examples/v1beta1/pipelineruns/pipeline-result-conditions.yaml deleted file mode 100644 index 44fb2efc82f..00000000000 --- a/examples/v1beta1/pipelineruns/pipeline-result-conditions.yaml +++ /dev/null @@ -1,112 +0,0 @@ -# `Conditions` are deprecated, use `when` expressions instead -# https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#guard-task-execution-using-when-expressions -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: condition-1 -spec: - check: - args: - - EXITCODE=$(python -c "import sys; input1=str.rstrip(sys.argv[1]); input2=str.rstrip(sys.argv[2]); print(0) if (input1 == 'heads') else - print(1)" '$(params.flip-coin)' 'heads'); exit $EXITCODE - command: - - sh - - -c - image: python:alpine3.6 - params: - - name: flip-coin ---- -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: flip-coin -spec: - results: - - description: /tmp/output - name: output - steps: - - args: - - python -c "import random; result = 'heads' if random.randint(0,1) == 0 else - 'tails'; result='heads'; print(result)" | tee $(results.output.path) - command: - - sh - - -c - image: python:alpine3.6 - name: flip-coin ---- -apiVersion: tekton.dev/v1alpha1 -kind: Task -metadata: - name: condition-check -spec: - params: - - name: flip-coin - results: - - description: /tmp/output - name: output - steps: - - args: - - EXITCODE=$(python -c "import sys; input1=str.rstrip(sys.argv[1]); input2=str.rstrip(sys.argv[2]); print(input1) if (input1 == 'heads') else - print(input1)" '$(params.flip-coin)' 'heads'); echo $EXITCODE | tee $(results.output.path) - command: - - sh - - -c - image: python:alpine3.6 ---- -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: generate-random-number -spec: - results: - - description: /tmp/output - name: output - steps: - - args: - - python -c "import random; print(random.randint($0, $1))" | tee $2 - - '0' - - '9' - - $(results.output.path) - command: - - sh - - -c - image: python:alpine3.6 - name: generate-random-number ---- -apiVersion: tekton.dev/v1beta1 -kind: Pipeline -metadata: - annotations: - pipelines.kubeflow.org/pipeline_spec: '{"description": "Shows how to use dsl.Condition().", - "name": "Conditional execution pipeline"}' - name: flip-cond-gen-pipeline -spec: - params: [] - tasks: - - name: flip-coin - params: [] - taskRef: - name: flip-coin - - name: condition-check - params: - - name: flip-coin - value: $(tasks.flip-coin.results.output) - taskRef: - name: condition-check - - conditions: - - conditionRef: condition-1 - params: - - name: flip-coin - value: $(tasks.flip-coin.results.output) - name: generate-random-number - params: [] - taskRef: - name: generate-random-number ---- -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - name: flip-cond-gen-pipeline-run -spec: - pipelineRef: - name: flip-cond-gen-pipeline \ No newline at end of file diff --git a/examples/v1beta1/pipelineruns/pipelinerun-with-resourcespec.yaml b/examples/v1beta1/pipelineruns/pipelinerun-with-resourcespec.yaml index fbfbf19a9f3..0020987fde8 100644 --- a/examples/v1beta1/pipelineruns/pipelinerun-with-resourcespec.yaml +++ b/examples/v1beta1/pipelineruns/pipelinerun-with-resourcespec.yaml @@ -20,25 +20,6 @@ spec: - | ls -al $(resources.inputs.pipeline-git.path) --- -# `Conditions` are deprecated, use `when` expressions instead -# https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#guard-task-execution-using-when-expressions -apiVersion: tekton.dev/v1alpha1 -kind: Condition -metadata: - name: always-true-sample-condition -spec: - resources: - - name: pipeline-git - type: git - check: - image: ubuntu - command: - - bash - args: - - -c - - | - echo "Hello from Tekton Pipeline!" ---- apiVersion: tekton.dev/v1beta1 kind: Pipeline @@ -62,21 +43,6 @@ spec: outputs: - name: pipeline-git resource: pipeline-git - - name: conditional-list-files - taskRef: - name: task-to-list-files - conditions: - - conditionRef: always-true-sample-condition - resources: - - name: pipeline-git - resource: pipeline-git - resources: - inputs: - - name: pipeline-git - resource: pipeline-git - outputs: - - name: pipeline-git - resource: pipeline-git --- # `PipelineResources` are deprecated, consider using `Tasks` and other replacement features instead # https://github.com/tektoncd/pipeline/blob/main/docs/migrating-v1alpha1-to-v1beta1.md#replacing-pipelineresources-with-tasks diff --git a/pkg/apis/pipeline/register.go b/pkg/apis/pipeline/register.go index 97ee57fe8c8..50159ef4478 100644 --- a/pkg/apis/pipeline/register.go +++ b/pkg/apis/pipeline/register.go @@ -91,9 +91,4 @@ var ( Group: GroupName, Resource: "pipelineresources", } - // ConditionResource represents a Tekton Condition - ConditionResource = schema.GroupResource{ - Group: GroupName, - Resource: "conditions", - } ) diff --git a/pkg/apis/pipeline/v1alpha1/condition_defaults.go b/pkg/apis/pipeline/v1alpha1/condition_defaults.go deleted file mode 100644 index dcf7601d882..00000000000 --- a/pkg/apis/pipeline/v1alpha1/condition_defaults.go +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright 2019 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "context" - - "knative.dev/pkg/apis" -) - -var _ apis.Defaultable = (*Condition)(nil) - -// SetDefaults sets the Condition's Spec's default values. -func (c *Condition) SetDefaults(ctx context.Context) { - c.Spec.SetDefaults(ctx) -} - -// SetDefaults sets defaults for all params on the ConditionSpec. -func (cs *ConditionSpec) SetDefaults(ctx context.Context) { - for i := range cs.Params { - cs.Params[i].SetDefaults(ctx) - } -} diff --git a/pkg/apis/pipeline/v1alpha1/condition_defaults_test.go b/pkg/apis/pipeline/v1alpha1/condition_defaults_test.go deleted file mode 100644 index eac3b875fcf..00000000000 --- a/pkg/apis/pipeline/v1alpha1/condition_defaults_test.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -Copyright 2020 The Tetkon Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1_test - -import ( - "context" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "github.com/tektoncd/pipeline/test/diff" -) - -func TestConditionSpec_SetDefaults(t *testing.T) { - for _, tc := range []struct { - name string - input *v1alpha1.ConditionSpec - output *v1alpha1.ConditionSpec - }{{ - name: "No Param", - input: &v1alpha1.ConditionSpec{}, - output: &v1alpha1.ConditionSpec{}, - }, { - name: "One Param", - input: &v1alpha1.ConditionSpec{ - Params: []v1alpha1.ParamSpec{{ - Name: "test-1", - Default: &v1alpha1.ArrayOrString{ - Type: v1alpha1.ParamTypeArray, - ArrayVal: []string{"an", "array"}, - }, - }}, - }, - output: &v1alpha1.ConditionSpec{ - Params: []v1alpha1.ParamSpec{{ - Name: "test-1", - Type: v1alpha1.ParamTypeArray, - Default: &v1alpha1.ArrayOrString{ - Type: v1alpha1.ParamTypeArray, - ArrayVal: []string{"an", "array"}, - }, - }}, - }, - }, { - name: "Multiple Param", - input: &v1alpha1.ConditionSpec{ - Params: []v1alpha1.ParamSpec{{ - Name: "test-1", - Default: &v1alpha1.ArrayOrString{ - Type: v1alpha1.ParamTypeString, - StringVal: "string", - }, - }, { - Name: "test-2", - Default: &v1alpha1.ArrayOrString{ - Type: v1alpha1.ParamTypeArray, - ArrayVal: []string{"an", "array"}, - }, - }}, - }, - output: &v1alpha1.ConditionSpec{ - Params: []v1alpha1.ParamSpec{{ - Name: "test-1", - Type: v1alpha1.ParamTypeString, - Default: &v1alpha1.ArrayOrString{ - Type: v1alpha1.ParamTypeString, - StringVal: "string", - }, - }, { - Name: "test-2", - Type: v1alpha1.ParamTypeArray, - Default: &v1alpha1.ArrayOrString{ - Type: v1alpha1.ParamTypeArray, - ArrayVal: []string{"an", "array"}, - }, - }}, - }, - }} { - t.Run(tc.name, func(t *testing.T) { - ctx := context.Background() - tc.input.SetDefaults(ctx) - if d := cmp.Diff(tc.output, tc.input); d != "" { - t.Errorf("Mismatch of PipelineRunSpec: %s", diff.PrintWantGot(d)) - } - }) - } -} diff --git a/pkg/apis/pipeline/v1alpha1/condition_types.go b/pkg/apis/pipeline/v1alpha1/condition_types.go deleted file mode 100644 index ad4ab611d67..00000000000 --- a/pkg/apis/pipeline/v1alpha1/condition_types.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -Copyright 2019-2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" -) - -// +genclient -// +genclient:noStatus -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Condition declares a step that is used to gate the execution of a Task in a Pipeline. -// A condition execution (ConditionCheck) evaluates to either true or false -// +k8s:openapi-gen=true -type Condition struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata"` - - // Spec holds the desired state of the Condition from the client - // +optional - Spec ConditionSpec `json:"spec"` -} - -// ConditionCheckStatus defines the observed state of ConditionCheck -type ConditionCheckStatus = v1beta1.ConditionCheckStatus - -// ConditionCheckStatusFields holds the fields of ConfigurationCheck's status. -// This is defined separately and inlined so that other types can readily -// consume these fields via duck typing. -type ConditionCheckStatusFields = v1beta1.ConditionCheckStatusFields - -// ConditionSpec defines the desired state of the Condition -type ConditionSpec struct { - // Check declares container whose exit code determines where a condition is true or false - Check Step `json:"check,omitempty"` - - // Description is a user-facing description of the condition that may be - // used to populate a UI. - // +optional - Description string `json:"description,omitempty"` - - // Params is an optional set of parameters which must be supplied by the user when a Condition - // is evaluated - // +optional - Params []ParamSpec `json:"params,omitempty"` - - // Resources is a list of the ConditionResources required to run the condition. - // +optional - Resources []ResourceDeclaration `json:"resources,omitempty"` -} - -// ConditionCheck represents a single evaluation of a Condition step. -type ConditionCheck TaskRun - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ConditionList contains a list of Conditions -type ConditionList struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - Items []Condition `json:"items"` -} - -// NewConditionCheck creates a new ConditionCheck from a given TaskRun. -func NewConditionCheck(tr *TaskRun) *ConditionCheck { - if tr == nil { - return nil - } - - cc := ConditionCheck(*tr) - return &cc -} - -// IsDone returns true if the ConditionCheck's status indicates that it is done. -func (cc *ConditionCheck) IsDone() bool { - return !cc.Status.GetCondition(apis.ConditionSucceeded).IsUnknown() -} - -// IsSuccessful returns true if the ConditionCheck's status indicates that it is done. -func (cc *ConditionCheck) IsSuccessful() bool { - return cc.Status.GetCondition(apis.ConditionSucceeded).IsTrue() -} diff --git a/pkg/apis/pipeline/v1alpha1/condition_types_test.go b/pkg/apis/pipeline/v1alpha1/condition_types_test.go deleted file mode 100644 index 840a119aa01..00000000000 --- a/pkg/apis/pipeline/v1alpha1/condition_types_test.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright 2019 The Tekton Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package v1alpha1_test - -import ( - "testing" - - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - corev1 "k8s.io/api/core/v1" - "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -func TestConditionCheck_IsDone(t *testing.T) { - tr := &v1alpha1.TaskRun{ - Status: v1alpha1.TaskRunStatus{Status: duckv1beta1.Status{ - Conditions: []apis.Condition{{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionFalse, - }}, - }}, - } - - cc := v1alpha1.ConditionCheck(*tr) - if !cc.IsDone() { - t.Fatal("Expected conditionCheck status to be done") - } -} - -func TestConditionCheck_IsSuccessful(t *testing.T) { - tr := &v1alpha1.TaskRun{ - Status: v1alpha1.TaskRunStatus{Status: duckv1beta1.Status{ - Conditions: []apis.Condition{{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionTrue, - }}, - }}, - } - - cc := v1alpha1.ConditionCheck(*tr) - if !cc.IsSuccessful() { - t.Fatal("Expected conditionCheck status to be done") - } -} diff --git a/pkg/apis/pipeline/v1alpha1/condition_validation.go b/pkg/apis/pipeline/v1alpha1/condition_validation.go deleted file mode 100644 index daa8b75fc89..00000000000 --- a/pkg/apis/pipeline/v1alpha1/condition_validation.go +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright 2019 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "context" - "fmt" - - "github.com/tektoncd/pipeline/pkg/apis/validate" - "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/util/validation" - "knative.dev/pkg/apis" -) - -var _ apis.Validatable = (*Condition)(nil) - -// Validate performs validation on the Condition's metadata and spec -func (c Condition) Validate(ctx context.Context) *apis.FieldError { - if err := validate.ObjectMetadata(c.GetObjectMeta()); err != nil { - return err.ViaField("metadata") - } - if apis.IsInDelete(ctx) { - return nil - } - return c.Spec.Validate(ctx).ViaField("Spec") -} - -// Validate makes sure the ConditionSpec is actually configured and that its name is a valid DNS label, -// and finally validates its steps. -func (cs *ConditionSpec) Validate(ctx context.Context) *apis.FieldError { - if equality.Semantic.DeepEqual(cs, ConditionSpec{}) { - return apis.ErrMissingField(apis.CurrentField) - } - - // Validate condition check name - if errs := validation.IsDNS1123Label(cs.Check.Name); cs.Check.Name != "" && len(errs) > 0 { - return &apis.FieldError{ - Message: fmt.Sprintf("invalid value %q", cs.Check.Name), - Paths: []string{"Check.name"}, - Details: "Condition check name must be a valid DNS Label, For more info refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", - } - } - - return validateSteps([]Step{cs.Check}).ViaField("Check") -} diff --git a/pkg/apis/pipeline/v1alpha1/condition_validation_test.go b/pkg/apis/pipeline/v1alpha1/condition_validation_test.go deleted file mode 100644 index e5ada37a96e..00000000000 --- a/pkg/apis/pipeline/v1alpha1/condition_validation_test.go +++ /dev/null @@ -1,121 +0,0 @@ -/* -Copyright 2019 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1_test - -import ( - "context" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "github.com/tektoncd/pipeline/test/diff" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" -) - -func TestCondition_Validate(t *testing.T) { - c := v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{Name: "condname"}, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Name: "cname", - Image: "ubuntu", - }, - Params: []v1alpha1.ParamSpec{{ - Name: "paramname", - Type: v1alpha1.ParamTypeString, - }}, - }, - } - if err := c.Validate(context.Background()); err != nil { - t.Errorf("Condition.Validate() unexpected error = %v", err) - } -} - -func TestCondition_Invalid(t *testing.T) { - for _, tc := range []struct { - name string - cond *v1alpha1.Condition - expectedError apis.FieldError - }{{ - name: "invalid meta", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{Name: "invalid,name"}, - }, - expectedError: apis.FieldError{ - Message: `invalid resource name "invalid,name": must be a valid DNS label`, - Paths: []string{"metadata.name"}, - }, - }, { - name: "no image", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{Name: "condname"}, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Image: "", - }, - }, - }, - expectedError: apis.FieldError{ - Message: "missing field(s)", - Paths: []string{"Spec.Check.Image"}, - }, - }, { - name: "condition with script and command", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{Name: "condname"}, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Image: "image", - Command: []string{"exit", "0"}, - Script: "echo foo", - }, - }, - }, - expectedError: apis.FieldError{ - Message: "step 0 script cannot be used with command", - Paths: []string{"Spec.Check.script"}, - }, - }, { - name: "condition with invalid check name", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{Name: "condname"}, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Name: "Cname", - Image: "image", - }, - }, - }, - expectedError: apis.FieldError{ - Message: "invalid value \"Cname\"", - Paths: []string{"Spec.Check.name"}, - Details: "Condition check name must be a valid DNS Label, For more info refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", - }, - }} { - t.Run(tc.name, func(t *testing.T) { - err := tc.cond.Validate(context.Background()) - if err == nil { - t.Fatalf("Expected an Error, got nothing for %v", tc) - } - if d := cmp.Diff(tc.expectedError, *err, cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { - t.Errorf("Condition.Validate() errors diff %s", diff.PrintWantGot(d)) - } - }) - } -} diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go b/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go index 06b5e60a99e..b37d62a70b1 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go @@ -78,7 +78,6 @@ func (pt *PipelineTask) ConvertTo(ctx context.Context, sink *v1beta1.PipelineTas return err } } - sink.Conditions = pt.Conditions sink.Retries = pt.Retries sink.RunAfter = pt.RunAfter sink.Resources = pt.Resources @@ -129,7 +128,6 @@ func (pt *PipelineTask) ConvertFrom(ctx context.Context, source v1beta1.Pipeline return err } } - pt.Conditions = source.Conditions pt.Retries = source.Retries pt.RunAfter = source.RunAfter pt.Resources = source.Resources diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go b/pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go index 8f34514fc05..3adaa070b63 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go @@ -77,9 +77,6 @@ func TestPipelineConversion_Success(t *testing.T) { TaskRef: &TaskRef{ Name: "taskref", }, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "condition1", - }}, Retries: 10, RunAfter: []string{"task1"}, Resources: &PipelineTaskResources{ diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_types.go b/pkg/apis/pipeline/v1alpha1/pipeline_types.go index e02a19d8625..6067f2d971a 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_types.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_types.go @@ -121,10 +121,6 @@ type PipelineTask struct { // +optional TaskSpec *TaskSpec `json:"taskSpec,omitempty"` - // Conditions is a list of conditions that need to be true for the task to run - // +optional - Conditions []PipelineTaskCondition `json:"conditions,omitempty"` - // Retries represents how many times this task should be retried in case of task failure: ConditionSucceeded set to False // +optional Retries int `json:"retries,omitempty"` @@ -168,21 +164,6 @@ func (pt PipelineTask) Deps() []string { deps = append(deps, rd.From...) } } - // Add any dependents from conditional resources. - for _, cond := range pt.Conditions { - for _, rd := range cond.Resources { - deps = append(deps, rd.From...) - } - for _, param := range cond.Params { - expressions, ok := v1beta1.GetVarSubstitutionExpressionsForParam(param) - if ok { - resultRefs := v1beta1.NewResultRefs(expressions) - for _, resultRef := range resultRefs { - deps = append(deps, resultRef.PipelineTask) - } - } - } - } // Add any dependents from task results for _, param := range pt.Params { expressions, ok := v1beta1.GetVarSubstitutionExpressionsForParam(param) @@ -221,10 +202,6 @@ func (l PipelineTaskList) Deps() map[string][]string { // PipelineTaskParam is used to provide arbitrary string parameters to a Task. type PipelineTaskParam = v1beta1.PipelineTaskParam -// PipelineTaskCondition allows a PipelineTask to declare a Condition to be evaluated before -// the Task is run. -type PipelineTaskCondition = v1beta1.PipelineTaskCondition - // PipelineDeclaredResource is used by a Pipeline to declare the types of the // PipelineResources that it will required to run and names which can be used to // refer to these PipelineResources in PipelineTaskResourceBindings. diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_validation.go b/pkg/apis/pipeline/v1alpha1/pipeline_validation.go index 7492a4d0c2d..7d8f985b1ae 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_validation.go @@ -63,12 +63,6 @@ func validateDeclaredResources(ps *PipelineSpec) error { required = append(required, output.Resource) } } - - for _, condition := range t.Conditions { - for _, cr := range condition.Resources { - required = append(required, cr.Resource) - } - } } provided := make([]string, 0, len(ps.Resources)) @@ -110,10 +104,6 @@ func validateFrom(tasks []PipelineTask) *apis.FieldError { inputResources = append(inputResources, t.Resources.Inputs...) } - for _, c := range t.Conditions { - inputResources = append(inputResources, c.Resources...) - } - for _, rd := range inputResources { for _, pt := range rd.From { outputs, found := taskOutputs[pt] diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go b/pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go index 404a24600ed..4bebf96f8ed 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go @@ -254,12 +254,6 @@ func TestPipeline_Validate(t *testing.T) { Name: "wow-image", Resource: "wonderful-resource", From: []string{"bar"}, }}, }, - Conditions: []v1alpha1.PipelineTaskCondition{{ - ConditionRef: "some-condition-2", - Resources: []v1alpha1.PipelineTaskInputResource{{ - Name: "wow-image", Resource: "wonderful-resource", From: []string{"bar"}, - }}, - }}, }, { Name: "bar", TaskRef: &v1alpha1.TaskRef{Name: "bar-task"}, @@ -271,34 +265,6 @@ func TestPipeline_Validate(t *testing.T) { Name: "some-image", Resource: "wonderful-resource", }}, }, - Conditions: []v1alpha1.PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []v1alpha1.PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "great-resource", - }}, - }}, - }}, - }, - }, - failureExpected: false, - }, { - name: "valid condition only resource", - p: &v1alpha1.Pipeline{ - ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1alpha1.PipelineSpec{ - Resources: []v1alpha1.PipelineDeclaredResource{{ - Name: "great-resource", - Type: v1alpha1.PipelineResourceTypeGit, - }}, - Tasks: []v1alpha1.PipelineTask{{ - Name: "bar", - TaskRef: &v1alpha1.TaskRef{Name: "bar-task"}, - Conditions: []v1alpha1.PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []v1alpha1.PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "great-resource", - }}, - }}, }}, }, }, @@ -511,45 +477,6 @@ func TestPipeline_Validate(t *testing.T) { }, }, failureExpected: true, - }, { - name: "invalid condition only resource", - p: &v1alpha1.Pipeline{ - ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1alpha1.PipelineSpec{ - Tasks: []v1alpha1.PipelineTask{{ - Name: "bar", - TaskRef: &v1alpha1.TaskRef{Name: "bar-task"}, - Conditions: []v1alpha1.PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []v1alpha1.PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "missing-resource", - }}, - }}, - }}, - }, - }, - failureExpected: true, - }, { - name: "invalid from in condition", - p: &v1alpha1.Pipeline{ - ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1alpha1.PipelineSpec{ - Tasks: []v1alpha1.PipelineTask{{ - Name: "foo", - TaskRef: &v1alpha1.TaskRef{Name: "foo-task"}, - }, { - Name: "bar", - TaskRef: &v1alpha1.TaskRef{Name: "bar-task"}, - Conditions: []v1alpha1.PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []v1alpha1.PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "missing-resource", From: []string{"foo"}, - }}, - }}, - }}, - }, - }, - failureExpected: true, }, { name: "from resource isn't output by task", p: &v1alpha1.Pipeline{ diff --git a/pkg/apis/pipeline/v1alpha1/register.go b/pkg/apis/pipeline/v1alpha1/register.go index 78b59bfdce1..ca83ff92047 100644 --- a/pkg/apis/pipeline/v1alpha1/register.go +++ b/pkg/apis/pipeline/v1alpha1/register.go @@ -48,8 +48,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &Task{}, &TaskList{}, - &Condition{}, - &ConditionList{}, &ClusterTask{}, &ClusterTaskList{}, &TaskRun{}, diff --git a/pkg/apis/pipeline/v1alpha1/types_test.go b/pkg/apis/pipeline/v1alpha1/types_test.go index 85999a4e3b4..47693c13d28 100644 --- a/pkg/apis/pipeline/v1alpha1/types_test.go +++ b/pkg/apis/pipeline/v1alpha1/types_test.go @@ -30,5 +30,4 @@ func TestTypes(t *testing.T) { var _ resourcesemantics.GenericCRD = (*v1alpha1.PipelineResource)(nil) var _ resourcesemantics.GenericCRD = (*v1alpha1.Task)(nil) var _ resourcesemantics.GenericCRD = (*v1alpha1.TaskRun)(nil) - var _ resourcesemantics.GenericCRD = (*v1alpha1.Condition)(nil) } diff --git a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go index f537fa4b5b8..002c3e03167 100644 --- a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go @@ -24,7 +24,6 @@ package v1alpha1 import ( pod "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -89,115 +88,6 @@ func (in *ClusterTaskList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Condition) DeepCopyInto(out *Condition) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. -func (in *Condition) DeepCopy() *Condition { - if in == nil { - return nil - } - out := new(Condition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Condition) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConditionCheck) DeepCopyInto(out *ConditionCheck) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionCheck. -func (in *ConditionCheck) DeepCopy() *ConditionCheck { - if in == nil { - return nil - } - out := new(ConditionCheck) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConditionList) DeepCopyInto(out *ConditionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionList. -func (in *ConditionList) DeepCopy() *ConditionList { - if in == nil { - return nil - } - out := new(ConditionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ConditionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConditionSpec) DeepCopyInto(out *ConditionSpec) { - *out = *in - in.Check.DeepCopyInto(&out.Check) - if in.Params != nil { - in, out := &in.Params, &out.Params - *out = make([]v1beta1.ParamSpec, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = make([]resourcev1alpha1.ResourceDeclaration, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionSpec. -func (in *ConditionSpec) DeepCopy() *ConditionSpec { - if in == nil { - return nil - } - out := new(ConditionSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EmbeddedRunSpec) DeepCopyInto(out *EmbeddedRunSpec) { *out = *in @@ -540,13 +430,6 @@ func (in *PipelineTask) DeepCopyInto(out *PipelineTask) { *out = new(TaskSpec) (*in).DeepCopyInto(*out) } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1beta1.PipelineTaskCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } if in.RunAfter != nil { in, out := &in.RunAfter, &out.RunAfter *out = make([]string, len(*in)) diff --git a/pkg/apis/pipeline/v1beta1/condition_types.go b/pkg/apis/pipeline/v1beta1/condition_types.go deleted file mode 100644 index 6139a331226..00000000000 --- a/pkg/apis/pipeline/v1beta1/condition_types.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -// ConditionCheck represents a single evaluation of a Condition step. -type ConditionCheck TaskRun - -// NewConditionCheck creates a new ConditionCheck from a given TaskRun -func NewConditionCheck(tr *TaskRun) *ConditionCheck { - if tr == nil { - return nil - } - - cc := ConditionCheck(*tr) - return &cc -} - -// IsDone returns true if the ConditionCheck's status indicates that it is done. -func (cc *ConditionCheck) IsDone() bool { - return !cc.Status.GetCondition(apis.ConditionSucceeded).IsUnknown() -} - -// IsSuccessful returns true if the ConditionCheck's status indicates that it is done. -func (cc *ConditionCheck) IsSuccessful() bool { - return cc.Status.GetCondition(apis.ConditionSucceeded).IsTrue() -} - -// ConditionCheckStatus defines the observed state of ConditionCheck -type ConditionCheckStatus struct { - duckv1beta1.Status `json:",inline"` - - // ConditionCheckStatusFields inlines the status fields. - ConditionCheckStatusFields `json:",inline"` -} - -// ConditionCheckStatusFields holds the fields of ConfigurationCheck's status. -// This is defined separately and inlined so that other types can readily -// consume these fields via duck typing. -type ConditionCheckStatusFields struct { - // PodName is the name of the pod responsible for executing this condition check. - PodName string `json:"podName"` - - // StartTime is the time the check is actually started. - // +optional - StartTime *metav1.Time `json:"startTime,omitempty"` - - // CompletionTime is the time the check pod completed. - // +optional - CompletionTime *metav1.Time `json:"completionTime,omitempty"` - - // Check describes the state of the check container. - // +optional - Check corev1.ContainerState `json:"check,omitempty"` -} diff --git a/pkg/apis/pipeline/v1beta1/openapi_generated.go b/pkg/apis/pipeline/v1beta1/openapi_generated.go index b7ecf823187..d3592a4ba44 100644 --- a/pkg/apis/pipeline/v1beta1/openapi_generated.go +++ b/pkg/apis/pipeline/v1beta1/openapi_generated.go @@ -30,94 +30,88 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.AffinityAssistantTemplate": schema_pkg_apis_pipeline_pod_AffinityAssistantTemplate(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.Template": schema_pkg_apis_pipeline_pod_Template(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ArrayOrString": schema_pkg_apis_pipeline_v1beta1_ArrayOrString(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ChildStatusReference": schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDelivery": schema_pkg_apis_pipeline_v1beta1_CloudEventDelivery(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDeliveryState": schema_pkg_apis_pipeline_v1beta1_CloudEventDeliveryState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTask": schema_pkg_apis_pipeline_v1beta1_ClusterTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTaskList": schema_pkg_apis_pipeline_v1beta1_ClusterTaskList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ConditionCheck": schema_pkg_apis_pipeline_v1beta1_ConditionCheck(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ConditionCheckStatus": schema_pkg_apis_pipeline_v1beta1_ConditionCheckStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ConditionCheckStatusFields": schema_pkg_apis_pipeline_v1beta1_ConditionCheckStatusFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask": schema_pkg_apis_pipeline_v1beta1_EmbeddedTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.InternalTaskModifier": schema_pkg_apis_pipeline_v1beta1_InternalTaskModifier(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param": schema_pkg_apis_pipeline_v1beta1_Param(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamSpec": schema_pkg_apis_pipeline_v1beta1_ParamSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Pipeline": schema_pkg_apis_pipeline_v1beta1_Pipeline(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineDeclaredResource": schema_pkg_apis_pipeline_v1beta1_PipelineDeclaredResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineList": schema_pkg_apis_pipeline_v1beta1_PipelineList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRef": schema_pkg_apis_pipeline_v1beta1_PipelineRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceBinding": schema_pkg_apis_pipeline_v1beta1_PipelineResourceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceRef": schema_pkg_apis_pipeline_v1beta1_PipelineResourceRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceResult": schema_pkg_apis_pipeline_v1beta1_PipelineResourceResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResult": schema_pkg_apis_pipeline_v1beta1_PipelineResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRun": schema_pkg_apis_pipeline_v1beta1_PipelineRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunChildConditionCheckStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunChildConditionCheckStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunConditionCheckStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunConditionCheckStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunList": schema_pkg_apis_pipeline_v1beta1_PipelineRunList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunResult": schema_pkg_apis_pipeline_v1beta1_PipelineRunResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunSpecServiceAccountName": schema_pkg_apis_pipeline_v1beta1_PipelineRunSpecServiceAccountName(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatusFields": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatusFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunTaskRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunTaskRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineSpec": schema_pkg_apis_pipeline_v1beta1_PipelineSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTask": schema_pkg_apis_pipeline_v1beta1_PipelineTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskCondition": schema_pkg_apis_pipeline_v1beta1_PipelineTaskCondition(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskInputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskInputResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskMetadata": schema_pkg_apis_pipeline_v1beta1_PipelineTaskMetadata(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskOutputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskOutputResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskParam": schema_pkg_apis_pipeline_v1beta1_PipelineTaskParam(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskResources": schema_pkg_apis_pipeline_v1beta1_PipelineTaskResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRun": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineWorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_PipelineWorkspaceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PropertySpec": schema_pkg_apis_pipeline_v1beta1_PropertySpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverParam": schema_pkg_apis_pipeline_v1beta1_ResolverParam(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverRef": schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResultRef": schema_pkg_apis_pipeline_v1beta1_ResultRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Sidecar": schema_pkg_apis_pipeline_v1beta1_Sidecar(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SidecarState": schema_pkg_apis_pipeline_v1beta1_SidecarState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SkippedTask": schema_pkg_apis_pipeline_v1beta1_SkippedTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Step": schema_pkg_apis_pipeline_v1beta1_Step(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepState": schema_pkg_apis_pipeline_v1beta1_StepState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepTemplate": schema_pkg_apis_pipeline_v1beta1_StepTemplate(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Task": schema_pkg_apis_pipeline_v1beta1_Task(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskList": schema_pkg_apis_pipeline_v1beta1_TaskList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRef": schema_pkg_apis_pipeline_v1beta1_TaskRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResource": schema_pkg_apis_pipeline_v1beta1_TaskResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResourceBinding": schema_pkg_apis_pipeline_v1beta1_TaskResourceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResources": schema_pkg_apis_pipeline_v1beta1_TaskResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResult": schema_pkg_apis_pipeline_v1beta1_TaskResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRun": schema_pkg_apis_pipeline_v1beta1_TaskRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunDebug": schema_pkg_apis_pipeline_v1beta1_TaskRunDebug(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunInputs": schema_pkg_apis_pipeline_v1beta1_TaskRunInputs(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunList": schema_pkg_apis_pipeline_v1beta1_TaskRunList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunOutputs": schema_pkg_apis_pipeline_v1beta1_TaskRunOutputs(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResources": schema_pkg_apis_pipeline_v1beta1_TaskRunResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResult": schema_pkg_apis_pipeline_v1beta1_TaskRunResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSidecarOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunSidecarOverride(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSpec": schema_pkg_apis_pipeline_v1beta1_TaskRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus": schema_pkg_apis_pipeline_v1beta1_TaskRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatusFields": schema_pkg_apis_pipeline_v1beta1_TaskRunStatusFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStepOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunStepOverride(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskSpec": schema_pkg_apis_pipeline_v1beta1_TaskSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TimeoutFields": schema_pkg_apis_pipeline_v1beta1_TimeoutFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression": schema_pkg_apis_pipeline_v1beta1_WhenExpression(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceBinding": schema_pkg_apis_pipeline_v1beta1_WorkspaceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_WorkspaceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding": schema_pkg_apis_pipeline_v1beta1_WorkspacePipelineTaskBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage": schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResource": schema_pkg_apis_resource_v1alpha1_PipelineResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceList": schema_pkg_apis_resource_v1alpha1_PipelineResourceList(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceSpec": schema_pkg_apis_resource_v1alpha1_PipelineResourceSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceStatus": schema_pkg_apis_resource_v1alpha1_PipelineResourceStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceDeclaration": schema_pkg_apis_resource_v1alpha1_ResourceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceParam": schema_pkg_apis_resource_v1alpha1_ResourceParam(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.SecretParam": schema_pkg_apis_resource_v1alpha1_SecretParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.AffinityAssistantTemplate": schema_pkg_apis_pipeline_pod_AffinityAssistantTemplate(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.Template": schema_pkg_apis_pipeline_pod_Template(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ArrayOrString": schema_pkg_apis_pipeline_v1beta1_ArrayOrString(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ChildStatusReference": schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDelivery": schema_pkg_apis_pipeline_v1beta1_CloudEventDelivery(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDeliveryState": schema_pkg_apis_pipeline_v1beta1_CloudEventDeliveryState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTask": schema_pkg_apis_pipeline_v1beta1_ClusterTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTaskList": schema_pkg_apis_pipeline_v1beta1_ClusterTaskList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask": schema_pkg_apis_pipeline_v1beta1_EmbeddedTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.InternalTaskModifier": schema_pkg_apis_pipeline_v1beta1_InternalTaskModifier(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param": schema_pkg_apis_pipeline_v1beta1_Param(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamSpec": schema_pkg_apis_pipeline_v1beta1_ParamSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Pipeline": schema_pkg_apis_pipeline_v1beta1_Pipeline(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineDeclaredResource": schema_pkg_apis_pipeline_v1beta1_PipelineDeclaredResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineList": schema_pkg_apis_pipeline_v1beta1_PipelineList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRef": schema_pkg_apis_pipeline_v1beta1_PipelineRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceBinding": schema_pkg_apis_pipeline_v1beta1_PipelineResourceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceRef": schema_pkg_apis_pipeline_v1beta1_PipelineResourceRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceResult": schema_pkg_apis_pipeline_v1beta1_PipelineResourceResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResult": schema_pkg_apis_pipeline_v1beta1_PipelineResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRun": schema_pkg_apis_pipeline_v1beta1_PipelineRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunList": schema_pkg_apis_pipeline_v1beta1_PipelineRunList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunResult": schema_pkg_apis_pipeline_v1beta1_PipelineRunResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunSpecServiceAccountName": schema_pkg_apis_pipeline_v1beta1_PipelineRunSpecServiceAccountName(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatusFields": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatusFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunTaskRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunTaskRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineSpec": schema_pkg_apis_pipeline_v1beta1_PipelineSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTask": schema_pkg_apis_pipeline_v1beta1_PipelineTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskInputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskInputResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskMetadata": schema_pkg_apis_pipeline_v1beta1_PipelineTaskMetadata(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskOutputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskOutputResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskParam": schema_pkg_apis_pipeline_v1beta1_PipelineTaskParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskResources": schema_pkg_apis_pipeline_v1beta1_PipelineTaskResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRun": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineWorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_PipelineWorkspaceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PropertySpec": schema_pkg_apis_pipeline_v1beta1_PropertySpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverParam": schema_pkg_apis_pipeline_v1beta1_ResolverParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverRef": schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResultRef": schema_pkg_apis_pipeline_v1beta1_ResultRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Sidecar": schema_pkg_apis_pipeline_v1beta1_Sidecar(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SidecarState": schema_pkg_apis_pipeline_v1beta1_SidecarState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SkippedTask": schema_pkg_apis_pipeline_v1beta1_SkippedTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Step": schema_pkg_apis_pipeline_v1beta1_Step(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepState": schema_pkg_apis_pipeline_v1beta1_StepState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepTemplate": schema_pkg_apis_pipeline_v1beta1_StepTemplate(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Task": schema_pkg_apis_pipeline_v1beta1_Task(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskList": schema_pkg_apis_pipeline_v1beta1_TaskList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRef": schema_pkg_apis_pipeline_v1beta1_TaskRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResource": schema_pkg_apis_pipeline_v1beta1_TaskResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResourceBinding": schema_pkg_apis_pipeline_v1beta1_TaskResourceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResources": schema_pkg_apis_pipeline_v1beta1_TaskResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResult": schema_pkg_apis_pipeline_v1beta1_TaskResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRun": schema_pkg_apis_pipeline_v1beta1_TaskRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunDebug": schema_pkg_apis_pipeline_v1beta1_TaskRunDebug(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunInputs": schema_pkg_apis_pipeline_v1beta1_TaskRunInputs(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunList": schema_pkg_apis_pipeline_v1beta1_TaskRunList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunOutputs": schema_pkg_apis_pipeline_v1beta1_TaskRunOutputs(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResources": schema_pkg_apis_pipeline_v1beta1_TaskRunResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResult": schema_pkg_apis_pipeline_v1beta1_TaskRunResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSidecarOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunSidecarOverride(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSpec": schema_pkg_apis_pipeline_v1beta1_TaskRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus": schema_pkg_apis_pipeline_v1beta1_TaskRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatusFields": schema_pkg_apis_pipeline_v1beta1_TaskRunStatusFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStepOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunStepOverride(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskSpec": schema_pkg_apis_pipeline_v1beta1_TaskSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TimeoutFields": schema_pkg_apis_pipeline_v1beta1_TimeoutFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression": schema_pkg_apis_pipeline_v1beta1_WhenExpression(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceBinding": schema_pkg_apis_pipeline_v1beta1_WorkspaceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_WorkspaceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding": schema_pkg_apis_pipeline_v1beta1_WorkspacePipelineTaskBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage": schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResource": schema_pkg_apis_resource_v1alpha1_PipelineResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceList": schema_pkg_apis_resource_v1alpha1_PipelineResourceList(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceSpec": schema_pkg_apis_resource_v1alpha1_PipelineResourceSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceStatus": schema_pkg_apis_resource_v1alpha1_PipelineResourceStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceDeclaration": schema_pkg_apis_resource_v1alpha1_ResourceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceParam": schema_pkg_apis_resource_v1alpha1_ResourceParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.SecretParam": schema_pkg_apis_resource_v1alpha1_SecretParam(ref), } } @@ -462,24 +456,6 @@ func schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref common.ReferenceC Format: "", }, }, - "conditionChecks": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "ConditionChecks is the the list of condition checks, including their names and statuses, for the PipelineTask. Deprecated: This field will be removed when conditions are removed.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunChildConditionCheckStatus"), - }, - }, - }, - }, - }, "whenExpressions": { VendorExtensible: spec.VendorExtensible{ Extensions: spec.Extensions{ @@ -503,7 +479,7 @@ func schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref common.ReferenceC }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunChildConditionCheckStatus", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression"}, + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression"}, } } @@ -671,182 +647,6 @@ func schema_pkg_apis_pipeline_v1beta1_ClusterTaskList(ref common.ReferenceCallba } } -func schema_pkg_apis_pipeline_v1beta1_ConditionCheck(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ConditionCheck represents a single evaluation of a Condition step.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), - }, - }, - "spec": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSpec"), - }, - }, - "status": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSpec", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, - } -} - -func schema_pkg_apis_pipeline_v1beta1_ConditionCheckStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ConditionCheckStatus defines the observed state of ConditionCheck", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "observedGeneration": { - SchemaProps: spec.SchemaProps{ - Description: "ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.", - Type: []string{"integer"}, - Format: "int64", - }, - }, - "conditions": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-patch-merge-key": "type", - "x-kubernetes-patch-strategy": "merge", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Conditions the latest available observations of a resource's current state.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("knative.dev/pkg/apis.Condition"), - }, - }, - }, - }, - }, - "annotations": { - SchemaProps: spec.SchemaProps{ - Description: "Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards.", - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - "podName": { - SchemaProps: spec.SchemaProps{ - Description: "PodName is the name of the pod responsible for executing this condition check.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "startTime": { - SchemaProps: spec.SchemaProps{ - Description: "StartTime is the time the check is actually started.", - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), - }, - }, - "completionTime": { - SchemaProps: spec.SchemaProps{ - Description: "CompletionTime is the time the check pod completed.", - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), - }, - }, - "check": { - SchemaProps: spec.SchemaProps{ - Description: "Check describes the state of the check container.", - Default: map[string]interface{}{}, - Ref: ref("k8s.io/api/core/v1.ContainerState"), - }, - }, - }, - Required: []string{"podName"}, - }, - }, - Dependencies: []string{ - "k8s.io/api/core/v1.ContainerState", "k8s.io/apimachinery/pkg/apis/meta/v1.Time", "knative.dev/pkg/apis.Condition"}, - } -} - -func schema_pkg_apis_pipeline_v1beta1_ConditionCheckStatusFields(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ConditionCheckStatusFields holds the fields of ConfigurationCheck's status. This is defined separately and inlined so that other types can readily consume these fields via duck typing.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "podName": { - SchemaProps: spec.SchemaProps{ - Description: "PodName is the name of the pod responsible for executing this condition check.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "startTime": { - SchemaProps: spec.SchemaProps{ - Description: "StartTime is the time the check is actually started.", - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), - }, - }, - "completionTime": { - SchemaProps: spec.SchemaProps{ - Description: "CompletionTime is the time the check pod completed.", - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), - }, - }, - "check": { - SchemaProps: spec.SchemaProps{ - Description: "Check describes the state of the check container.", - Default: map[string]interface{}{}, - Ref: ref("k8s.io/api/core/v1.ContainerState"), - }, - }, - }, - Required: []string{"podName"}, - }, - }, - Dependencies: []string{ - "k8s.io/api/core/v1.ContainerState", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, - } -} - func schema_pkg_apis_pipeline_v1beta1_EmbeddedTask(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1534,68 +1334,6 @@ func schema_pkg_apis_pipeline_v1beta1_PipelineRun(ref common.ReferenceCallback) } } -func schema_pkg_apis_pipeline_v1beta1_PipelineRunChildConditionCheckStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "PipelineRunChildConditionCheckStatus is used to record the status of condition checks within StatusChildReferences.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "conditionName": { - SchemaProps: spec.SchemaProps{ - Description: "ConditionName is the name of the Condition", - Type: []string{"string"}, - Format: "", - }, - }, - "status": { - SchemaProps: spec.SchemaProps{ - Description: "Status is the ConditionCheckStatus for the corresponding ConditionCheck", - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ConditionCheckStatus"), - }, - }, - "conditionCheckName": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ConditionCheckStatus"}, - } -} - -func schema_pkg_apis_pipeline_v1beta1_PipelineRunConditionCheckStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "PipelineRunConditionCheckStatus returns the condition check status", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "conditionName": { - SchemaProps: spec.SchemaProps{ - Description: "ConditionName is the name of the Condition", - Type: []string{"string"}, - Format: "", - }, - }, - "status": { - SchemaProps: spec.SchemaProps{ - Description: "Status is the ConditionCheckStatus for the corresponding ConditionCheck", - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ConditionCheckStatus"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ConditionCheckStatus"}, - } -} - func schema_pkg_apis_pipeline_v1beta1_PipelineRunList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -2196,20 +1934,6 @@ func schema_pkg_apis_pipeline_v1beta1_PipelineRunTaskRunStatus(ref common.Refere Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus"), }, }, - "conditionChecks": { - SchemaProps: spec.SchemaProps{ - Description: "ConditionChecks maps the name of a condition check to its Status", - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunConditionCheckStatus"), - }, - }, - }, - }, - }, "whenExpressions": { VendorExtensible: spec.VendorExtensible{ Extensions: spec.Extensions{ @@ -2233,7 +1957,7 @@ func schema_pkg_apis_pipeline_v1beta1_PipelineRunTaskRunStatus(ref common.Refere }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunConditionCheckStatus", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression"}, + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression"}, } } @@ -2399,25 +2123,6 @@ func schema_pkg_apis_pipeline_v1beta1_PipelineTask(ref common.ReferenceCallback) Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask"), }, }, - "conditions": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Conditions is a list of conditions that need to be true for the task to run Conditions are deprecated, use WhenExpressions instead", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskCondition"), - }, - }, - }, - }, - }, "when": { SchemaProps: spec.SchemaProps{ Description: "WhenExpressions is a list of when expressions that need to be true for the task to run", @@ -2532,69 +2237,7 @@ func schema_pkg_apis_pipeline_v1beta1_PipelineTask(ref common.ReferenceCallback) }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskCondition", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskResources", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRef", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration"}, - } -} - -func schema_pkg_apis_pipeline_v1beta1_PipelineTaskCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "PipelineTaskCondition allows a PipelineTask to declare a Condition to be evaluated before the Task is run.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "conditionRef": { - SchemaProps: spec.SchemaProps{ - Description: "ConditionRef is the name of the Condition to use for the conditionCheck", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "params": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Params declare parameters passed to this Condition", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param"), - }, - }, - }, - }, - }, - "resources": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Resources declare the resources provided to this Condition as input", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskInputResource"), - }, - }, - }, - }, - }, - }, - Required: []string{"conditionRef"}, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskInputResource"}, + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskResources", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRef", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration"}, } } diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types.go b/pkg/apis/pipeline/v1beta1/pipeline_types.go index ea31ef6ae37..0b6d4d76763 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types.go @@ -172,12 +172,6 @@ type PipelineTask struct { // +optional TaskSpec *EmbeddedTask `json:"taskSpec,omitempty"` - // Conditions is a list of conditions that need to be true for the task to run - // Conditions are deprecated, use WhenExpressions instead - // +optional - // +listType=atomic - Conditions []PipelineTaskCondition `json:"conditions,omitempty"` - // WhenExpressions is a list of when expressions that need to be true for the task to run // +optional WhenExpressions WhenExpressions `json:"when,omitempty"` @@ -248,11 +242,6 @@ func (pt PipelineTask) validateCustomTask() (errs *apis.FieldError) { errs = errs.Also(apis.ErrInvalidValue("custom task spec must specify apiVersion", "taskSpec.apiVersion")) } - // Conditions are deprecated so the effort to support them with custom tasks is not justified. - // When expressions should be used instead. - if len(pt.Conditions) > 0 { - errs = errs.Also(apis.ErrInvalidValue("custom tasks do not support conditions - use when expressions instead", "conditions")) - } // TODO(#3133): Support these features if possible. if pt.Resources != nil { errs = errs.Also(apis.ErrInvalidValue("custom tasks do not support PipelineResources", "resources")) @@ -493,13 +482,6 @@ func (pt PipelineTask) resourceDeps() []string { } } - // Add any dependents from conditional resources. - for _, cond := range pt.Conditions { - for _, rd := range cond.Resources { - resourceDeps = append(resourceDeps, rd.From...) - } - } - // Add any dependents from result references. for _, ref := range PipelineTaskResultRefs(&pt) { resourceDeps = append(resourceDeps, ref.PipelineTask) @@ -573,22 +555,6 @@ type PipelineTaskParam struct { Value string `json:"value"` } -// PipelineTaskCondition allows a PipelineTask to declare a Condition to be evaluated before -// the Task is run. -type PipelineTaskCondition struct { - // ConditionRef is the name of the Condition to use for the conditionCheck - ConditionRef string `json:"conditionRef"` - - // Params declare parameters passed to this Condition - // +optional - // +listType=atomic - Params []Param `json:"params,omitempty"` - - // Resources declare the resources provided to this Condition as input - // +listType=atomic - Resources []PipelineTaskInputResource `json:"resources,omitempty"` -} - // PipelineDeclaredResource is used by a Pipeline to declare the types of the // PipelineResources that it will required to run and names which can be used to // refer to these PipelineResources in PipelineTaskResourceBindings. diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types_test.go b/pkg/apis/pipeline/v1beta1/pipeline_types_test.go index 711b1f75bb9..6b4489b7210 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types_test.go @@ -170,19 +170,6 @@ func TestPipelineTask_ValidateCustomTask(t *testing.T) { Message: `invalid value: custom task ref must specify apiVersion`, Paths: []string{"taskRef.apiVersion"}, }, - }, { - name: "custom task doesn't support conditions", - task: PipelineTask{ - Name: "foo", - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - }}, - TaskRef: &TaskRef{APIVersion: "example.dev/v0", Kind: "Example"}, - }, - expectedError: apis.FieldError{ - Message: `invalid value: custom tasks do not support conditions - use when expressions instead`, - Paths: []string{"conditions"}, - }, }, { name: "custom task doesn't support pipeline resources", task: PipelineTask{ diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation.go b/pkg/apis/pipeline/v1beta1/pipeline_validation.go index 6f171a8f57d..880fc008c90 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation.go @@ -279,9 +279,6 @@ func validateFinalTasks(tasks []PipelineTask, finalTasks []PipelineTask) (errs * if len(f.RunAfter) != 0 { errs = errs.Also(apis.ErrInvalidValue(fmt.Sprintf("no runAfter allowed under spec.finally, final task %s has runAfter specified", f.Name), "").ViaFieldIndex("finally", idx)) } - if len(f.Conditions) != 0 { - errs = errs.Also(apis.ErrInvalidValue(fmt.Sprintf("no conditions allowed under spec.finally, final task %s has conditions specified", f.Name), "").ViaFieldIndex("finally", idx)) - } } ts := PipelineTaskList(tasks).Names() @@ -346,7 +343,6 @@ func validateTasksInputFrom(tasks []PipelineTask) (errs *apis.FieldError) { func validateWhenExpressions(tasks []PipelineTask, finalTasks []PipelineTask) (errs *apis.FieldError) { for i, t := range tasks { - errs = errs.Also(validateOneOfWhenExpressionsOrConditions(t).ViaFieldIndex("tasks", i)) errs = errs.Also(t.WhenExpressions.validate().ViaFieldIndex("tasks", i)) } for i, t := range finalTasks { @@ -355,13 +351,6 @@ func validateWhenExpressions(tasks []PipelineTask, finalTasks []PipelineTask) (e return errs } -func validateOneOfWhenExpressionsOrConditions(t PipelineTask) *apis.FieldError { - if t.WhenExpressions != nil && t.Conditions != nil { - return apis.ErrMultipleOneOf("when", "conditions") - } - return nil -} - // validateDeclaredResources ensures that the specified resources have unique names and // validates that all the resources referenced by pipeline tasks are declared in the pipeline func validateDeclaredResources(resources []PipelineDeclaredResource, tasks []PipelineTask, finalTasks []PipelineTask) *apis.FieldError { @@ -383,11 +372,6 @@ func validateDeclaredResources(resources []PipelineDeclaredResource, tasks []Pip } } - for _, condition := range t.Conditions { - for _, cr := range condition.Resources { - required = append(required, cr.Resource) - } - } } for _, t := range finalTasks { if t.Resources != nil { @@ -438,10 +422,6 @@ func validateFrom(tasks []PipelineTask) (errs *apis.FieldError) { inputResources = append(inputResources, t.Resources.Inputs...) } - for _, c := range t.Conditions { - inputResources = append(inputResources, c.Resources...) - } - for j, rd := range inputResources { for _, pt := range rd.From { outputs, found := taskOutputs[pt] diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go index cf4ab411e84..3893ae45a86 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go @@ -233,27 +233,6 @@ func TestPipelineSpec_Validate_Failure(t *testing.T) { Message: `expected exactly one, got both`, Paths: []string{"tasks[1].taskRef", "tasks[1].taskSpec"}, }, - }, { - name: "invalid pipeline with one pipeline task having both conditions and when expressions", - ps: &PipelineSpec{ - Description: "this is an invalid pipeline with invalid pipeline task", - Tasks: []PipelineTask{{ - Name: "invalid-pipeline-task", - TaskRef: &TaskRef{Name: "foo-task"}, - WhenExpressions: []WhenExpression{{ - Input: "foo", - Operator: selection.In, - Values: []string{"bar"}, - }}, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - }}, - }}, - }, - expectedError: apis.FieldError{ - Message: `expected exactly one, got both`, - Paths: []string{"tasks[0].conditions", "tasks[0].when"}, - }, }, { name: "invalid pipeline with one pipeline task having when expression with invalid operator (not In/NotIn)", ps: &PipelineSpec{ @@ -669,12 +648,6 @@ func TestPipelineSpec_Validate_Failure(t *testing.T) { Name: "some-imagee", Resource: "missing-wonderful-resource", }}, }, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "missing-great-resource", - }}, - }}, }, { Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}, @@ -683,16 +656,10 @@ func TestPipelineSpec_Validate_Failure(t *testing.T) { Name: "some-image", Resource: "wonderful-resource", }}, }, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition-2", - Resources: []PipelineTaskInputResource{{ - Name: "some-image", Resource: "wonderful-resource", - }}, - }}, }}, }, expectedError: apis.FieldError{ - Message: `invalid value: pipeline declared resources didn't match usage in Tasks: Didn't provide required values: [missing-great-resource missing-wonderful-resource missing-great-resource]`, + Message: `invalid value: pipeline declared resources didn't match usage in Tasks: Didn't provide required values: [missing-great-resource missing-wonderful-resource]`, Paths: []string{"resources"}, }, }, { @@ -841,24 +808,6 @@ func TestValidateFrom_Failure(t *testing.T) { Message: `invalid value: expected resource great-resource to be from task bar, but task bar doesn't exist`, Paths: []string{"tasks[1].resources.inputs[0].from"}, }, - }, { - name: "invalid pipeline task - pipeline task condition resource does not exist", - tasks: []PipelineTask{{ - Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}, - }, { - Name: "bar", - TaskRef: &TaskRef{Name: "bar-task"}, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "missing-resource", From: []string{"foo"}, - }}, - }}, - }}, - expectedError: apis.FieldError{ - Message: `invalid value: the resource missing-resource from foo must be an output but is an input`, - Paths: []string{"tasks[1].resources.inputs[0].from"}, - }, }, { name: "invalid pipeline task - from resource referring to a pipeline task which has no output", tasks: []PipelineTask{{ @@ -945,12 +894,6 @@ func TestValidateDeclaredResources_Success(t *testing.T) { Name: "some-imagee", Resource: "wonderful-resource", }}, }, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "great-resource", - }}, - }}, }, { Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}, @@ -959,27 +902,6 @@ func TestValidateDeclaredResources_Success(t *testing.T) { Name: "some-image", Resource: "wonderful-resource", From: []string{"bar"}, }}, }, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition-2", - Resources: []PipelineTaskInputResource{{ - Name: "some-image", Resource: "wonderful-resource", From: []string{"bar"}, - }}, - }}, - }}, - }, { - name: "valid resource declaration with single reference in the pipeline task condition", - resources: []PipelineDeclaredResource{{ - Name: "great-resource", Type: PipelineResourceTypeGit, - }}, - tasks: []PipelineTask{{ - Name: "bar", - TaskRef: &TaskRef{Name: "bar-task"}, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "great-resource", - }}, - }}, }}, }, { name: "valid resource declarations with extra resources, not used in any pipeline task", @@ -1083,23 +1005,6 @@ func TestValidateDeclaredResources_Failure(t *testing.T) { Message: `invalid value: pipeline declared resources didn't match usage in Tasks: Didn't provide required values: [missing-resource]`, Paths: []string{"resources"}, }, - }, { - name: "invalid condition only resource -" + - " pipeline task condition referring to a resource which is missing from resource declarations", - tasks: []PipelineTask{{ - Name: "bar", - TaskRef: &TaskRef{Name: "bar-task"}, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "missing-resource", - }}, - }}, - }}, - expectedError: apis.FieldError{ - Message: `invalid value: pipeline declared resources didn't match usage in Tasks: Didn't provide required values: [missing-resource]`, - Paths: []string{"resources"}, - }, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -1881,12 +1786,6 @@ func TestValidatePipelineWithFinalTasks_Success(t *testing.T) { Name: "some-image", Resource: "wonderful-resource", }}, }, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []PipelineTaskInputResource{{ - Name: "some-workspace", Resource: "great-resource", - }}, - }}, }}, Finally: []PipelineTask{{ Name: "foo", @@ -2113,7 +2012,7 @@ func TestValidatePipelineWithFinalTasks_Failure(t *testing.T) { Paths: []string{"spec.finally[0].params[final-param]"}, }, }, { - name: "invalid pipeline with invalid final tasks with runAfter and conditions", + name: "invalid pipeline with invalid final tasks with runAfter", p: &Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, Spec: PipelineSpec{ @@ -2125,21 +2024,12 @@ func TestValidatePipelineWithFinalTasks_Failure(t *testing.T) { Name: "final-task-1", TaskRef: &TaskRef{Name: "final-task"}, RunAfter: []string{"non-final-task"}, - }, { - Name: "final-task-2", - TaskRef: &TaskRef{Name: "final-task"}, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - }}, }}, }, }, expectedError: *apis.ErrGeneric("").Also(&apis.FieldError{ Message: `invalid value: no runAfter allowed under spec.finally, final task final-task-1 has runAfter specified`, Paths: []string{"spec.finally[0]"}, - }).Also(&apis.FieldError{ - Message: `invalid value: no conditions allowed under spec.finally, final task final-task-2 has conditions specified`, - Paths: []string{"spec.finally[1]"}, }), }, { name: "invalid pipeline - workspace bindings in final task relying on a non-existent pipeline workspace", @@ -2281,19 +2171,6 @@ func TestValidateFinalTasks_Failure(t *testing.T) { Message: `invalid value: no runAfter allowed under spec.finally, final task final-task has runAfter specified`, Paths: []string{"finally[0]"}, }, - }, { - name: "invalid pipeline with final task specifying conditions", - finalTasks: []PipelineTask{{ - Name: "final-task", - TaskRef: &TaskRef{Name: "final-task"}, - Conditions: []PipelineTaskCondition{{ - ConditionRef: "some-condition", - }}, - }}, - expectedError: apis.FieldError{ - Message: `invalid value: no conditions allowed under spec.finally, final task final-task has conditions specified`, - Paths: []string{"finally[0]"}, - }, }, { name: "invalid pipeline with final task output resources referring to other task input", finalTasks: []PipelineTask{{ diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_types.go b/pkg/apis/pipeline/v1beta1/pipelinerun_types.go index 562a9299faf..01686eb88bb 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_types.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_types.go @@ -410,32 +410,12 @@ type ChildStatusReference struct { // PipelineTaskName is the name of the PipelineTask this is referencing. PipelineTaskName string `json:"pipelineTaskName,omitempty"` - // ConditionChecks is the the list of condition checks, including their names and statuses, for the PipelineTask. - // Deprecated: This field will be removed when conditions are removed. - // +optional - // +listType=atomic - ConditionChecks []*PipelineRunChildConditionCheckStatus `json:"conditionChecks,omitempty"` // WhenExpressions is the list of checks guarding the execution of the PipelineTask // +optional // +listType=atomic WhenExpressions []WhenExpression `json:"whenExpressions,omitempty"` } -// GetConditionChecks returns a map representation of this ChildStatusReference's ConditionChecks, in the same form -// as PipelineRunTaskRunStatus.ConditionChecks. -func (cr ChildStatusReference) GetConditionChecks() map[string]*PipelineRunConditionCheckStatus { - if len(cr.ConditionChecks) == 0 { - return nil - } - ccMap := make(map[string]*PipelineRunConditionCheckStatus) - - for _, cc := range cr.ConditionChecks { - ccMap[cc.ConditionCheckName] = &cc.PipelineRunConditionCheckStatus - } - - return ccMap -} - // PipelineRunStatusFields holds the fields of PipelineRunStatus' status. // This is defined separately and inlined so that other types can readily // consume these fields via duck typing. @@ -497,8 +477,6 @@ type SkippingReason string const ( // WhenExpressionsSkip means the task was skipped due to at least one of its when expressions evaluating to false WhenExpressionsSkip SkippingReason = "When Expressions evaluated to false" - // ConditionsSkip means the task was skipped due to at least one of its conditions failing - ConditionsSkip SkippingReason = "Conditions failed" // ParentTasksSkip means the task was skipped because its parent was skipped ParentTasksSkip SkippingReason = "Parent Tasks were skipped" // StoppingSkip means the task was skipped because the pipeline run is stopping @@ -529,9 +507,6 @@ type PipelineRunTaskRunStatus struct { // Status is the TaskRunStatus for the corresponding TaskRun // +optional Status *TaskRunStatus `json:"status,omitempty"` - // ConditionChecks maps the name of a condition check to its Status - // +optional - ConditionChecks map[string]*PipelineRunConditionCheckStatus `json:"conditionChecks,omitempty"` // WhenExpressions is the list of checks guarding the execution of the PipelineTask // +optional // +listType=atomic @@ -551,21 +526,6 @@ type PipelineRunRunStatus struct { WhenExpressions []WhenExpression `json:"whenExpressions,omitempty"` } -// PipelineRunConditionCheckStatus returns the condition check status -type PipelineRunConditionCheckStatus struct { - // ConditionName is the name of the Condition - ConditionName string `json:"conditionName,omitempty"` - // Status is the ConditionCheckStatus for the corresponding ConditionCheck - // +optional - Status *ConditionCheckStatus `json:"status,omitempty"` -} - -// PipelineRunChildConditionCheckStatus is used to record the status of condition checks within StatusChildReferences. -type PipelineRunChildConditionCheckStatus struct { - PipelineRunConditionCheckStatus `json:",inline"` - ConditionCheckName string `json:"conditionCheckName,omitempty"` -} - // PipelineRunSpecServiceAccountName can be used to configure specific // ServiceAccountName for a concrete Task type PipelineRunSpecServiceAccountName struct { diff --git a/pkg/apis/pipeline/v1beta1/resultref.go b/pkg/apis/pipeline/v1beta1/resultref.go index d74e2bcd38f..c0cf2bdc0fc 100644 --- a/pkg/apis/pipeline/v1beta1/resultref.go +++ b/pkg/apis/pipeline/v1beta1/resultref.go @@ -134,13 +134,6 @@ func parseExpression(substitutionExpression string) (string, string, error) { // in a PipelineTask and returns a list of any references that are found. func PipelineTaskResultRefs(pt *PipelineTask) []*ResultRef { refs := []*ResultRef{} - for _, condition := range pt.Conditions { - for _, p := range condition.Params { - expressions, _ := GetVarSubstitutionExpressionsForParam(p) - refs = append(refs, NewResultRefs(expressions)...) - } - } - for _, p := range pt.Params { expressions, _ := GetVarSubstitutionExpressionsForParam(p) refs = append(refs, NewResultRefs(expressions)...) diff --git a/pkg/apis/pipeline/v1beta1/resultref_test.go b/pkg/apis/pipeline/v1beta1/resultref_test.go index 37015ad5be6..64e408d6d7a 100644 --- a/pkg/apis/pipeline/v1beta1/resultref_test.go +++ b/pkg/apis/pipeline/v1beta1/resultref_test.go @@ -559,13 +559,9 @@ func TestLooksLikeResultRefWhenExpressionFalse(t *testing.T) { // returns them all in the expected order. func TestPipelineTaskResultRefs(t *testing.T) { pt := v1beta1.PipelineTask{ - Conditions: []v1beta1.PipelineTaskCondition{{ - Params: []v1beta1.Param{{ - Name: "foo", - Value: *v1beta1.NewArrayOrString("$(tasks.pt1.results.r1)"), - }}, - }}, Params: []v1beta1.Param{{ + Value: *v1beta1.NewArrayOrString("$(tasks.pt1.results.r1)"), + }, { Value: *v1beta1.NewArrayOrString("$(tasks.pt2.results.r2)"), }}, WhenExpressions: []v1beta1.WhenExpression{{ diff --git a/pkg/apis/pipeline/v1beta1/swagger.json b/pkg/apis/pipeline/v1beta1/swagger.json index 6e7d2c66b2d..37eb2c459f6 100644 --- a/pkg/apis/pipeline/v1beta1/swagger.json +++ b/pkg/apis/pipeline/v1beta1/swagger.json @@ -341,14 +341,6 @@ "apiVersion": { "type": "string" }, - "conditionChecks": { - "description": "ConditionChecks is the the list of condition checks, including their names and statuses, for the PipelineTask. Deprecated: This field will be removed when conditions are removed.", - "type": "array", - "items": { - "$ref": "#/definitions/v1beta1.PipelineRunChildConditionCheckStatus" - }, - "x-kubernetes-list-type": "atomic" - }, "kind": { "type": "string" }, @@ -465,109 +457,6 @@ } } }, - "v1beta1.ConditionCheck": { - "description": "ConditionCheck represents a single evaluation of a Condition step.", - "type": "object", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {}, - "$ref": "#/definitions/v1.ObjectMeta" - }, - "spec": { - "default": {}, - "$ref": "#/definitions/v1beta1.TaskRunSpec" - }, - "status": { - "default": {}, - "$ref": "#/definitions/v1beta1.TaskRunStatus" - } - } - }, - "v1beta1.ConditionCheckStatus": { - "description": "ConditionCheckStatus defines the observed state of ConditionCheck", - "type": "object", - "required": [ - "podName" - ], - "properties": { - "annotations": { - "description": "Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards.", - "type": "object", - "additionalProperties": { - "type": "string", - "default": "" - } - }, - "check": { - "description": "Check describes the state of the check container.", - "default": {}, - "$ref": "#/definitions/v1.ContainerState" - }, - "completionTime": { - "description": "CompletionTime is the time the check pod completed.", - "$ref": "#/definitions/v1.Time" - }, - "conditions": { - "description": "Conditions the latest available observations of a resource's current state.", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/knative.Condition" - }, - "x-kubernetes-patch-merge-key": "type", - "x-kubernetes-patch-strategy": "merge" - }, - "observedGeneration": { - "description": "ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.", - "type": "integer", - "format": "int64" - }, - "podName": { - "description": "PodName is the name of the pod responsible for executing this condition check.", - "type": "string", - "default": "" - }, - "startTime": { - "description": "StartTime is the time the check is actually started.", - "$ref": "#/definitions/v1.Time" - } - } - }, - "v1beta1.ConditionCheckStatusFields": { - "description": "ConditionCheckStatusFields holds the fields of ConfigurationCheck's status. This is defined separately and inlined so that other types can readily consume these fields via duck typing.", - "type": "object", - "required": [ - "podName" - ], - "properties": { - "check": { - "description": "Check describes the state of the check container.", - "default": {}, - "$ref": "#/definitions/v1.ContainerState" - }, - "completionTime": { - "description": "CompletionTime is the time the check pod completed.", - "$ref": "#/definitions/v1.Time" - }, - "podName": { - "description": "PodName is the name of the pod responsible for executing this condition check.", - "type": "string", - "default": "" - }, - "startTime": { - "description": "StartTime is the time the check is actually started.", - "$ref": "#/definitions/v1.Time" - } - } - }, "v1beta1.EmbeddedTask": { "description": "EmbeddedTask is used to define a Task inline within a Pipeline's PipelineTasks.", "type": "object", @@ -947,37 +836,6 @@ } } }, - "v1beta1.PipelineRunChildConditionCheckStatus": { - "description": "PipelineRunChildConditionCheckStatus is used to record the status of condition checks within StatusChildReferences.", - "type": "object", - "properties": { - "conditionCheckName": { - "type": "string" - }, - "conditionName": { - "description": "ConditionName is the name of the Condition", - "type": "string" - }, - "status": { - "description": "Status is the ConditionCheckStatus for the corresponding ConditionCheck", - "$ref": "#/definitions/v1beta1.ConditionCheckStatus" - } - } - }, - "v1beta1.PipelineRunConditionCheckStatus": { - "description": "PipelineRunConditionCheckStatus returns the condition check status", - "type": "object", - "properties": { - "conditionName": { - "description": "ConditionName is the name of the Condition", - "type": "string" - }, - "status": { - "description": "Status is the ConditionCheckStatus for the corresponding ConditionCheck", - "$ref": "#/definitions/v1beta1.ConditionCheckStatus" - } - } - }, "v1beta1.PipelineRunList": { "description": "PipelineRunList contains a list of PipelineRun", "type": "object", @@ -1279,13 +1137,6 @@ "description": "PipelineRunTaskRunStatus contains the name of the PipelineTask for this TaskRun and the TaskRun's Status", "type": "object", "properties": { - "conditionChecks": { - "description": "ConditionChecks maps the name of a condition check to its Status", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/v1beta1.PipelineRunConditionCheckStatus" - } - }, "pipelineTaskName": { "description": "PipelineTaskName is the name of the PipelineTask.", "type": "string" @@ -1373,15 +1224,6 @@ "description": "PipelineTask defines a task in a Pipeline, passing inputs from both Params and from the output of previous tasks.", "type": "object", "properties": { - "conditions": { - "description": "Conditions is a list of conditions that need to be true for the task to run Conditions are deprecated, use WhenExpressions instead", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1beta1.PipelineTaskCondition" - }, - "x-kubernetes-list-type": "atomic" - }, "matrix": { "description": "Matrix declares parameters used to fan out this task.", "type": "array", @@ -1453,38 +1295,6 @@ } } }, - "v1beta1.PipelineTaskCondition": { - "description": "PipelineTaskCondition allows a PipelineTask to declare a Condition to be evaluated before the Task is run.", - "type": "object", - "required": [ - "conditionRef" - ], - "properties": { - "conditionRef": { - "description": "ConditionRef is the name of the Condition to use for the conditionCheck", - "type": "string", - "default": "" - }, - "params": { - "description": "Params declare parameters passed to this Condition", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1beta1.Param" - }, - "x-kubernetes-list-type": "atomic" - }, - "resources": { - "description": "Resources declare the resources provided to this Condition as input", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1beta1.PipelineTaskInputResource" - }, - "x-kubernetes-list-type": "atomic" - } - } - }, "v1beta1.PipelineTaskInputResource": { "description": "PipelineTaskInputResource maps the name of a declared PipelineResource input dependency in a Task to the resource in the Pipeline's DeclaredPipelineResources that should be used. This input may come from a previous task.", "type": "object", diff --git a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go index 6b52281b7c6..b24a077dabf 100644 --- a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go @@ -62,17 +62,6 @@ func (in *ArrayOrString) DeepCopy() *ArrayOrString { func (in *ChildStatusReference) DeepCopyInto(out *ChildStatusReference) { *out = *in out.TypeMeta = in.TypeMeta - if in.ConditionChecks != nil { - in, out := &in.ConditionChecks, &out.ConditionChecks - *out = make([]*PipelineRunChildConditionCheckStatus, len(*in)) - for i := range *in { - if (*in)[i] != nil { - in, out := &(*in)[i], &(*out)[i] - *out = new(PipelineRunChildConditionCheckStatus) - (*in).DeepCopyInto(*out) - } - } - } if in.WhenExpressions != nil { in, out := &in.WhenExpressions, &out.WhenExpressions *out = make([]WhenExpression, len(*in)) @@ -190,69 +179,6 @@ func (in *ClusterTaskList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConditionCheck) DeepCopyInto(out *ConditionCheck) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionCheck. -func (in *ConditionCheck) DeepCopy() *ConditionCheck { - if in == nil { - return nil - } - out := new(ConditionCheck) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConditionCheckStatus) DeepCopyInto(out *ConditionCheckStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - in.ConditionCheckStatusFields.DeepCopyInto(&out.ConditionCheckStatusFields) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionCheckStatus. -func (in *ConditionCheckStatus) DeepCopy() *ConditionCheckStatus { - if in == nil { - return nil - } - out := new(ConditionCheckStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConditionCheckStatusFields) DeepCopyInto(out *ConditionCheckStatusFields) { - *out = *in - if in.StartTime != nil { - in, out := &in.StartTime, &out.StartTime - *out = (*in).DeepCopy() - } - if in.CompletionTime != nil { - in, out := &in.CompletionTime, &out.CompletionTime - *out = (*in).DeepCopy() - } - in.Check.DeepCopyInto(&out.Check) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionCheckStatusFields. -func (in *ConditionCheckStatusFields) DeepCopy() *ConditionCheckStatusFields { - if in == nil { - return nil - } - out := new(ConditionCheckStatusFields) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EmbeddedTask) DeepCopyInto(out *EmbeddedTask) { *out = *in @@ -555,44 +481,6 @@ func (in *PipelineRun) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PipelineRunChildConditionCheckStatus) DeepCopyInto(out *PipelineRunChildConditionCheckStatus) { - *out = *in - in.PipelineRunConditionCheckStatus.DeepCopyInto(&out.PipelineRunConditionCheckStatus) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineRunChildConditionCheckStatus. -func (in *PipelineRunChildConditionCheckStatus) DeepCopy() *PipelineRunChildConditionCheckStatus { - if in == nil { - return nil - } - out := new(PipelineRunChildConditionCheckStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PipelineRunConditionCheckStatus) DeepCopyInto(out *PipelineRunConditionCheckStatus) { - *out = *in - if in.Status != nil { - in, out := &in.Status, &out.Status - *out = new(ConditionCheckStatus) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineRunConditionCheckStatus. -func (in *PipelineRunConditionCheckStatus) DeepCopy() *PipelineRunConditionCheckStatus { - if in == nil { - return nil - } - out := new(PipelineRunConditionCheckStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PipelineRunList) DeepCopyInto(out *PipelineRunList) { *out = *in @@ -864,21 +752,6 @@ func (in *PipelineRunTaskRunStatus) DeepCopyInto(out *PipelineRunTaskRunStatus) *out = new(TaskRunStatus) (*in).DeepCopyInto(*out) } - if in.ConditionChecks != nil { - in, out := &in.ConditionChecks, &out.ConditionChecks - *out = make(map[string]*PipelineRunConditionCheckStatus, len(*in)) - for key, val := range *in { - var outVal *PipelineRunConditionCheckStatus - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = new(PipelineRunConditionCheckStatus) - (*in).DeepCopyInto(*out) - } - (*out)[key] = outVal - } - } if in.WhenExpressions != nil { in, out := &in.WhenExpressions, &out.WhenExpressions *out = make([]WhenExpression, len(*in)) @@ -964,13 +837,6 @@ func (in *PipelineTask) DeepCopyInto(out *PipelineTask) { *out = new(EmbeddedTask) (*in).DeepCopyInto(*out) } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]PipelineTaskCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } if in.WhenExpressions != nil { in, out := &in.WhenExpressions, &out.WhenExpressions *out = make(WhenExpressions, len(*in)) @@ -1025,36 +891,6 @@ func (in *PipelineTask) DeepCopy() *PipelineTask { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PipelineTaskCondition) DeepCopyInto(out *PipelineTaskCondition) { - *out = *in - if in.Params != nil { - in, out := &in.Params, &out.Params - *out = make([]Param, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = make([]PipelineTaskInputResource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineTaskCondition. -func (in *PipelineTaskCondition) DeepCopy() *PipelineTaskCondition { - if in == nil { - return nil - } - out := new(PipelineTaskCondition) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PipelineTaskInputResource) DeepCopyInto(out *PipelineTaskInputResource) { *out = *in diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/condition.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/condition.go deleted file mode 100644 index ab26eea6eb9..00000000000 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/condition.go +++ /dev/null @@ -1,178 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - scheme "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ConditionsGetter has a method to return a ConditionInterface. -// A group's client should implement this interface. -type ConditionsGetter interface { - Conditions(namespace string) ConditionInterface -} - -// ConditionInterface has methods to work with Condition resources. -type ConditionInterface interface { - Create(ctx context.Context, condition *v1alpha1.Condition, opts v1.CreateOptions) (*v1alpha1.Condition, error) - Update(ctx context.Context, condition *v1alpha1.Condition, opts v1.UpdateOptions) (*v1alpha1.Condition, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Condition, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ConditionList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Condition, err error) - ConditionExpansion -} - -// conditions implements ConditionInterface -type conditions struct { - client rest.Interface - ns string -} - -// newConditions returns a Conditions -func newConditions(c *TektonV1alpha1Client, namespace string) *conditions { - return &conditions{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the condition, and returns the corresponding condition object, and an error if there is any. -func (c *conditions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Condition, err error) { - result = &v1alpha1.Condition{} - err = c.client.Get(). - Namespace(c.ns). - Resource("conditions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Conditions that match those selectors. -func (c *conditions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ConditionList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ConditionList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("conditions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested conditions. -func (c *conditions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("conditions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a condition and creates it. Returns the server's representation of the condition, and an error, if there is any. -func (c *conditions) Create(ctx context.Context, condition *v1alpha1.Condition, opts v1.CreateOptions) (result *v1alpha1.Condition, err error) { - result = &v1alpha1.Condition{} - err = c.client.Post(). - Namespace(c.ns). - Resource("conditions"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(condition). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a condition and updates it. Returns the server's representation of the condition, and an error, if there is any. -func (c *conditions) Update(ctx context.Context, condition *v1alpha1.Condition, opts v1.UpdateOptions) (result *v1alpha1.Condition, err error) { - result = &v1alpha1.Condition{} - err = c.client.Put(). - Namespace(c.ns). - Resource("conditions"). - Name(condition.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(condition). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the condition and deletes it. Returns an error if one occurs. -func (c *conditions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("conditions"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *conditions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("conditions"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched condition. -func (c *conditions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Condition, err error) { - result = &v1alpha1.Condition{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("conditions"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_condition.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_condition.go deleted file mode 100644 index b3f1cd683e6..00000000000 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_condition.go +++ /dev/null @@ -1,130 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeConditions implements ConditionInterface -type FakeConditions struct { - Fake *FakeTektonV1alpha1 - ns string -} - -var conditionsResource = schema.GroupVersionResource{Group: "tekton.dev", Version: "v1alpha1", Resource: "conditions"} - -var conditionsKind = schema.GroupVersionKind{Group: "tekton.dev", Version: "v1alpha1", Kind: "Condition"} - -// Get takes name of the condition, and returns the corresponding condition object, and an error if there is any. -func (c *FakeConditions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Condition, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(conditionsResource, c.ns, name), &v1alpha1.Condition{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Condition), err -} - -// List takes label and field selectors, and returns the list of Conditions that match those selectors. -func (c *FakeConditions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ConditionList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(conditionsResource, conditionsKind, c.ns, opts), &v1alpha1.ConditionList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.ConditionList{ListMeta: obj.(*v1alpha1.ConditionList).ListMeta} - for _, item := range obj.(*v1alpha1.ConditionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested conditions. -func (c *FakeConditions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(conditionsResource, c.ns, opts)) - -} - -// Create takes the representation of a condition and creates it. Returns the server's representation of the condition, and an error, if there is any. -func (c *FakeConditions) Create(ctx context.Context, condition *v1alpha1.Condition, opts v1.CreateOptions) (result *v1alpha1.Condition, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(conditionsResource, c.ns, condition), &v1alpha1.Condition{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Condition), err -} - -// Update takes the representation of a condition and updates it. Returns the server's representation of the condition, and an error, if there is any. -func (c *FakeConditions) Update(ctx context.Context, condition *v1alpha1.Condition, opts v1.UpdateOptions) (result *v1alpha1.Condition, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(conditionsResource, c.ns, condition), &v1alpha1.Condition{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Condition), err -} - -// Delete takes name of the condition and deletes it. Returns an error if one occurs. -func (c *FakeConditions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(conditionsResource, c.ns, name, opts), &v1alpha1.Condition{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeConditions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(conditionsResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.ConditionList{}) - return err -} - -// Patch applies the patch and returns the patched condition. -func (c *FakeConditions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Condition, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(conditionsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Condition{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Condition), err -} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go index f04cb586314..72bad222bd1 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go @@ -32,10 +32,6 @@ func (c *FakeTektonV1alpha1) ClusterTasks() v1alpha1.ClusterTaskInterface { return &FakeClusterTasks{c} } -func (c *FakeTektonV1alpha1) Conditions(namespace string) v1alpha1.ConditionInterface { - return &FakeConditions{c, namespace} -} - func (c *FakeTektonV1alpha1) Pipelines(namespace string) v1alpha1.PipelineInterface { return &FakePipelines{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go index 6942df0f45e..58b8994efd7 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go @@ -20,8 +20,6 @@ package v1alpha1 type ClusterTaskExpansion interface{} -type ConditionExpansion interface{} - type PipelineExpansion interface{} type PipelineRunExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go index d81e4c674b2..3392e3a95db 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go @@ -29,7 +29,6 @@ import ( type TektonV1alpha1Interface interface { RESTClient() rest.Interface ClusterTasksGetter - ConditionsGetter PipelinesGetter PipelineRunsGetter RunsGetter @@ -46,10 +45,6 @@ func (c *TektonV1alpha1Client) ClusterTasks() ClusterTaskInterface { return newClusterTasks(c) } -func (c *TektonV1alpha1Client) Conditions(namespace string) ConditionInterface { - return newConditions(c, namespace) -} - func (c *TektonV1alpha1Client) Pipelines(namespace string) PipelineInterface { return newPipelines(c, namespace) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 3d05774d1c5..a5efe0759fc 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -56,8 +56,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=tekton.dev, Version=v1alpha1 case v1alpha1.SchemeGroupVersion.WithResource("clustertasks"): return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1alpha1().ClusterTasks().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("conditions"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1alpha1().Conditions().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("pipelines"): return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1alpha1().Pipelines().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("pipelineruns"): diff --git a/pkg/client/informers/externalversions/pipeline/v1alpha1/condition.go b/pkg/client/informers/externalversions/pipeline/v1alpha1/condition.go deleted file mode 100644 index 5ee887d5f49..00000000000 --- a/pkg/client/informers/externalversions/pipeline/v1alpha1/condition.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - time "time" - - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - versioned "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - internalinterfaces "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// ConditionInformer provides access to a shared informer and lister for -// Conditions. -type ConditionInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.ConditionLister -} - -type conditionInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewConditionInformer constructs a new informer for Condition type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewConditionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredConditionInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredConditionInformer constructs a new informer for Condition type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredConditionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.TektonV1alpha1().Conditions(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.TektonV1alpha1().Conditions(namespace).Watch(context.TODO(), options) - }, - }, - &pipelinev1alpha1.Condition{}, - resyncPeriod, - indexers, - ) -} - -func (f *conditionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredConditionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *conditionInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&pipelinev1alpha1.Condition{}, f.defaultInformer) -} - -func (f *conditionInformer) Lister() v1alpha1.ConditionLister { - return v1alpha1.NewConditionLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/externalversions/pipeline/v1alpha1/interface.go b/pkg/client/informers/externalversions/pipeline/v1alpha1/interface.go index 5b9882c30d7..4fdb40457e8 100644 --- a/pkg/client/informers/externalversions/pipeline/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/pipeline/v1alpha1/interface.go @@ -26,8 +26,6 @@ import ( type Interface interface { // ClusterTasks returns a ClusterTaskInformer. ClusterTasks() ClusterTaskInformer - // Conditions returns a ConditionInformer. - Conditions() ConditionInformer // Pipelines returns a PipelineInformer. Pipelines() PipelineInformer // PipelineRuns returns a PipelineRunInformer. @@ -56,11 +54,6 @@ func (v *version) ClusterTasks() ClusterTaskInformer { return &clusterTaskInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Conditions returns a ConditionInformer. -func (v *version) Conditions() ConditionInformer { - return &conditionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - // Pipelines returns a PipelineInformer. func (v *version) Pipelines() PipelineInformer { return &pipelineInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/injection/client/client.go b/pkg/client/injection/client/client.go index 748c1e36e19..949065abe3f 100644 --- a/pkg/client/injection/client/client.go +++ b/pkg/client/injection/client/client.go @@ -240,137 +240,6 @@ func (w *wrapTektonV1alpha1ClusterTaskImpl) Watch(ctx context.Context, opts v1.L return nil, errors.New("NYI: Watch") } -func (w *wrapTektonV1alpha1) Conditions(namespace string) typedtektonv1alpha1.ConditionInterface { - return &wrapTektonV1alpha1ConditionImpl{ - dyn: w.dyn.Resource(schema.GroupVersionResource{ - Group: "tekton.dev", - Version: "v1alpha1", - Resource: "conditions", - }), - - namespace: namespace, - } -} - -type wrapTektonV1alpha1ConditionImpl struct { - dyn dynamic.NamespaceableResourceInterface - - namespace string -} - -var _ typedtektonv1alpha1.ConditionInterface = (*wrapTektonV1alpha1ConditionImpl)(nil) - -func (w *wrapTektonV1alpha1ConditionImpl) Create(ctx context.Context, in *v1alpha1.Condition, opts v1.CreateOptions) (*v1alpha1.Condition, error) { - in.SetGroupVersionKind(schema.GroupVersionKind{ - Group: "tekton.dev", - Version: "v1alpha1", - Kind: "Condition", - }) - uo := &unstructured.Unstructured{} - if err := convert(in, uo); err != nil { - return nil, err - } - uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts) - if err != nil { - return nil, err - } - out := &v1alpha1.Condition{} - if err := convert(uo, out); err != nil { - return nil, err - } - return out, nil -} - -func (w *wrapTektonV1alpha1ConditionImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts) -} - -func (w *wrapTektonV1alpha1ConditionImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts) -} - -func (w *wrapTektonV1alpha1ConditionImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Condition, error) { - uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts) - if err != nil { - return nil, err - } - out := &v1alpha1.Condition{} - if err := convert(uo, out); err != nil { - return nil, err - } - return out, nil -} - -func (w *wrapTektonV1alpha1ConditionImpl) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ConditionList, error) { - uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts) - if err != nil { - return nil, err - } - out := &v1alpha1.ConditionList{} - if err := convert(uo, out); err != nil { - return nil, err - } - return out, nil -} - -func (w *wrapTektonV1alpha1ConditionImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Condition, err error) { - uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts) - if err != nil { - return nil, err - } - out := &v1alpha1.Condition{} - if err := convert(uo, out); err != nil { - return nil, err - } - return out, nil -} - -func (w *wrapTektonV1alpha1ConditionImpl) Update(ctx context.Context, in *v1alpha1.Condition, opts v1.UpdateOptions) (*v1alpha1.Condition, error) { - in.SetGroupVersionKind(schema.GroupVersionKind{ - Group: "tekton.dev", - Version: "v1alpha1", - Kind: "Condition", - }) - uo := &unstructured.Unstructured{} - if err := convert(in, uo); err != nil { - return nil, err - } - uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts) - if err != nil { - return nil, err - } - out := &v1alpha1.Condition{} - if err := convert(uo, out); err != nil { - return nil, err - } - return out, nil -} - -func (w *wrapTektonV1alpha1ConditionImpl) UpdateStatus(ctx context.Context, in *v1alpha1.Condition, opts v1.UpdateOptions) (*v1alpha1.Condition, error) { - in.SetGroupVersionKind(schema.GroupVersionKind{ - Group: "tekton.dev", - Version: "v1alpha1", - Kind: "Condition", - }) - uo := &unstructured.Unstructured{} - if err := convert(in, uo); err != nil { - return nil, err - } - uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts) - if err != nil { - return nil, err - } - out := &v1alpha1.Condition{} - if err := convert(uo, out); err != nil { - return nil, err - } - return out, nil -} - -func (w *wrapTektonV1alpha1ConditionImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return nil, errors.New("NYI: Watch") -} - func (w *wrapTektonV1alpha1) Pipelines(namespace string) typedtektonv1alpha1.PipelineInterface { return &wrapTektonV1alpha1PipelineImpl{ dyn: w.dyn.Resource(schema.GroupVersionResource{ diff --git a/pkg/client/injection/informers/pipeline/v1alpha1/condition/condition.go b/pkg/client/injection/informers/pipeline/v1alpha1/condition/condition.go deleted file mode 100644 index 582d2c5e1de..00000000000 --- a/pkg/client/injection/informers/pipeline/v1alpha1/condition/condition.go +++ /dev/null @@ -1,116 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package condition - -import ( - context "context" - - apispipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - versioned "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - v1alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" - client "github.com/tektoncd/pipeline/pkg/client/injection/client" - factory "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - cache "k8s.io/client-go/tools/cache" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterInformer(withInformer) - injection.Dynamic.RegisterDynamicInformer(withDynamicInformer) -} - -// Key is used for associating the Informer inside the context.Context. -type Key struct{} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := factory.Get(ctx) - inf := f.Tekton().V1alpha1().Conditions() - return context.WithValue(ctx, Key{}, inf), inf.Informer() -} - -func withDynamicInformer(ctx context.Context) context.Context { - inf := &wrapper{client: client.Get(ctx), resourceVersion: injection.GetResourceVersion(ctx)} - return context.WithValue(ctx, Key{}, inf) -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context) v1alpha1.ConditionInformer { - untyped := ctx.Value(Key{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1.ConditionInformer from context.") - } - return untyped.(v1alpha1.ConditionInformer) -} - -type wrapper struct { - client versioned.Interface - - namespace string - - resourceVersion string -} - -var _ v1alpha1.ConditionInformer = (*wrapper)(nil) -var _ pipelinev1alpha1.ConditionLister = (*wrapper)(nil) - -func (w *wrapper) Informer() cache.SharedIndexInformer { - return cache.NewSharedIndexInformer(nil, &apispipelinev1alpha1.Condition{}, 0, nil) -} - -func (w *wrapper) Lister() pipelinev1alpha1.ConditionLister { - return w -} - -func (w *wrapper) Conditions(namespace string) pipelinev1alpha1.ConditionNamespaceLister { - return &wrapper{client: w.client, namespace: namespace, resourceVersion: w.resourceVersion} -} - -// SetResourceVersion allows consumers to adjust the minimum resourceVersion -// used by the underlying client. It is not accessible via the standard -// lister interface, but can be accessed through a user-defined interface and -// an implementation check e.g. rvs, ok := foo.(ResourceVersionSetter) -func (w *wrapper) SetResourceVersion(resourceVersion string) { - w.resourceVersion = resourceVersion -} - -func (w *wrapper) List(selector labels.Selector) (ret []*apispipelinev1alpha1.Condition, err error) { - lo, err := w.client.TektonV1alpha1().Conditions(w.namespace).List(context.TODO(), v1.ListOptions{ - LabelSelector: selector.String(), - ResourceVersion: w.resourceVersion, - }) - if err != nil { - return nil, err - } - for idx := range lo.Items { - ret = append(ret, &lo.Items[idx]) - } - return ret, nil -} - -func (w *wrapper) Get(name string) (*apispipelinev1alpha1.Condition, error) { - return w.client.TektonV1alpha1().Conditions(w.namespace).Get(context.TODO(), name, v1.GetOptions{ - ResourceVersion: w.resourceVersion, - }) -} diff --git a/pkg/client/injection/informers/pipeline/v1alpha1/condition/fake/fake.go b/pkg/client/injection/informers/pipeline/v1alpha1/condition/fake/fake.go deleted file mode 100644 index 097cfa63b09..00000000000 --- a/pkg/client/injection/informers/pipeline/v1alpha1/condition/fake/fake.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package fake - -import ( - context "context" - - fake "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory/fake" - condition "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/condition" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" -) - -var Get = condition.Get - -func init() { - injection.Fake.RegisterInformer(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := fake.Get(ctx) - inf := f.Tekton().V1alpha1().Conditions() - return context.WithValue(ctx, condition.Key{}, inf), inf.Informer() -} diff --git a/pkg/client/injection/informers/pipeline/v1alpha1/condition/filtered/condition.go b/pkg/client/injection/informers/pipeline/v1alpha1/condition/filtered/condition.go deleted file mode 100644 index 11f47953921..00000000000 --- a/pkg/client/injection/informers/pipeline/v1alpha1/condition/filtered/condition.go +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package filtered - -import ( - context "context" - - apispipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - versioned "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - v1alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" - client "github.com/tektoncd/pipeline/pkg/client/injection/client" - filtered "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory/filtered" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - cache "k8s.io/client-go/tools/cache" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterFilteredInformers(withInformer) - injection.Dynamic.RegisterDynamicInformer(withDynamicInformer) -} - -// Key is used for associating the Informer inside the context.Context. -type Key struct { - Selector string -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(filtered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := filtered.Get(ctx, selector) - inf := f.Tekton().V1alpha1().Conditions() - ctx = context.WithValue(ctx, Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} - -func withDynamicInformer(ctx context.Context) context.Context { - untyped := ctx.Value(filtered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - for _, selector := range labelSelectors { - inf := &wrapper{client: client.Get(ctx), selector: selector} - ctx = context.WithValue(ctx, Key{Selector: selector}, inf) - } - return ctx -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context, selector string) v1alpha1.ConditionInformer { - untyped := ctx.Value(Key{Selector: selector}) - if untyped == nil { - logging.FromContext(ctx).Panicf( - "Unable to fetch github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1.ConditionInformer with selector %s from context.", selector) - } - return untyped.(v1alpha1.ConditionInformer) -} - -type wrapper struct { - client versioned.Interface - - namespace string - - selector string -} - -var _ v1alpha1.ConditionInformer = (*wrapper)(nil) -var _ pipelinev1alpha1.ConditionLister = (*wrapper)(nil) - -func (w *wrapper) Informer() cache.SharedIndexInformer { - return cache.NewSharedIndexInformer(nil, &apispipelinev1alpha1.Condition{}, 0, nil) -} - -func (w *wrapper) Lister() pipelinev1alpha1.ConditionLister { - return w -} - -func (w *wrapper) Conditions(namespace string) pipelinev1alpha1.ConditionNamespaceLister { - return &wrapper{client: w.client, namespace: namespace, selector: w.selector} -} - -func (w *wrapper) List(selector labels.Selector) (ret []*apispipelinev1alpha1.Condition, err error) { - reqs, err := labels.ParseToRequirements(w.selector) - if err != nil { - return nil, err - } - selector = selector.Add(reqs...) - lo, err := w.client.TektonV1alpha1().Conditions(w.namespace).List(context.TODO(), v1.ListOptions{ - LabelSelector: selector.String(), - // TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria. - }) - if err != nil { - return nil, err - } - for idx := range lo.Items { - ret = append(ret, &lo.Items[idx]) - } - return ret, nil -} - -func (w *wrapper) Get(name string) (*apispipelinev1alpha1.Condition, error) { - // TODO(mattmoor): Check that the fetched object matches the selector. - return w.client.TektonV1alpha1().Conditions(w.namespace).Get(context.TODO(), name, v1.GetOptions{ - // TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria. - }) -} diff --git a/pkg/client/injection/informers/pipeline/v1alpha1/condition/filtered/fake/fake.go b/pkg/client/injection/informers/pipeline/v1alpha1/condition/filtered/fake/fake.go deleted file mode 100644 index 6896ddc111f..00000000000 --- a/pkg/client/injection/informers/pipeline/v1alpha1/condition/filtered/fake/fake.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package fake - -import ( - context "context" - - factoryfiltered "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory/filtered" - filtered "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/condition/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -var Get = filtered.Get - -func init() { - injection.Fake.RegisterFilteredInformers(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(factoryfiltered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := factoryfiltered.Get(ctx, selector) - inf := f.Tekton().V1alpha1().Conditions() - ctx = context.WithValue(ctx, filtered.Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} diff --git a/pkg/client/listers/pipeline/v1alpha1/condition.go b/pkg/client/listers/pipeline/v1alpha1/condition.go deleted file mode 100644 index ca835eb2c57..00000000000 --- a/pkg/client/listers/pipeline/v1alpha1/condition.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright 2020 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// ConditionLister helps list Conditions. -// All objects returned here must be treated as read-only. -type ConditionLister interface { - // List lists all Conditions in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.Condition, err error) - // Conditions returns an object that can list and get Conditions. - Conditions(namespace string) ConditionNamespaceLister - ConditionListerExpansion -} - -// conditionLister implements the ConditionLister interface. -type conditionLister struct { - indexer cache.Indexer -} - -// NewConditionLister returns a new ConditionLister. -func NewConditionLister(indexer cache.Indexer) ConditionLister { - return &conditionLister{indexer: indexer} -} - -// List lists all Conditions in the indexer. -func (s *conditionLister) List(selector labels.Selector) (ret []*v1alpha1.Condition, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Condition)) - }) - return ret, err -} - -// Conditions returns an object that can list and get Conditions. -func (s *conditionLister) Conditions(namespace string) ConditionNamespaceLister { - return conditionNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// ConditionNamespaceLister helps list and get Conditions. -// All objects returned here must be treated as read-only. -type ConditionNamespaceLister interface { - // List lists all Conditions in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.Condition, err error) - // Get retrieves the Condition from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.Condition, error) - ConditionNamespaceListerExpansion -} - -// conditionNamespaceLister implements the ConditionNamespaceLister -// interface. -type conditionNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Conditions in the indexer for a given namespace. -func (s conditionNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Condition, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Condition)) - }) - return ret, err -} - -// Get retrieves the Condition from the indexer for a given namespace and name. -func (s conditionNamespaceLister) Get(name string) (*v1alpha1.Condition, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("condition"), name) - } - return obj.(*v1alpha1.Condition), nil -} diff --git a/pkg/client/listers/pipeline/v1alpha1/expansion_generated.go b/pkg/client/listers/pipeline/v1alpha1/expansion_generated.go index fc4bd080d6a..6f4c92c04af 100644 --- a/pkg/client/listers/pipeline/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/pipeline/v1alpha1/expansion_generated.go @@ -22,14 +22,6 @@ package v1alpha1 // ClusterTaskLister. type ClusterTaskListerExpansion interface{} -// ConditionListerExpansion allows custom methods to be added to -// ConditionLister. -type ConditionListerExpansion interface{} - -// ConditionNamespaceListerExpansion allows custom methods to be added to -// ConditionNamespaceLister. -type ConditionNamespaceListerExpansion interface{} - // PipelineListerExpansion allows custom methods to be added to // PipelineLister. type PipelineListerExpansion interface{} diff --git a/pkg/reconciler/pipeline/dag/dag_test.go b/pkg/reconciler/pipeline/dag/dag_test.go index a9a7ad7ada3..abd0e3401b6 100644 --- a/pkg/reconciler/pipeline/dag/dag_test.go +++ b/pkg/reconciler/pipeline/dag/dag_test.go @@ -286,85 +286,6 @@ func TestBuild_FanInFanOut(t *testing.T) { assertSameDAG(t, expectedDAG, g) } -func TestBuild_ConditionResources(t *testing.T) { - // a,b, c are regular tasks - a := v1beta1.PipelineTask{Name: "a"} - b := v1beta1.PipelineTask{Name: "b"} - c := v1beta1.PipelineTask{Name: "c"} - - // Condition that depends on Task a output - cond1DependsOnA := v1beta1.PipelineTaskCondition{ - Resources: []v1beta1.PipelineTaskInputResource{{From: []string{"a"}}}, - } - // Condition that depends on Task b output - cond2DependsOnB := v1beta1.PipelineTaskCondition{ - Resources: []v1beta1.PipelineTaskInputResource{{From: []string{"b"}}}, - } - - // x indirectly depends on A,B via its conditions - xDependsOnAAndB := v1beta1.PipelineTask{ - Name: "x", - Conditions: []v1beta1.PipelineTaskCondition{cond1DependsOnA, cond2DependsOnB}, - } - - // y depends on a both directly + via its conditional - yDependsOnA := v1beta1.PipelineTask{ - Name: "y", - Resources: &v1beta1.PipelineTaskResources{ - Inputs: []v1beta1.PipelineTaskInputResource{{From: []string{"a"}}}, - }, - Conditions: []v1beta1.PipelineTaskCondition{cond1DependsOnA}, - } - - // y depends on b both directly + via its conditional - zDependsOnBRunsAfterC := v1beta1.PipelineTask{ - Name: "z", - RunAfter: []string{"c"}, - Conditions: []v1beta1.PipelineTaskCondition{cond2DependsOnB}, - } - - // a b c - // / \ / \ / - // y x z - nodeA := &dag.Node{Task: a} - nodeB := &dag.Node{Task: b} - nodeC := &dag.Node{Task: c} - nodeX := &dag.Node{Task: xDependsOnAAndB} - nodeY := &dag.Node{Task: yDependsOnA} - nodeZ := &dag.Node{Task: zDependsOnBRunsAfterC} - - nodeA.Next = []*dag.Node{nodeX, nodeY} - nodeB.Next = []*dag.Node{nodeX, nodeZ} - nodeC.Next = []*dag.Node{nodeZ} - nodeX.Prev = []*dag.Node{nodeA, nodeB} - nodeY.Prev = []*dag.Node{nodeA} - nodeZ.Prev = []*dag.Node{nodeB, nodeC} - - expectedDAG := &dag.Graph{ - Nodes: map[string]*dag.Node{ - "a": nodeA, - "b": nodeB, - "c": nodeC, - "x": nodeX, - "y": nodeY, - "z": nodeZ, - }, - } - - p := &v1beta1.Pipeline{ - ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{a, b, c, xDependsOnAAndB, yDependsOnA, zDependsOnBRunsAfterC}, - }, - } - - g, err := dag.Build(v1beta1.PipelineTaskList(p.Spec.Tasks), v1beta1.PipelineTaskList(p.Spec.Tasks).Deps()) - if err != nil { - t.Errorf("didn't expect error creating valid Pipeline %v but got %v", p, err) - } - assertSameDAG(t, expectedDAG, g) -} - func TestBuild_TaskParamsFromTaskResults(t *testing.T) { a := v1beta1.PipelineTask{Name: "a"} b := v1beta1.PipelineTask{Name: "b"} @@ -441,46 +362,6 @@ func TestBuild_TaskParamsFromTaskResults(t *testing.T) { assertSameDAG(t, expectedDAG, g) } -func TestBuild_ConditionsParamsFromTaskResults(t *testing.T) { - a := v1beta1.PipelineTask{Name: "a"} - xDependsOnA := v1beta1.PipelineTask{ - Name: "x", - Conditions: []v1beta1.PipelineTaskCondition{{ - ConditionRef: "cond", - Params: []v1beta1.Param{{ - Name: "paramX", - Value: *v1beta1.NewArrayOrString("$(tasks.a.results.resultA)"), - }}, - }}, - } - - // a - // | - // x - nodeA := &dag.Node{Task: a} - nodeX := &dag.Node{Task: xDependsOnA} - - nodeA.Next = []*dag.Node{nodeX} - nodeX.Prev = []*dag.Node{nodeA} - expectedDAG := &dag.Graph{ - Nodes: map[string]*dag.Node{ - "a": nodeA, - "x": nodeX, - }, - } - p := &v1beta1.Pipeline{ - ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{a, xDependsOnA}, - }, - } - g, err := dag.Build(v1beta1.PipelineTaskList(p.Spec.Tasks), v1beta1.PipelineTaskList(p.Spec.Tasks).Deps()) - if err != nil { - t.Fatalf("didn't expect error creating valid Pipeline %v but got %v", p, err) - } - assertSameDAG(t, expectedDAG, g) -} - func TestBuild_InvalidDAG(t *testing.T) { a := v1beta1.PipelineTask{Name: "a"} xDependsOnA := v1beta1.PipelineTask{ @@ -534,13 +415,6 @@ func TestBuild_InvalidDAG(t *testing.T) { RunAfter: []string{"none"}, } - invalidConditionalTask := v1beta1.PipelineTask{ - Name: "b", - Conditions: []v1beta1.PipelineTaskCondition{{ - ConditionRef: "some-condition", - Resources: []v1beta1.PipelineTaskInputResource{{From: []string{"none"}}}, - }}, - } aRunsAfterE := v1beta1.PipelineTask{Name: "a", RunAfter: []string{"e"}} bDependsOnA := v1beta1.PipelineTask{ Name: "b", @@ -645,10 +519,6 @@ func TestBuild_InvalidDAG(t *testing.T) { name: "invalid-task-name-after", spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{invalidTaskAfter}}, err: "wasn't present in Pipeline", - }, { - name: "invalid-task-name-from-conditional", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{invalidConditionalTask}}, - err: "wasn't present in Pipeline", }, } for _, tc := range tcs { diff --git a/pkg/reconciler/pipelinerun/controller.go b/pkg/reconciler/pipelinerun/controller.go index 6ffeee6da4b..ba077bab172 100644 --- a/pkg/reconciler/pipelinerun/controller.go +++ b/pkg/reconciler/pipelinerun/controller.go @@ -23,7 +23,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" pipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client" - conditioninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/condition" runinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/run" pipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipelinerun" taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun" @@ -53,7 +52,6 @@ func NewController(opts *pipeline.Options, clock clock.PassiveClock) func(contex runInformer := runinformer.Get(ctx) pipelineRunInformer := pipelineruninformer.Get(ctx) resourceInformer := resourceinformer.Get(ctx) - conditionInformer := conditioninformer.Get(ctx) resolutionInformer := resolutioninformer.Get(ctx) configStore := config.NewStore(logger.Named("config-store"), pipelinerunmetrics.MetricsOnStore(logger)) configStore.WatchConfigs(cmw) @@ -67,7 +65,6 @@ func NewController(opts *pipeline.Options, clock clock.PassiveClock) func(contex taskRunLister: taskRunInformer.Lister(), runLister: runInformer.Lister(), resourceLister: resourceInformer.Lister(), - conditionLister: conditionInformer.Lister(), cloudEventClient: cloudeventclient.Get(ctx), metrics: pipelinerunmetrics.Get(ctx), pvcHandler: volumeclaim.NewPVCHandler(kubeclientset, logger), diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 999adb35416..4c7cafd8ac7 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -23,7 +23,6 @@ import ( "fmt" "path/filepath" "reflect" - "strconv" "strings" "time" @@ -132,7 +131,6 @@ type Reconciler struct { taskRunLister listers.TaskRunLister runLister listersv1alpha1.RunLister resourceLister resourcelisters.PipelineResourceLister - conditionLister listersv1alpha1.ConditionLister cloudEventClient cloudevent.CEClient metrics *pipelinerunmetrics.Recorder pvcHandler volumeclaim.PvcHandler @@ -309,9 +307,6 @@ func (c *Reconciler) resolvePipelineState( func(name string) (*v1alpha1.Run, error) { return c.runLister.Runs(pr.Namespace).Get(name) }, - func(name string) (*v1alpha1.Condition, error) { - return c.conditionLister.Conditions(pr.Namespace).Get(name) - }, task, providedResources, ) if err != nil { @@ -326,10 +321,6 @@ func (c *Reconciler) resolvePipelineState( pr.Status.MarkFailed(ReasonCouldntGetTask, "Pipeline %s/%s can't be Run; it contains Tasks that don't exist: %s", pipelineMeta.Namespace, pipelineMeta.Name, err) - case *resources.ConditionNotFoundError: - pr.Status.MarkFailed(ReasonCouldntGetCondition, - "PipelineRun %s/%s can't be Run; it contains Conditions that don't exist: %s", - pipelineMeta.Namespace, pr.Name, err) default: pr.Status.MarkFailed(ReasonFailedValidation, "PipelineRun %s/%s can't be Run; couldn't resolve all references: %s", @@ -479,7 +470,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get // Update pipelinespec of pipelinerun's status field pr.Status.PipelineSpec = pipelineSpec - // pipelineState holds a list of pipeline tasks after resolving conditions and pipeline resources + // pipelineState holds a list of pipeline tasks after resolving pipeline resources // pipelineState also holds a taskRun for each pipeline task after the taskRun is created // pipelineState is instantiated and updated on every reconcile cycle // Resolve the set of tasks (and possibly task runs). @@ -697,35 +688,25 @@ func (c *Reconciler) runNextSchedulableTask(ctx context.Context, pr *v1beta1.Pip if rprt == nil || rprt.Skip(pipelineRunFacts).IsSkipped || rprt.IsFinallySkipped(pipelineRunFacts).IsSkipped { continue } - if rprt.ResolvedConditionChecks == nil || rprt.ResolvedConditionChecks.IsSuccess() { - if rprt.IsCustomTask() { - if rprt.IsFinalTask(pipelineRunFacts) { - rprt.Run, err = c.createRun(ctx, rprt, pr, getFinallyTaskRunTimeout) - } else { - rprt.Run, err = c.createRun(ctx, rprt, pr, getTaskRunTimeout) - } - if err != nil { - recorder.Eventf(pr, corev1.EventTypeWarning, "RunCreationFailed", "Failed to create Run %q: %v", rprt.RunName, err) - return fmt.Errorf("error creating Run called %s for PipelineTask %s from PipelineRun %s: %w", rprt.RunName, rprt.PipelineTask.Name, pr.Name, err) - } + if rprt.IsCustomTask() { + if rprt.IsFinalTask(pipelineRunFacts) { + rprt.Run, err = c.createRun(ctx, rprt, pr, getFinallyTaskRunTimeout) } else { - if rprt.IsFinalTask(pipelineRunFacts) { - rprt.TaskRun, err = c.createTaskRun(ctx, rprt, pr, as.StorageBasePath(pr), getFinallyTaskRunTimeout) - } else { - rprt.TaskRun, err = c.createTaskRun(ctx, rprt, pr, as.StorageBasePath(pr), getTaskRunTimeout) - } - if err != nil { - recorder.Eventf(pr, corev1.EventTypeWarning, "TaskRunCreationFailed", "Failed to create TaskRun %q: %v", rprt.TaskRunName, err) - return fmt.Errorf("error creating TaskRun called %s for PipelineTask %s from PipelineRun %s: %w", rprt.TaskRunName, rprt.PipelineTask.Name, pr.Name, err) - } + rprt.Run, err = c.createRun(ctx, rprt, pr, getTaskRunTimeout) } - } else if !rprt.ResolvedConditionChecks.HasStarted() { - for _, rcc := range rprt.ResolvedConditionChecks { - rcc.ConditionCheck, err = c.makeConditionCheckContainer(ctx, rprt, rcc, pr) - if err != nil { - recorder.Eventf(pr, corev1.EventTypeWarning, "ConditionCheckCreationFailed", "Failed to create TaskRun %q: %v", rcc.ConditionCheckName, err) - return fmt.Errorf("error creating ConditionCheck container called %s for PipelineTask %s from PipelineRun %s: %w", rcc.ConditionCheckName, rprt.PipelineTask.Name, pr.Name, err) - } + if err != nil { + recorder.Eventf(pr, corev1.EventTypeWarning, "RunCreationFailed", "Failed to create Run %q: %v", rprt.RunName, err) + return fmt.Errorf("error creating Run called %s for PipelineTask %s from PipelineRun %s: %w", rprt.RunName, rprt.PipelineTask.Name, pr.Name, err) + } + } else { + if rprt.IsFinalTask(pipelineRunFacts) { + rprt.TaskRun, err = c.createTaskRun(ctx, rprt, pr, as.StorageBasePath(pr), getFinallyTaskRunTimeout) + } else { + rprt.TaskRun, err = c.createTaskRun(ctx, rprt, pr, as.StorageBasePath(pr), getTaskRunTimeout) + } + if err != nil { + recorder.Eventf(pr, corev1.EventTypeWarning, "TaskRunCreationFailed", "Failed to create TaskRun %q: %v", rprt.TaskRunName, err) + return fmt.Errorf("error creating TaskRun called %s for PipelineTask %s from PipelineRun %s: %w", rprt.TaskRunName, rprt.PipelineTask.Name, pr.Name, err) } } } @@ -736,7 +717,6 @@ func (c *Reconciler) runNextSchedulableTask(ctx context.Context, pr *v1beta1.Pip // When the "full" and "both" options are removed, updateTaskRunsStatusDirectly can be removed. func (c *Reconciler) updateTaskRunsStatusDirectly(pr *v1beta1.PipelineRun) error { for taskRunName := range pr.Status.TaskRuns { - // TODO(dibyom): Add conditionCheck statuses here prtrs := pr.Status.TaskRuns[taskRunName] tr, err := c.taskRunLister.TaskRuns(pr.Namespace).Get(taskRunName) if err != nil { @@ -1140,55 +1120,6 @@ func (c *Reconciler) updateLabelsAndAnnotations(ctx context.Context, pr *v1beta1 return newPr, nil } -func (c *Reconciler) makeConditionCheckContainer(ctx context.Context, rprt *resources.ResolvedPipelineRunTask, rcc *resources.ResolvedConditionCheck, pr *v1beta1.PipelineRun) (*v1beta1.ConditionCheck, error) { - labels := getTaskrunLabels(pr, rprt.PipelineTask.Name, true) - labels[pipeline.ConditionCheckKey] = rcc.ConditionCheckName - labels[pipeline.ConditionNameKey] = rcc.Condition.Name - - for key, value := range rcc.Condition.ObjectMeta.Labels { - labels[key] = value - } - - // Propagate annotations from PipelineRun to TaskRun. - annotations := getTaskrunAnnotations(pr) - - for key, value := range rcc.Condition.ObjectMeta.Annotations { - annotations[key] = value - } - - taskSpec, err := rcc.ConditionToTaskSpec() - if err != nil { - return nil, fmt.Errorf("failed to get TaskSpec from Condition: %w", err) - } - - taskRunSpec := pr.GetTaskRunSpec(rprt.PipelineTask.Name) - tr := &v1beta1.TaskRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: rcc.ConditionCheckName, - Namespace: pr.Namespace, - OwnerReferences: []metav1.OwnerReference{*kmeta.NewControllerRef(pr)}, - Labels: labels, - Annotations: annotations, - }, - Spec: v1beta1.TaskRunSpec{ - TaskSpec: taskSpec, - ServiceAccountName: taskRunSpec.TaskServiceAccountName, - Params: rcc.PipelineTaskCondition.Params, - Resources: &v1beta1.TaskRunResources{ - Inputs: rcc.ToTaskResourceBindings(), - }, - Timeout: getTaskRunTimeout(ctx, pr, rprt, c.Clock), - PodTemplate: taskRunSpec.TaskPodTemplate, - }} - - cctr, err := c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).Create(ctx, tr, metav1.CreateOptions{}) - if err != nil { - return nil, err - } - cc := v1beta1.ConditionCheck(*cctr) - return &cc, err -} - func storePipelineSpecAndMergeMeta(pr *v1beta1.PipelineRun, ps *v1beta1.PipelineSpec, meta *metav1.ObjectMeta) error { // Only store the PipelineSpec once, if it has never been set before. if pr.Status.PipelineSpec == nil { @@ -1327,10 +1258,9 @@ func validateChildObjectsInPipelineRunStatus(ctx context.Context, prs v1beta1.Pi return err } -// filterTaskRunsForPipelineRun returns TaskRuns owned by the PipelineRun and their condition checks -func filterTaskRunsForPipelineRun(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun) ([]*v1beta1.TaskRun, map[string][]*v1beta1.TaskRun) { - var normalTaskRuns []*v1beta1.TaskRun - conditionTaskRuns := make(map[string][]*v1beta1.TaskRun) +// filterTaskRunsForPipelineRun returns TaskRuns owned by the PipelineRun. +func filterTaskRunsForPipelineRun(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun) []*v1beta1.TaskRun { + var ownedTaskRuns []*v1beta1.TaskRun for _, tr := range trs { // Only process TaskRuns that are owned by this PipelineRun. @@ -1339,21 +1269,10 @@ func filterTaskRunsForPipelineRun(logger *zap.SugaredLogger, pr *v1beta1.Pipelin logger.Debugf("Found a TaskRun %s that is not owned by this PipelineRun", tr.Name) continue } - lbls := tr.GetLabels() - pipelineTaskName := lbls[pipeline.PipelineTaskLabelKey] - if _, ok := lbls[pipeline.ConditionCheckKey]; ok { - // Save condition for looping over them after this - if _, ok := conditionTaskRuns[pipelineTaskName]; !ok { - // If it's the first condition taskrun, initialise the slice - conditionTaskRuns[pipelineTaskName] = []*v1beta1.TaskRun{} - } - conditionTaskRuns[pipelineTaskName] = append(conditionTaskRuns[pipelineTaskName], tr) - } else { - normalTaskRuns = append(normalTaskRuns, tr) - } + ownedTaskRuns = append(ownedTaskRuns, tr) } - return normalTaskRuns, conditionTaskRuns + return ownedTaskRuns } // filterRunsForPipelineRun filters the given slice of Runs, returning only those owned by the given PipelineRun. @@ -1375,7 +1294,7 @@ func filterRunsForPipelineRun(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun } // updatePipelineRunStatusFromTaskRuns takes a PipelineRun and a list of TaskRuns within that PipelineRun, and updates -// the PipelineRun's .Status.TaskRuns, including ensuring that any (deprecated) condition checks are represented. +// the PipelineRun's .Status.TaskRuns. func updatePipelineRunStatusFromTaskRuns(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun) { // If no TaskRun was found, nothing to be done. We never remove taskruns from the status if len(trs) == 0 { @@ -1386,7 +1305,7 @@ func updatePipelineRunStatusFromTaskRuns(logger *zap.SugaredLogger, pr *v1beta1. pr.Status.TaskRuns = make(map[string]*v1beta1.PipelineRunTaskRunStatus) } - taskRuns, conditionTaskRuns := filterTaskRunsForPipelineRun(logger, pr, trs) + taskRuns := filterTaskRunsForPipelineRun(logger, pr, trs) // Loop over all the TaskRuns associated to Tasks for _, taskrun := range taskRuns { @@ -1400,65 +1319,9 @@ func updatePipelineRunStatusFromTaskRuns(logger *zap.SugaredLogger, pr *v1beta1. pr.Status.TaskRuns[taskrun.Name] = &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: pipelineTaskName, Status: &taskrun.Status, - ConditionChecks: nil, - } - } - } - // Then loop by pipelinetask name over all the TaskRuns associated to Conditions - for pipelineTaskName, actualConditionTaskRuns := range conditionTaskRuns { - // GetTaskRunName will look in first ChildReferences and then TaskRuns to see if there's already a TaskRun name - // for this pipelineTaskName, and if not, it will generate one. - taskRunName := resources.GetTaskRunName(pr.Status.TaskRuns, pr.Status.ChildReferences, pipelineTaskName, pr.Name) - - if _, ok := pr.Status.TaskRuns[taskRunName]; !ok { - pr.Status.TaskRuns[taskRunName] = &v1beta1.PipelineRunTaskRunStatus{ - PipelineTaskName: pipelineTaskName, - Status: nil, - ConditionChecks: nil, - } - } - - // Add any new condition checks which we've found but weren't already present to the status's condition checks map - for k, v := range getNewConditionChecksForTaskRun(logger, pr.Status.TaskRuns[taskRunName].ConditionChecks, actualConditionTaskRuns) { - if pr.Status.TaskRuns[taskRunName].ConditionChecks == nil { - pr.Status.TaskRuns[taskRunName].ConditionChecks = make(map[string]*v1beta1.PipelineRunConditionCheckStatus) - } - - pr.Status.TaskRuns[taskRunName].ConditionChecks[k] = v - } - } -} - -// getNewConditionChecksForTaskRun returns a map of condition task name to condition check status for each condition TaskRun -// provided which isn't already present in the existing map of condition checks. -func getNewConditionChecksForTaskRun(logger *zap.SugaredLogger, existingChecks map[string]*v1beta1.PipelineRunConditionCheckStatus, - actualConditionTaskRuns []*v1beta1.TaskRun) map[string]*v1beta1.PipelineRunConditionCheckStatus { - // If we don't have any condition task runs to process, just return nil. - if len(actualConditionTaskRuns) == 0 { - return nil - } - - newChecks := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) - - for i, foundTaskRun := range actualConditionTaskRuns { - lbls := foundTaskRun.GetLabels() - if _, ok := existingChecks[foundTaskRun.Name]; !ok { - // The condition check was not found, so we need to add it - // We only add the condition name, the status can now be gathered by the - // normal reconcile process - if conditionName, ok := lbls[pipeline.ConditionNameKey]; ok { - newChecks[foundTaskRun.Name] = &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: fmt.Sprintf("%s-%s", conditionName, strconv.Itoa(i)), - } - } else { - // The condition name label is missing, so we cannot recover this - logger.Warnf("found an orphaned condition taskrun %#v with missing %s label", - foundTaskRun, pipeline.ConditionNameKey) } } } - - return newChecks } func updatePipelineRunStatusFromRuns(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, runs []*v1alpha1.Run) { @@ -1498,7 +1361,7 @@ func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1 childRefByPipelineTask[pr.Status.ChildReferences[i].PipelineTaskName] = &pr.Status.ChildReferences[i] } - taskRuns, conditionTaskRuns := filterTaskRunsForPipelineRun(logger, pr, trs) + taskRuns := filterTaskRunsForPipelineRun(logger, pr, trs) // Loop over all the TaskRuns associated to Tasks for _, tr := range taskRuns { @@ -1544,32 +1407,6 @@ func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1 } } - // Then loop by pipelinetask name over all the TaskRuns associated to Conditions - for pipelineTaskName, actualConditionTaskRuns := range conditionTaskRuns { - // GetTaskRunName will look in first ChildReferences and then TaskRuns to see if there's already a TaskRun name - // for this pipelineTaskName, and if not, it will generate one. - taskRunName := resources.GetTaskRunName(pr.Status.TaskRuns, pr.Status.ChildReferences, pipelineTaskName, pr.Name) - if _, ok := childRefByPipelineTask[pipelineTaskName]; !ok { - childRefByPipelineTask[pipelineTaskName] = &v1beta1.ChildStatusReference{ - TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: "TaskRun", - }, - Name: taskRunName, - PipelineTaskName: pipelineTaskName, - } - } - - for k, v := range getNewConditionChecksForTaskRun(logger, childRefByPipelineTask[pipelineTaskName].GetConditionChecks(), actualConditionTaskRuns) { - // Just append any new condition checks to the relevant ChildStatusReference.ConditionChecks. - childRefByPipelineTask[pipelineTaskName].ConditionChecks = append(childRefByPipelineTask[pipelineTaskName].ConditionChecks, - &v1beta1.PipelineRunChildConditionCheckStatus{ - PipelineRunConditionCheckStatus: *v, - ConditionCheckName: k, - }) - } - } - var newChildRefs []v1beta1.ChildStatusReference for k := range childRefByPipelineTask { newChildRefs = append(newChildRefs, *childRefByPipelineTask[k]) diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 12bc3ed42dd..9b90215360f 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -988,18 +988,6 @@ spec: taskRef: name: a-task-that-needs-array-params `, v1beta1.ParamTypeArray)), - parse.MustParsePipeline(t, ` -metadata: - name: a-pipeline-with-missing-conditions - namespace: foo -spec: - tasks: - - name: some-task - taskRef: - name: a-task-that-exists - conditions: - - conditionRef: condition-does-not-exist -`), } for _, tc := range []struct { @@ -1129,22 +1117,6 @@ spec: "Normal Started", "Warning Failed PipelineRun foo/pipeline-mismatching-param-type parameters have mismatching types", }, - }, { - name: "invalid-pipeline-missing-conditions-shd-stop-reconciling", - pipelineRun: parse.MustParsePipelineRun(t, ` -metadata: - name: pipeline-conditions-missing - namespace: foo -spec: - pipelineRef: - name: a-pipeline-with-missing-conditions -`), - reason: ReasonCouldntGetCondition, - permanentError: true, - wantEvents: []string{ - "Normal Started", - "Warning Failed PipelineRun foo/pipeline-conditions-missing can't be Run; it contains Conditions", - }, }, { name: "invalid-embedded-pipeline-resources-bot-bound-shd-stop-reconciling", pipelineRun: parse.MustParsePipelineRun(t, fmt.Sprintf(` @@ -1810,10 +1782,12 @@ func runTestReconcileOnCancelledRunFinallyPipelineRun(t *testing.T, embeddedStat prs := []*v1beta1.PipelineRun{createCancelledPipelineRun(t, "test-pipeline-run-cancelled-run-finally", v1beta1.PipelineRunSpecStatusCancelledRunFinally)} ps := []*v1beta1.Pipeline{helloWorldPipelineWithRunAfter(t)} ts := []*v1beta1.Task{simpleHelloWorldTask} + cms := []*corev1.ConfigMap{withEmbeddedStatus(newFeatureFlagsConfigMap(), embeddedStatus)} d := test.Data{ PipelineRuns: prs, Pipelines: ps, Tasks: ts, + ConfigMaps: cms, } prt := newPipelineRunTest(d, t) defer prt.Cancel() @@ -3563,282 +3537,6 @@ spec: } -func TestReconcileWithConditionChecks(t *testing.T) { - // TestReconcileWithConditionChecks runs "Reconcile" on a PipelineRun that has a task with - // multiple conditions. It verifies that reconcile is successful, taskruns are created and - // the status is updated. It checks that the correct events are sent. - names.TestingSeed() - prName := "test-pipeline-run" - conditions := []*v1alpha1.Condition{ - parse.MustParseCondition(t, ` -metadata: - annotations: - annotation-1: value-1 - labels: - label-1: value-1 - label-2: value-2 - name: cond-1 - namespace: foo -spec: - check: - args: - - bar - image: foo -`), - parse.MustParseCondition(t, ` -metadata: - labels: - label-3: value-3 - label-4: value-4 - name: cond-2 - namespace: foo -spec: - check: - args: - - bar - image: foo -`), - } - ps := []*v1beta1.Pipeline{parse.MustParsePipeline(t, ` -metadata: - name: test-pipeline - namespace: foo -spec: - tasks: - - conditions: - - conditionRef: cond-1 - - conditionRef: cond-2 - name: hello-world-1 - taskRef: - name: hello-world -`)} - prs := []*v1beta1.PipelineRun{parse.MustParsePipelineRun(t, ` -metadata: - annotations: - PipelineRunAnnotation: PipelineRunValue - name: test-pipeline-run - namespace: foo -spec: - pipelineRef: - name: test-pipeline - serviceAccountName: test-sa -`)} - ts := []*v1beta1.Task{simpleHelloWorldTask} - - d := test.Data{ - PipelineRuns: prs, - Pipelines: ps, - Tasks: ts, - Conditions: conditions, - } - prt := newPipelineRunTest(d, t) - defer prt.Cancel() - - wantEvents := []string{ - "Normal Started", - "Normal Running Tasks Completed: 0 \\(Failed: 0, Cancelled 0\\), Incomplete: 1, Skipped: 0", - } - _, clients := prt.reconcileRun("foo", prName, wantEvents, false) - - ccNameBase := prName + "-hello-world-1" - ccNames := map[string]string{ - "cond-1": ccNameBase + "-cond-1-0", - "cond-2": ccNameBase + "-cond-2-1", - } - expectedConditionChecks := make([]*v1beta1.TaskRun, len(conditions)) - for index, condition := range conditions { - expectedConditionChecks[index] = makeExpectedTr(condition.Name, ccNames[condition.Name], condition.Labels, condition.Annotations) - } - - // Check that the expected TaskRun was created - actual := getTaskRunCreations(t, clients.Pipeline.Actions(), 3) - if d := cmp.Diff(actual, expectedConditionChecks); d != "" { - t.Errorf("expected to see 2 ConditionCheck TaskRuns created. Diff %s", diff.PrintWantGot(d)) - } -} - -func TestReconcileWithFailingConditionChecks(t *testing.T) { - // TestReconcileWithFailingConditionChecks runs "Reconcile" on a PipelineRun that has a task with - // multiple conditions, some that fails. It verifies that reconcile is successful, taskruns are - // created and the status is updated. It checks that the correct events are sent. - names.TestingSeed() - conditions := []*v1alpha1.Condition{parse.MustParseCondition(t, ` -metadata: - name: always-false - namespace: foo -spec: - check: - args: - - bar - image: foo -`)} - pipelineRunName := "test-pipeline-run-with-conditions" - prccs := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) - - conditionCheckName := pipelineRunName + "task-2-always-false" - prccs[conditionCheckName] = &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: "always-false-0", - Status: &v1beta1.ConditionCheckStatus{}, - } - ps := []*v1beta1.Pipeline{parse.MustParsePipeline(t, ` -metadata: - name: test-pipeline - namespace: foo -spec: - tasks: - - name: task-1 - taskRef: - name: hello-world - - conditions: - - conditionRef: always-false - name: task-2 - taskRef: - name: hello-world - - name: task-3 - runAfter: - - task-1 - taskRef: - name: hello-world -`)} - - prs := []*v1beta1.PipelineRun{parse.MustParsePipelineRun(t, ` -metadata: - annotations: - PipelineRunAnnotation: PipelineRunValue - name: test-pipeline-run-with-conditions - namespace: foo -spec: - pipelineRef: - name: test-pipeline - serviceAccountName: test-sa -status: - conditions: - - message: Not all Tasks in the Pipeline have finished executing - reason: Running - status: Unknown - type: Succeeded - taskRuns: - test-pipeline-run-with-conditionstask-1: - pipelineTaskName: task-1 - test-pipeline-run-with-conditionstask-2: - conditionChecks: - test-pipeline-run-with-conditionstask-2-always-false: - conditionName: always-false-0 - status: - check: {} - pipelineTaskName: task-2 -`)} - - ts := []*v1beta1.Task{simpleHelloWorldTask} - trs := []*v1beta1.TaskRun{ - parse.MustParseTaskRun(t, ` -metadata: - labels: - tekton.dev/memberOf: tasks - tekton.dev/pipeline: test-pipeine-run-with-conditions - tekton.dev/pipelineRun: test-pipeline - name: test-pipeline-run-with-conditionstask-1 - namespace: foo - ownerReferences: - - kind: kind - name: name -spec: - taskRef: - name: hello-world -status: - conditions: - - lastTransitionTime: null - status: "True" - type: Succeeded -`), - parse.MustParseTaskRun(t, ` -metadata: - labels: - tekton.dev/conditionCheck: test-pipeline-run-with-conditionstask-2-always-false - tekton.dev/conditionName: always-false - tekton.dev/pipeline: test-pipeine-run-with-conditions - tekton.dev/pipelineRun: test-pipeline - name: test-pipeline-run-with-conditionstask-2-always-false - namespace: foo - ownerReferences: - - kind: kind - name: name -spec: - taskSpec: {} -status: - conditions: - - lastTransitionTime: null - status: "False" - type: Succeeded -`), - } - - d := test.Data{ - PipelineRuns: prs, - Pipelines: ps, - Tasks: ts, - TaskRuns: trs, - Conditions: conditions, - } - prt := newPipelineRunTest(d, t) - defer prt.Cancel() - - wantEvents := []string{ - "Normal Started", - "Normal Running Tasks Completed: 1 \\(Failed: 0, Cancelled 0\\), Incomplete: 1, Skipped: 1", - } - _, clients := prt.reconcileRun("foo", pipelineRunName, wantEvents, false) - - // Check that the expected TaskRun was created - actual := getTaskRunCreations(t, clients.Pipeline.Actions(), 2)[0] - expectedTaskRunObjectMeta := taskRunObjectMeta("test-pipeline-run-with-conditions-task-3", "foo", "test-pipeline-run-with-conditions", "test-pipeline", "task-3", false) - expectedTaskRunObjectMeta.Annotations["PipelineRunAnnotation"] = "PipelineRunValue" - expectedTaskRun := mustParseTaskRunWithObjectMeta(t, expectedTaskRunObjectMeta, ` -spec: - resources: {} - serviceAccountName: test-sa - taskRef: - name: hello-world - timeout: 1h0m0s -`) - - if d := cmp.Diff(actual, expectedTaskRun, ignoreTypeMeta); d != "" { - t.Errorf("expected to see ConditionCheck TaskRun %v created. Diff %s", expectedTaskRun, diff.PrintWantGot(d)) - } -} - -func makeExpectedTr(condName, ccName string, labels, annotations map[string]string) *v1beta1.TaskRun { - om := taskRunObjectMeta(ccName, "foo", "test-pipeline-run", "test-pipeline", "hello-world-1", false) - for k, v := range labels { - om.Labels[k] = v - } - om.Labels[pipeline.ConditionCheckKey] = ccName - om.Labels[pipeline.ConditionNameKey] = condName - if len(om.Annotations) == 0 { - om.Annotations = map[string]string{} - } - for k, v := range annotations { - om.Annotations[k] = v - } - om.Annotations["PipelineRunAnnotation"] = "PipelineRunValue" - - return &v1beta1.TaskRun{ - ObjectMeta: om, - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Name: "condition-check-" + condName, - Image: "foo", - Args: []string{"bar"}, - }}, - }, - ServiceAccountName: "test-sa", - Resources: &v1beta1.TaskRunResources{}, - Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute}, - }, - } -} - func ensurePVCCreated(ctx context.Context, t *testing.T, clients test.Clients, name, namespace string) { t.Helper() _, err := clients.Kube.CoreV1().PersistentVolumeClaims(namespace).Get(ctx, name, metav1.GetOptions{}) @@ -5205,38 +4903,6 @@ func runTestReconcileOutOfSyncPipelineRun(t *testing.T, embeddedStatus string) { prOutOfSyncName := "test-pipeline-run-out-of-sync" helloWorldTask := simpleHelloWorldTask - // Condition checks for the third task - prccs3 := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) - conditionCheckName3 := prOutOfSyncName + "-hello-world-3-always-true" - prccs3[conditionCheckName3] = &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: "always-true-0", - Status: &v1beta1.ConditionCheckStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{ - apis.Condition{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionUnknown, - }, - }, - }, - }, - } - // Condition checks for the fourth task - prccs4 := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) - conditionCheckName4 := prOutOfSyncName + "-hello-world-4-always-true" - prccs4[conditionCheckName4] = &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: "always-true-0", - Status: &v1beta1.ConditionCheckStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{ - apis.Condition{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionUnknown, - }, - }, - }, - }, - } testPipeline := parse.MustParsePipeline(t, ` metadata: name: test-pipeline @@ -5249,16 +4915,6 @@ spec: - name: hello-world-2 taskRef: name: hello-world - - conditions: - - conditionRef: always-true - name: hello-world-3 - taskRef: - name: hello-world - - conditions: - - conditionRef: always-true - name: hello-world-4 - taskRef: - name: hello-world - name: hello-world-5 taskRef: apiVersion: example.dev/v0 @@ -5291,51 +4947,6 @@ status: type: Succeeded `) - // This taskrun has a condition attached. The condition is in the pipelinerun, but the taskrun - // itself is *not* in the pipelinerun status. It's still running. - taskRunWithCondition := mustParseTaskRunWithObjectMeta(t, - taskRunObjectMeta("test-pipeline-run-out-of-sync-hello-world-3", "foo", prOutOfSyncName, testPipeline.Name, "hello-world-3", false), - ` -spec: - taskRef: - name: hello-world -status: - conditions: - - status: Unknown - type: Succeeded -`) - - taskRunForConditionOfOrphanedTaskRunObjectMeta := taskRunObjectMeta(conditionCheckName3, "foo", prOutOfSyncName, testPipeline.Name, "hello-world-3", false) - taskRunForConditionOfOrphanedTaskRunObjectMeta.Labels[pipeline.ConditionCheckKey] = conditionCheckName3 - taskRunForConditionOfOrphanedTaskRunObjectMeta.Labels[pipeline.ConditionNameKey] = "always-true" - - taskRunForConditionOfOrphanedTaskRun := mustParseTaskRunWithObjectMeta(t, taskRunForConditionOfOrphanedTaskRunObjectMeta, ` -spec: - taskRef: - name: always-true-0 -status: - conditions: - - status: Unknown - type: Succeeded -`) - - // This taskrun has a condition attached. The condition is *not* the in pipelinerun, and it's still - // running. The taskrun itself was not created yet. - taskRunWithOrphanedConditionName := "test-pipeline-run-out-of-sync-hello-world-4" - taskRunForOrphanedConditionObjectMeta := taskRunObjectMeta(conditionCheckName4, "foo", prOutOfSyncName, testPipeline.Name, "hello-world-4", false) - taskRunForOrphanedConditionObjectMeta.Labels[pipeline.ConditionCheckKey] = conditionCheckName4 - taskRunForOrphanedConditionObjectMeta.Labels[pipeline.ConditionNameKey] = "always-true" - - taskRunForOrphanedCondition := mustParseTaskRunWithObjectMeta(t, taskRunForOrphanedConditionObjectMeta, ` -spec: - taskRef: - name: always-true-0 -status: - conditions: - - status: Unknown - type: Succeeded -`) - orphanedRun := mustParseRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-out-of-sync-hello-world-5", "foo", prOutOfSyncName, testPipeline.Name, "hello-world-5", true), @@ -5370,11 +4981,6 @@ status: PipelineTaskName: "hello-world-1", Status: &v1beta1.TaskRunStatus{}, }, - taskRunWithCondition.Name: { - PipelineTaskName: "hello-world-3", - Status: nil, - ConditionChecks: prccs3, - }, } } if shouldHaveMinimalEmbeddedStatus(embeddedStatus) { @@ -5387,37 +4993,14 @@ status: Name: taskRunDone.Name, PipelineTaskName: "hello-world-1", }, - { - TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: "TaskRun", - }, - Name: taskRunWithCondition.Name, - PipelineTaskName: "hello-world-3", - ConditionChecks: []*v1beta1.PipelineRunChildConditionCheckStatus{{ - PipelineRunConditionCheckStatus: *prccs3[conditionCheckName3], - ConditionCheckName: conditionCheckName3, - }}, - }, } } prs := []*v1beta1.PipelineRun{prOutOfSync} ps := []*v1beta1.Pipeline{testPipeline} ts := []*v1beta1.Task{helloWorldTask} - trs := []*v1beta1.TaskRun{taskRunDone, taskRunOrphaned, taskRunWithCondition, - taskRunForOrphanedCondition, taskRunForConditionOfOrphanedTaskRun} + trs := []*v1beta1.TaskRun{taskRunDone, taskRunOrphaned} runs := []*v1alpha1.Run{orphanedRun} - cs := []*v1alpha1.Condition{parse.MustParseCondition(t, ` -metadata: - name: always-true - namespace: foo -spec: - check: - args: - - bar - image: foo -`)} cms := []*corev1.ConfigMap{withCustomTasks(withEmbeddedStatus(newFeatureFlagsConfigMap(), embeddedStatus))} @@ -5426,7 +5009,6 @@ spec: Pipelines: ps, Tasks: ts, TaskRuns: trs, - Conditions: cs, Runs: runs, ConfigMaps: cms, } @@ -5502,26 +5084,6 @@ spec: }, }, } - // taskRunWithCondition was recovered into the status. The condition did not change. - expectedTaskRunsStatus[taskRunWithCondition.Name] = &v1beta1.PipelineRunTaskRunStatus{ - PipelineTaskName: "hello-world-3", - Status: &v1beta1.TaskRunStatus{ - Status: duckv1beta1.Status{ - Conditions: []apis.Condition{ - { - Type: apis.ConditionSucceeded, - Status: corev1.ConditionUnknown, - }, - }, - }, - }, - ConditionChecks: prccs3, - } - // taskRunWithOrphanedConditionName had the condition recovered into the status. No taskrun. - expectedTaskRunsStatus[taskRunWithOrphanedConditionName] = &v1beta1.PipelineRunTaskRunStatus{ - PipelineTaskName: "hello-world-4", - ConditionChecks: prccs4, - } // orphanedRun was recovered into the status expectedRunsStatus[orphanedRun.Name] = &v1beta1.PipelineRunRunStatus{ PipelineTaskName: "hello-world-5", @@ -5556,16 +5118,6 @@ spec: WhenExpressions: cr.WhenExpressions, } - for _, cc := range cr.ConditionChecks { - if trStatusForPipelineRun.ConditionChecks == nil { - trStatusForPipelineRun.ConditionChecks = make(map[string]*v1beta1.PipelineRunConditionCheckStatus) - } - trStatusForPipelineRun.ConditionChecks[cc.ConditionCheckName] = &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: cc.ConditionName, - Status: cc.Status, - } - } - tr, _ := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(ctx, cr.Name, metav1.GetOptions{}) if tr != nil { trStatusForPipelineRun.Status = &tr.Status diff --git a/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go b/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go index bbe6ac3268f..cfd5883ae18 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go @@ -50,7 +50,7 @@ var ( ) type updateStatusTaskRunsData struct { - withConditions map[string]*v1beta1.PipelineRunTaskRunStatus + noTaskRuns map[string]*v1beta1.PipelineRunTaskRunStatus missingTaskRun map[string]*v1beta1.PipelineRunTaskRunStatus foundTaskRun map[string]*v1beta1.PipelineRunTaskRunStatus recovered map[string]*v1beta1.PipelineRunTaskRunStatus @@ -63,69 +63,18 @@ pipelineTaskName: task-1 status: {} ` prTask2Yaml := ` -conditionChecks: - pr-task-2-running-condition-check-xxyyy: - conditionName: running-condition-0 - status: - check: - running: {} - conditions: - - status: Unknown - type: Succeeded pipelineTaskName: task-2 ` prTask3Yaml := ` -conditionChecks: - pr-task-3-successful-condition-check-xxyyy: - conditionName: successful-condition-0 - status: - check: - terminated: - exitCode: 0 - conditions: - - status: "True" - type: Succeeded pipelineTaskName: task-3 status: {} ` prTask4Yaml := ` -conditionChecks: - pr-task-4-failed-condition-check-xxyyy: - conditionName: failed-condition-0 - status: - check: - terminated: - exitCode: 127 - conditions: - - status: "False" - type: Succeeded pipelineTaskName: task-4 ` - prTask3NoStatusYaml := ` -conditionChecks: - pr-task-3-successful-condition-check-xxyyy: - conditionName: successful-condition-0 -pipelineTaskName: task-3 -status: {} -` - - orphanedPRTask2Yaml := ` -conditionChecks: - pr-task-2-running-condition-check-xxyyy: - conditionName: running-condition-0 -pipelineTaskName: task-2 -` - - orphanedPRTask4Yaml := ` -conditionChecks: - pr-task-4-failed-condition-check-xxyyy: - conditionName: failed-condition-0 -pipelineTaskName: task-4 -` - - withConditions := map[string]*v1beta1.PipelineRunTaskRunStatus{ + noTaskRuns := map[string]*v1beta1.PipelineRunTaskRunStatus{ "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), "pr-task-2-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask2Yaml), "pr-task-3-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask3Yaml), @@ -141,15 +90,13 @@ pipelineTaskName: task-4 foundTaskRun := map[string]*v1beta1.PipelineRunTaskRunStatus{ "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), "pr-task-2-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask2Yaml), - "pr-task-3-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask3NoStatusYaml), + "pr-task-3-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask3Yaml), "pr-task-4-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask4Yaml), } recovered := map[string]*v1beta1.PipelineRunTaskRunStatus{ - "orphaned-taskruns-pr-task-2-xxyyy": mustParsePipelineRunTaskRunStatus(t, orphanedPRTask2Yaml), - "orphaned-taskruns-pr-task-4-xxyyy": mustParsePipelineRunTaskRunStatus(t, orphanedPRTask4Yaml), - "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), - "pr-task-3-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask3NoStatusYaml), + "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), + "pr-task-3-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask3Yaml), } simple := map[string]*v1beta1.PipelineRunTaskRunStatus{ @@ -157,7 +104,7 @@ pipelineTaskName: task-4 } return updateStatusTaskRunsData{ - withConditions: withConditions, + noTaskRuns: noTaskRuns, missingTaskRun: missingTaskRuns, foundTaskRun: foundTaskRun, recovered: recovered, @@ -182,10 +129,10 @@ func TestUpdatePipelineRunStatusFromTaskRuns(t *testing.T) { }, } - prStatusWithCondition := v1beta1.PipelineRunStatus{ + prStatusWithNoTaskRuns := v1beta1.PipelineRunStatus{ Status: prRunningStatus, PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - TaskRuns: taskRunsPRStatusData.withConditions, + TaskRuns: taskRunsPRStatusData.noTaskRuns, }, } @@ -255,9 +202,9 @@ func TestUpdatePipelineRunStatusFromTaskRuns(t *testing.T) { expectedPrStatus: v1beta1.PipelineRunStatus{}, }, { prName: "status-no-taskruns", - prStatus: prStatusWithCondition, + prStatus: prStatusWithNoTaskRuns, trs: nil, - expectedPrStatus: prStatusWithCondition, + expectedPrStatus: prStatusWithNoTaskRuns, }, { prName: "status-nil-taskruns", prStatus: prStatusWithEmptyTaskRuns, @@ -281,24 +228,14 @@ metadata: name: pr-task-3-xxyyy ownerReferences: - uid: 11111111-1111-1111-1111-111111111111 -`), - parse.MustParseTaskRun(t, ` -metadata: - labels: - tekton.dev/conditionCheck: pr-task-3-successful-condition-check-xxyyy - tekton.dev/conditionName: successful-condition - tekton.dev/pipelineTask: task-3 - name: pr-task-3-successful-condition-check-xxyyy - ownerReferences: - - uid: 11111111-1111-1111-1111-111111111111 `), }, expectedPrStatus: prStatusFoundTaskRun, }, { prName: "status-matching-taskruns-pr", - prStatus: prStatusWithCondition, + prStatus: prStatusWithNoTaskRuns, trs: allTaskRuns, - expectedPrStatus: prStatusWithCondition, + expectedPrStatus: prStatusWithNoTaskRuns, }, { prName: "orphaned-taskruns-pr", prStatus: prStatusWithOrphans, @@ -500,7 +437,7 @@ metadata: } type updateStatusChildRefsData struct { - withConditions []v1beta1.ChildStatusReference + noTaskRuns []v1beta1.ChildStatusReference missingTaskRun []v1beta1.ChildStatusReference foundTaskRun []v1beta1.ChildStatusReference missingRun []v1beta1.ChildStatusReference @@ -519,15 +456,6 @@ pipelineTaskName: task-1 prTask2Yaml := ` apiVersion: tekton.dev/v1beta1 -conditionChecks: -- conditionCheckName: pr-task-2-running-condition-check-xxyyy - conditionName: running-condition-0 - status: - check: - running: {} - conditions: - - status: Unknown - type: Succeeded kind: TaskRun name: pr-task-2-xxyyy pipelineTaskName: task-2 @@ -535,16 +463,6 @@ pipelineTaskName: task-2 prTask3Yaml := ` apiVersion: tekton.dev/v1beta1 -conditionChecks: -- conditionCheckName: pr-task-3-successful-condition-check-xxyyy - conditionName: successful-condition-0 - status: - check: - terminated: - exitCode: 0 - conditions: - - status: "True" - type: Succeeded kind: TaskRun name: pr-task-3-xxyyy pipelineTaskName: task-3 @@ -552,16 +470,6 @@ pipelineTaskName: task-3 prTask4Yaml := ` apiVersion: tekton.dev/v1beta1 -conditionChecks: -- conditionCheckName: pr-task-4-failed-condition-check-xxyyy - conditionName: failed-condition-0 - status: - check: - terminated: - exitCode: 127 - conditions: - - status: "False" - type: Succeeded kind: TaskRun name: pr-task-4-xxyyy pipelineTaskName: task-4 @@ -576,35 +484,12 @@ pipelineTaskName: task-6 prTask3NoStatusYaml := ` apiVersion: tekton.dev/v1beta1 -conditionChecks: -- conditionCheckName: pr-task-3-successful-condition-check-xxyyy - conditionName: successful-condition-0 kind: TaskRun name: pr-task-3-xxyyy pipelineTaskName: task-3 ` - orphanedPRTask2Yaml := ` -apiVersion: tekton.dev/v1beta1 -conditionChecks: -- conditionCheckName: pr-task-2-running-condition-check-xxyyy - conditionName: running-condition-0 -kind: TaskRun -name: orphaned-taskruns-pr-task-2-xxyyy -pipelineTaskName: task-2 -` - - orphanedPRTask4Yaml := ` -apiVersion: tekton.dev/v1beta1 -conditionChecks: -- conditionCheckName: pr-task-4-failed-condition-check-xxyyy - conditionName: failed-condition-0 -kind: TaskRun -name: orphaned-taskruns-pr-task-4-xxyyy -pipelineTaskName: task-4 -` - - withConditions := []v1beta1.ChildStatusReference{ + noTaskRuns := []v1beta1.ChildStatusReference{ mustParseChildStatusReference(t, prTask1Yaml), mustParseChildStatusReference(t, prTask2Yaml), mustParseChildStatusReference(t, prTask3Yaml), @@ -636,9 +521,7 @@ pipelineTaskName: task-4 recovered := []v1beta1.ChildStatusReference{ mustParseChildStatusReference(t, prTask1Yaml), - mustParseChildStatusReference(t, orphanedPRTask2Yaml), mustParseChildStatusReference(t, prTask3NoStatusYaml), - mustParseChildStatusReference(t, orphanedPRTask4Yaml), mustParseChildStatusReference(t, prTask6Yaml), } @@ -647,7 +530,7 @@ pipelineTaskName: task-4 simpleRun := []v1beta1.ChildStatusReference{mustParseChildStatusReference(t, prTask6Yaml)} return updateStatusChildRefsData{ - withConditions: withConditions, + noTaskRuns: noTaskRuns, missingTaskRun: missingTaskRun, foundTaskRun: foundTaskRun, missingRun: missingRun, @@ -673,10 +556,10 @@ func TestUpdatePipelineRunStatusFromChildRefs(t *testing.T) { }, } - prStatusWithCondition := v1beta1.PipelineRunStatus{ + prStatusWithNoTaskRuns := v1beta1.PipelineRunStatus{ Status: prRunningStatus, PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: childRefsPRStatusData.withConditions, + ChildReferences: childRefsPRStatusData.noTaskRuns, }, } @@ -774,10 +657,10 @@ metadata: expectedPrStatus: v1beta1.PipelineRunStatus{}, }, { prName: "status-no-taskruns-or-runs", - prStatus: prStatusWithCondition, + prStatus: prStatusWithNoTaskRuns, trs: nil, runs: nil, - expectedPrStatus: prStatusWithCondition, + expectedPrStatus: prStatusWithNoTaskRuns, }, { prName: "status-nil-taskruns", prStatus: prStatusWithEmptyChildRefs, @@ -806,16 +689,6 @@ metadata: name: pr-task-3-xxyyy ownerReferences: - uid: 11111111-1111-1111-1111-111111111111 -`), - parse.MustParseTaskRun(t, ` -metadata: - labels: - tekton.dev/conditionCheck: pr-task-3-successful-condition-check-xxyyy - tekton.dev/conditionName: successful-condition - tekton.dev/pipelineTask: task-3 - name: pr-task-3-successful-condition-check-xxyyy - ownerReferences: - - uid: 11111111-1111-1111-1111-111111111111 `), }, expectedPrStatus: prStatusFoundTaskRun, @@ -823,12 +696,12 @@ metadata: prName: "status-missing-runs", prStatus: prStatusMissingRun, runs: singleRun, - expectedPrStatus: prStatusWithCondition, + expectedPrStatus: prStatusWithNoTaskRuns, }, { prName: "status-matching-taskruns-pr", - prStatus: prStatusWithCondition, + prStatus: prStatusWithNoTaskRuns, trs: allTaskRuns, - expectedPrStatus: prStatusWithCondition, + expectedPrStatus: prStatusWithNoTaskRuns, }, { prName: "orphaned-taskruns-pr", prStatus: prStatusWithOrphans, @@ -1300,42 +1173,12 @@ metadata: - uid: 11111111-1111-1111-1111-111111111111 `), parse.MustParseTaskRun(t, ` -metadata: - labels: - tekton.dev/conditionCheck: pr-task-2-running-condition-check-xxyyy - tekton.dev/conditionName: running-condition - tekton.dev/pipelineTask: task-2 - name: pr-task-2-running-condition-check-xxyyy - ownerReferences: - - uid: 11111111-1111-1111-1111-111111111111 -`), - parse.MustParseTaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-3 name: pr-task-3-xxyyy ownerReferences: - uid: 11111111-1111-1111-1111-111111111111 -`), - parse.MustParseTaskRun(t, ` -metadata: - labels: - tekton.dev/conditionCheck: pr-task-3-successful-condition-check-xxyyy - tekton.dev/conditionName: successful-condition - tekton.dev/pipelineTask: task-3 - name: pr-task-3-successful-condition-check-xxyyy - ownerReferences: - - uid: 11111111-1111-1111-1111-111111111111 -`), - parse.MustParseTaskRun(t, ` -metadata: - labels: - tekton.dev/conditionCheck: pr-task-4-failed-condition-check-xxyyy - tekton.dev/conditionName: failed-condition - tekton.dev/pipelineTask: task-4 - name: pr-task-4-failed-condition-check-xxyyy - ownerReferences: - - uid: 11111111-1111-1111-1111-111111111111 `), } diff --git a/pkg/reconciler/pipelinerun/resources/apply.go b/pkg/reconciler/pipelinerun/resources/apply.go index 9ed5a944830..fb17e486174 100644 --- a/pkg/reconciler/pipelinerun/resources/apply.go +++ b/pkg/reconciler/pipelinerun/resources/apply.go @@ -103,12 +103,6 @@ func ApplyPipelineTaskContexts(pt *v1beta1.PipelineTask) *v1beta1.PipelineTask { func ApplyTaskResults(targets PipelineRunState, resolvedResultRefs ResolvedResultRefs) { stringReplacements := resolvedResultRefs.getStringReplacements() for _, resolvedPipelineRunTask := range targets { - // also make substitution for resolved condition checks - for _, resolvedConditionCheck := range resolvedPipelineRunTask.ResolvedConditionChecks { - pipelineTaskCondition := resolvedConditionCheck.PipelineTaskCondition.DeepCopy() - pipelineTaskCondition.Params = replaceParamValues(pipelineTaskCondition.Params, stringReplacements, nil) - resolvedConditionCheck.PipelineTaskCondition = pipelineTaskCondition - } if resolvedPipelineRunTask.PipelineTask != nil { pipelineTask := resolvedPipelineRunTask.PipelineTask.DeepCopy() pipelineTask.Params = replaceParamValues(pipelineTask.Params, stringReplacements, nil) @@ -156,10 +150,6 @@ func ApplyReplacements(ctx context.Context, p *v1beta1.PipelineSpec, replacement for j := range p.Tasks[i].Workspaces { p.Tasks[i].Workspaces[j].SubPath = substitution.ApplyReplacements(p.Tasks[i].Workspaces[j].SubPath, replacements) } - for j := range p.Tasks[i].Conditions { - c := p.Tasks[i].Conditions[j] - c.Params = replaceParamValues(c.Params, replacements, arrayReplacements) - } p.Tasks[i].WhenExpressions = p.Tasks[i].WhenExpressions.ReplaceWhenExpressionsVariables(replacements, arrayReplacements) p.Tasks[i], replacements, arrayReplacements = propagateParams(ctx, p.Tasks[i], replacements, arrayReplacements) } diff --git a/pkg/reconciler/pipelinerun/resources/apply_test.go b/pkg/reconciler/pipelinerun/resources/apply_test.go index 5e5ab9605bb..013d62e494a 100644 --- a/pkg/reconciler/pipelinerun/resources/apply_test.go +++ b/pkg/reconciler/pipelinerun/resources/apply_test.go @@ -21,11 +21,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/test/diff" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/selection" @@ -347,37 +345,6 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - }, { - name: "parameters in task condition", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewArrayOrString("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, - }, - Tasks: []v1beta1.PipelineTask{{ - Conditions: []v1beta1.PipelineTaskCondition{{ - Params: []v1beta1.Param{ - {Name: "cond-first-param", Value: *v1beta1.NewArrayOrString("$(params.first-param)")}, - {Name: "cond-second-param", Value: *v1beta1.NewArrayOrString("$(params.second-param)")}, - }, - }}, - }}, - }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewArrayOrString("second-value")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewArrayOrString("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, - }, - Tasks: []v1beta1.PipelineTask{{ - Conditions: []v1beta1.PipelineTaskCondition{{ - Params: []v1beta1.Param{ - {Name: "cond-first-param", Value: *v1beta1.NewArrayOrString("default-value")}, - {Name: "cond-second-param", Value: *v1beta1.NewArrayOrString("second-value")}, - }, - }}, - }}, - }, }, { name: "array parameter", original: v1beta1.PipelineSpec{ @@ -756,72 +723,6 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { } } -func TestApplyTaskResults_Conditions(t *testing.T) { - for _, tt := range []struct { - name string - targets PipelineRunState - resolvedResultRefs ResolvedResultRefs - want PipelineRunState - }{{ - name: "Test result substitution in condition parameter", - resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewArrayOrString("aResultValue"), - ResultReference: v1beta1.ResultRef{ - PipelineTask: "aTask", - Result: "aResult", - }, - FromTaskRun: "aTaskRun", - }}, - targets: PipelineRunState{{ - ResolvedConditionChecks: TaskConditionCheckState{{ - ConditionRegisterName: "always-true-0", - ConditionCheckName: "test", - Condition: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "always-true", - }, - Spec: v1alpha1.ConditionSpec{ - Check: v1beta1.Step{}, - }, - }, - ResolvedResources: map[string]*resourcev1alpha1.PipelineResource{}, - PipelineTaskCondition: &v1beta1.PipelineTaskCondition{ - Params: []v1beta1.Param{{ - Name: "cParam", - Value: *v1beta1.NewArrayOrString("Result value --> $(tasks.aTask.results.aResult)"), - }}, - }, - }}, - }}, - want: PipelineRunState{{ - ResolvedConditionChecks: TaskConditionCheckState{{ - ConditionRegisterName: "always-true-0", - ConditionCheckName: "test", - Condition: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "always-true", - }, - Spec: v1alpha1.ConditionSpec{ - Check: v1beta1.Step{}, - }, - }, - ResolvedResources: map[string]*resourcev1alpha1.PipelineResource{}, - PipelineTaskCondition: &v1beta1.PipelineTaskCondition{Params: []v1beta1.Param{{ - Name: "cParam", - Value: *v1beta1.NewArrayOrString("Result value --> aResultValue"), - }}}, - }}, - }}, - }} { - t.Run(tt.name, func(t *testing.T) { - ApplyTaskResults(tt.targets, tt.resolvedResultRefs) - if d := cmp.Diff(tt.want[0].ResolvedConditionChecks, tt.targets[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { - t.Fatalf("ApplyTaskResults() %s", diff.PrintWantGot(d)) - } - }) - } -} - func TestContext(t *testing.T) { ctx := context.Background() for _, tc := range []struct { diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution.go b/pkg/reconciler/pipelinerun/resources/conditionresolution.go deleted file mode 100644 index 66775ba46bd..00000000000 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution.go +++ /dev/null @@ -1,207 +0,0 @@ -/* - * - * Copyright 2019 The Tekton Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package resources - -import ( - "fmt" - - "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/apis/resource" - resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" - "github.com/tektoncd/pipeline/pkg/names" - corev1 "k8s.io/api/core/v1" -) - -const ( - // unnamedCheckNamePrefix is the prefix added to the name of a condition's - // spec.Check.Image if the name is missing - unnamedCheckNamePrefix = "condition-check-" -) - -// GetCondition is a function used to retrieve PipelineConditions. -type GetCondition func(string) (*v1alpha1.Condition, error) - -// ResolvedConditionCheck contains a Condition and its associated ConditionCheck, if it -// exists. ConditionCheck can be nil to represent there being no ConditionCheck (i.e the condition -// has not been evaluated). -type ResolvedConditionCheck struct { - ConditionRegisterName string - PipelineTaskCondition *v1beta1.PipelineTaskCondition - ConditionCheckName string - Condition *v1alpha1.Condition - ConditionCheck *v1beta1.ConditionCheck - // Resolved resources is a map of pipeline resources for this condition - // keyed by the bound resource name (i.e. the name used in PipelineTaskCondition.Resources) - ResolvedResources map[string]*resourcev1alpha1.PipelineResource - - images pipeline.Images -} - -// TaskConditionCheckState is a slice of ResolvedConditionCheck the represents the current execution -// state of Conditions for a Task in a pipeline run. -type TaskConditionCheckState []*ResolvedConditionCheck - -// HasStarted returns true if the conditionChecks for a given object have been created -func (state TaskConditionCheckState) HasStarted() bool { - hasStarted := true - for _, j := range state { - if j.ConditionCheck == nil { - hasStarted = false - } - } - return hasStarted -} - -// IsDone returns true if the status for all conditionChecks for a task indicate that they are done -func (state TaskConditionCheckState) IsDone() bool { - if !state.HasStarted() { - return false - } - isDone := true - for _, rcc := range state { - isDone = isDone && rcc.ConditionCheck.IsDone() - } - return isDone -} - -// IsSuccess returns true if the status for all conditionChecks for a task indicate they have -// completed successfully -func (state TaskConditionCheckState) IsSuccess() bool { - if !state.IsDone() { - return false - } - isSuccess := true - for _, rcc := range state { - isSuccess = isSuccess && rcc.ConditionCheck.IsSuccessful() - } - return isSuccess -} - -// ConditionToTaskSpec creates a TaskSpec from a given Condition -func (rcc *ResolvedConditionCheck) ConditionToTaskSpec() (*v1beta1.TaskSpec, error) { - if rcc.Condition.Spec.Check.Name == "" { - rcc.Condition.Spec.Check.Name = names.SimpleNameGenerator.RestrictLength(unnamedCheckNamePrefix + rcc.Condition.Name) - } - - t := &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{rcc.Condition.Spec.Check}, - Params: rcc.Condition.Spec.Params, - } - - for _, r := range rcc.Condition.Spec.Resources { - if t.Resources == nil { - t.Resources = &v1beta1.TaskResources{} - } - t.Resources.Inputs = append(t.Resources.Inputs, v1beta1.TaskResource{ - ResourceDeclaration: r, - }) - } - - convertParamTemplates(&t.Steps[0], rcc.Condition.Spec.Params) - err := applyResourceSubstitution(&t.Steps[0], rcc.ResolvedResources, rcc.Condition.Spec.Resources, rcc.images) - - if err != nil { - return nil, fmt.Errorf("failed to replace resource template strings %w", err) - } - - return t, nil -} - -// convertParamTemplates replaces all instances of $(params.x) in the container to $(inputs.params.x) for each param name. -func convertParamTemplates(step *v1beta1.Step, params []v1beta1.ParamSpec) { - replacements := make(map[string]string) - for _, p := range params { - replacements[fmt.Sprintf("params.%s", p.Name)] = fmt.Sprintf("$(inputs.params.%s)", p.Name) - v1beta1.ApplyStepReplacements(step, replacements, map[string][]string{}) - } - - v1beta1.ApplyStepReplacements(step, replacements, map[string][]string{}) -} - -// applyResourceSubstitution applies the substitution from values in resources which are referenced -// in spec as subitems of the replacementStr. -func applyResourceSubstitution(step *v1beta1.Step, resolvedResources map[string]*resourcev1alpha1.PipelineResource, conditionResources []v1beta1.ResourceDeclaration, images pipeline.Images) error { - replacements := make(map[string]string) - for _, cr := range conditionResources { - if rSpec, ok := resolvedResources[cr.Name]; ok { - r, err := resource.FromType(cr.Name, rSpec, images) - if err != nil { - return fmt.Errorf("error trying to create resource: %w", err) - } - for k, v := range r.Replacements() { - replacements[fmt.Sprintf("resources.%s.%s", cr.Name, k)] = v - } - replacements[fmt.Sprintf("resources.%s.path", cr.Name)] = v1beta1.InputResourcePath(cr) - } - } - v1beta1.ApplyStepReplacements(step, replacements, map[string][]string{}) - return nil -} - -// NewConditionCheckStatus creates a ConditionCheckStatus from a ConditionCheck -func (rcc *ResolvedConditionCheck) NewConditionCheckStatus() *v1beta1.ConditionCheckStatus { - var checkStep corev1.ContainerState - trs := rcc.ConditionCheck.Status - for _, s := range trs.Steps { - if s.Name == rcc.Condition.Spec.Check.Name { - checkStep = s.ContainerState - break - } - } - - return &v1beta1.ConditionCheckStatus{ - Status: trs.Status, - ConditionCheckStatusFields: v1beta1.ConditionCheckStatusFields{ - PodName: trs.PodName, - StartTime: trs.StartTime, - CompletionTime: trs.CompletionTime, - Check: checkStep, - }, - } -} - -// ToTaskResourceBindings converts pipeline resources in a ResolvedConditionCheck to a list of TaskResourceBinding -// and returns them. -func (rcc *ResolvedConditionCheck) ToTaskResourceBindings() []v1beta1.TaskResourceBinding { - var trb []v1beta1.TaskResourceBinding - - for name, r := range rcc.ResolvedResources { - tr := v1beta1.TaskResourceBinding{ - PipelineResourceBinding: v1beta1.PipelineResourceBinding{ - Name: name, - }, - } - if r.SelfLink != "" { - tr.ResourceRef = &v1beta1.PipelineResourceRef{ - Name: r.Name, - APIVersion: r.APIVersion, - } - } else if r.Spec.Type != "" { - tr.ResourceSpec = &resourcev1alpha1.PipelineResourceSpec{ - Type: r.Spec.Type, - Params: r.Spec.Params, - SecretParams: r.Spec.SecretParams, - } - } - trb = append(trb, tr) - } - - return trb -} diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go b/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go deleted file mode 100644 index 33bfb4349b1..00000000000 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go +++ /dev/null @@ -1,377 +0,0 @@ -/* - * - * Copyright 2019 The Tekton Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package resources - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" - "github.com/tektoncd/pipeline/test/diff" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -var c = &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "conditionname", - }, -} - -var notStartedState = TaskConditionCheckState{{ - ConditionCheckName: "foo", - Condition: c, -}} - -var runningState = TaskConditionCheckState{{ - ConditionCheckName: "foo", - Condition: c, - ConditionCheck: &v1beta1.ConditionCheck{ - ObjectMeta: metav1.ObjectMeta{ - Name: "running-condition-check", - }, - }, -}} - -var successState = TaskConditionCheckState{{ - ConditionCheckName: "foo", - Condition: c, - ConditionCheck: &v1beta1.ConditionCheck{ - ObjectMeta: metav1.ObjectMeta{ - Name: "successful-condition-check", - }, - Spec: v1beta1.TaskRunSpec{}, - Status: v1beta1.TaskRunStatus{ - Status: duckv1beta1.Status{ - Conditions: []apis.Condition{{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionTrue, - }}, - }, - }, - }, -}} - -var failedState = TaskConditionCheckState{{ - ConditionCheckName: "foo", - Condition: c, - ConditionCheck: &v1beta1.ConditionCheck{ - ObjectMeta: metav1.ObjectMeta{ - Name: "failed-condition-check", - }, - Spec: v1beta1.TaskRunSpec{}, - Status: v1beta1.TaskRunStatus{ - Status: duckv1beta1.Status{ - Conditions: []apis.Condition{{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionFalse, - }}, - }, - }, - }, -}} - -func TestTaskConditionCheckState_HasStarted(t *testing.T) { - tcs := []struct { - name string - state TaskConditionCheckState - want bool - }{{ - name: "no-condition-checks", - state: notStartedState, - want: false, - }, { - name: "running-condition-check", - state: runningState, - want: true, - }, { - name: "successful-condition-check", - state: successState, - want: true, - }, { - name: "failed-condition-check", - state: failedState, - want: true, - }} - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - got := tc.state.HasStarted() - if got != tc.want { - t.Errorf("Expected HasStarted to be %v but got %v for %s", tc.want, got, tc.name) - } - }) - } -} - -func TestTaskConditionCheckState_IsComplete(t *testing.T) { - tcs := []struct { - name string - state TaskConditionCheckState - want bool - }{{ - name: "no-condition-checks", - state: notStartedState, - want: false, - }, { - name: "running-condition-check", - state: runningState, - want: false, - }, { - name: "successful-condition-check", - state: successState, - want: true, - }, { - name: "failed-condition-check", - state: failedState, - want: true, - }} - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - got := tc.state.IsDone() - if got != tc.want { - t.Errorf("Expected IsComplete to be %v but got %v for %s", tc.want, got, tc.name) - } - }) - } -} - -func TestTaskConditionCheckState_IsSuccess(t *testing.T) { - tcs := []struct { - name string - state TaskConditionCheckState - want bool - }{{ - name: "no-condition-checks", - state: notStartedState, - want: false, - }, { - name: "running-condition-check", - state: runningState, - want: false, - }, { - name: "successful-condition-check", - state: successState, - want: true, - }, { - name: "failed-condition-check", - state: failedState, - want: false, - }} - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - got := tc.state.IsSuccess() - if got != tc.want { - t.Errorf("Expected IsSuccess to be %v but got %v for %s", tc.want, got, tc.name) - } - }) - } -} - -func TestResolvedConditionCheck_ConditionToTaskSpec(t *testing.T) { - tcs := []struct { - name string - cond *v1alpha1.Condition - resolvedResources map[string]*resourcev1alpha1.PipelineResource - want v1beta1.TaskSpec - }{{ - name: "user-provided-container-name", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "name", - }, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Name: "foo", - Image: "ubuntu", - }, - }, - }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Name: "foo", - Image: "ubuntu", - }}, - }, - }, { - name: "default-container-name", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "bar", - }, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Name: "", - Image: "ubuntu", - }, - }, - }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Name: "condition-check-bar", - Image: "ubuntu", - }}, - }, - }, { - name: "very-long-condition-name", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "very-very-very-very-very-very-very-very-very-very-very-long-name", - }, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Name: "", - Image: "ubuntu", - }, - }, - }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - // Shortened via: names.SimpleNameGenerator.RestrictLength - Name: "condition-check-very-very-very-very-very-very-very-very-very-ve", - Image: "ubuntu", - }}, - }, - }, { - name: "with-input-params", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "bar", - }, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Name: "$(params.name)", - Image: "$(params.img)", - WorkingDir: "$(params.not.replaced)", - }, - Params: []v1alpha1.ParamSpec{ - { - Name: "name", - Type: v1beta1.ParamTypeString, - }, - { - Name: "img", - Type: v1beta1.ParamTypeString, - }, - }, - }, - }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Name: "$(inputs.params.name)", - Image: "$(inputs.params.img)", - WorkingDir: "$(params.not.replaced)", - }}, - Params: []v1beta1.ParamSpec{{ - Name: "name", - Type: "string", - }, { - Name: "img", - Type: "string", - }}, - }, - }, { - name: "with-resources", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "bar", - }, - Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{ - Name: "name", - Image: "ubuntu", - Args: []string{"$(resources.git-resource.revision)"}, - }, - Resources: []v1alpha1.ResourceDeclaration{{ - Name: "git-resource", - Type: resourcev1alpha1.PipelineResourceTypeGit, - }}, - }, - }, - resolvedResources: map[string]*resourcev1alpha1.PipelineResource{ - "git-resource": { - ObjectMeta: metav1.ObjectMeta{ - Name: "git-resource", - }, - Spec: resourcev1alpha1.PipelineResourceSpec{ - Type: resourcev1alpha1.PipelineResourceTypeGit, - Params: []resourcev1alpha1.ResourceParam{{ - Name: "revision", - Value: "master", - }}, - }, - }, - }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Name: "name", - Image: "ubuntu", - Args: []string{"master"}, - }}, - Resources: &v1beta1.TaskResources{ - Inputs: []v1beta1.TaskResource{{ - ResourceDeclaration: v1beta1.ResourceDeclaration{ - Name: "git-resource", - Type: "git", - }}}, - }, - }, - }} - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - rcc := &ResolvedConditionCheck{Condition: tc.cond, ResolvedResources: tc.resolvedResources} - got, err := rcc.ConditionToTaskSpec() - if err != nil { - t.Errorf("Unexpected error when converting condition to task spec: %v", err) - } - - if d := cmp.Diff(&tc.want, got); d != "" { - t.Errorf("TaskSpec generated from Condition is unexpected %s", diff.PrintWantGot(d)) - } - }) - } -} - -func TestResolvedConditionCheck_ToTaskResourceBindings(t *testing.T) { - rcc := ResolvedConditionCheck{ - ResolvedResources: map[string]*resourcev1alpha1.PipelineResource{ - "git-resource": { - ObjectMeta: metav1.ObjectMeta{ - Name: "some-repo", - }, - }, - }, - } - - expected := []v1beta1.TaskResourceBinding{{ - PipelineResourceBinding: v1beta1.PipelineResourceBinding{ - Name: "git-resource", - }, - }} - - if d := cmp.Diff(expected, rcc.ToTaskResourceBindings()); d != "" { - t.Errorf("Did not get expected task resource binding from condition %s", diff.PrintWantGot(d)) - } -} diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index a24352e5c94..30990e0259b 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -20,7 +20,6 @@ import ( "context" "errors" "fmt" - "strconv" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" @@ -56,16 +55,6 @@ func (e *TaskNotFoundError) Error() string { return fmt.Sprintf("Couldn't retrieve Task %q: %s", e.Name, e.Msg) } -// ConditionNotFoundError is used to track failures to the -type ConditionNotFoundError struct { - Name string - Msg string -} - -func (e *ConditionNotFoundError) Error() string { - return fmt.Sprintf("Couldn't retrieve Condition %q: %s", e.Name, e.Msg) -} - // ResolvedPipelineRunTask contains a Task and its associated TaskRun, if it // exists. TaskRun can be nil to represent there being no TaskRun. type ResolvedPipelineRunTask struct { @@ -78,7 +67,6 @@ type ResolvedPipelineRunTask struct { PipelineTask *v1beta1.PipelineTask ResolvedTaskResources *resources.ResolvedTaskResources // ConditionChecks ~~TaskRuns but for evaling conditions - ResolvedConditionChecks TaskConditionCheckState // Could also be a TaskRun or maybe just a Pod? } // IsDone returns true only if the task is skipped, succeeded or failed @@ -223,8 +211,6 @@ func (t *ResolvedPipelineRunTask) skip(facts *PipelineRunFacts) TaskSkipStatus { skippingReason = v1beta1.GracefullyStoppedSkip case t.skipBecauseParentTaskWasSkipped(facts): skippingReason = v1beta1.ParentTasksSkip - case t.skipBecauseConditionsFailed(): - skippingReason = v1beta1.ConditionsSkip case t.skipBecauseResultReferencesAreMissing(facts): skippingReason = v1beta1.MissingResultsSkip case t.skipBecauseWhenExpressionsEvaluatedToFalse(facts): @@ -256,17 +242,6 @@ func (t *ResolvedPipelineRunTask) Skip(facts *PipelineRunFacts) TaskSkipStatus { return facts.SkipCache[t.PipelineTask.Name] } -// skipBecauseConditionsFailed checks that the task has Conditions which have completed evaluating -// it returns true if any of the Conditions fails -func (t *ResolvedPipelineRunTask) skipBecauseConditionsFailed() bool { - if len(t.ResolvedConditionChecks) > 0 { - if t.ResolvedConditionChecks.IsDone() && !t.ResolvedConditionChecks.IsSuccess() { - return true - } - } - return false -} - // skipBecauseWhenExpressionsEvaluatedToFalse confirms that the when expressions have completed evaluating, and // it returns true if any of the when expressions evaluate to false func (t *ResolvedPipelineRunTask) skipBecauseWhenExpressionsEvaluatedToFalse(facts *PipelineRunFacts) bool { @@ -471,7 +446,6 @@ func ResolvePipelineRunTask( getTask resources.GetTask, getTaskRun resources.GetTaskRun, getRun GetRun, - getCondition GetCondition, task v1beta1.PipelineTask, providedResources map[string]*resourcev1alpha1.PipelineResource, ) (*ResolvedPipelineRunTask, error) { @@ -513,15 +487,6 @@ func ResolvePipelineRunTask( } rprt.ResolvedTaskResources = rtr - - // Get all conditions that this pipelineTask will be using, if any - if len(task.Conditions) > 0 { - rcc, err := resolveConditionChecks(&task, pipelineRun.Status.TaskRuns, pipelineRun.Status.ChildReferences, rprt.TaskRunName, getTaskRun, getCondition, providedResources) - if err != nil { - return nil, err - } - rprt.ResolvedConditionChecks = rcc - } } return &rprt, nil } @@ -561,29 +526,6 @@ func resolveTask(ctx context.Context, taskRun *v1beta1.TaskRun, getTask resource return spec, taskName, kind, err } -// getConditionCheckName should return a unique name for a `ConditionCheck` if one has not already been defined, and the existing one otherwise. -func getConditionCheckName(taskRunStatus map[string]*v1beta1.PipelineRunTaskRunStatus, childRefs []v1beta1.ChildStatusReference, trName, conditionRegisterName string) string { - for _, cr := range childRefs { - if cr.Name == trName { - for _, cc := range cr.ConditionChecks { - if cc.ConditionName == conditionRegisterName { - return cc.ConditionCheckName - } - } - } - } - trStatus, ok := taskRunStatus[trName] - if ok && trStatus.ConditionChecks != nil { - for k, v := range trStatus.ConditionChecks { - // TODO(1022): Should we allow multiple conditions of the same type? - if conditionRegisterName == v.ConditionName { - return k - } - } - } - return kmeta.ChildName(trName, fmt.Sprintf("-%s", conditionRegisterName)) -} - // GetTaskRunName should return a unique name for a `TaskRun` if one has not already been defined, and the existing one otherwise. func GetTaskRunName(taskRunsStatus map[string]*v1beta1.PipelineRunTaskRunStatus, childRefs []v1beta1.ChildStatusReference, ptName, prName string) string { for _, cr := range childRefs { @@ -619,54 +561,6 @@ func getRunName(runsStatus map[string]*v1beta1.PipelineRunRunStatus, childRefs [ return kmeta.ChildName(prName, fmt.Sprintf("-%s", ptName)) } -func resolveConditionChecks(pt *v1beta1.PipelineTask, taskRunStatus map[string]*v1beta1.PipelineRunTaskRunStatus, childRefs []v1beta1.ChildStatusReference, taskRunName string, getTaskRun resources.GetTaskRun, getCondition GetCondition, providedResources map[string]*resourcev1alpha1.PipelineResource) ([]*ResolvedConditionCheck, error) { - rccs := []*ResolvedConditionCheck{} - for i := range pt.Conditions { - ptc := pt.Conditions[i] - cName := ptc.ConditionRef - crName := fmt.Sprintf("%s-%s", cName, strconv.Itoa(i)) - c, err := getCondition(cName) - if err != nil { - return nil, &ConditionNotFoundError{ - Name: cName, - Msg: err.Error(), - } - } - conditionCheckName := getConditionCheckName(taskRunStatus, childRefs, taskRunName, crName) - // TODO(#3133): Also handle Custom Task Runs (getRun here) - cctr, err := getTaskRun(conditionCheckName) - if err != nil { - if !kerrors.IsNotFound(err) { - return nil, fmt.Errorf("error retrieving ConditionCheck %s for taskRun name %s : %w", conditionCheckName, taskRunName, err) - } - } - conditionResources := map[string]*resourcev1alpha1.PipelineResource{} - for _, declared := range ptc.Resources { - if r, ok := providedResources[declared.Resource]; ok { - conditionResources[declared.Name] = r - } else { - for _, resource := range c.Spec.Resources { - if declared.Name == resource.Name && !resource.Optional { - return nil, fmt.Errorf("resources %s missing for condition %s in pipeline task %s", declared.Resource, cName, pt.Name) - } - } - } - } - - rcc := ResolvedConditionCheck{ - ConditionRegisterName: crName, - Condition: c, - ConditionCheckName: conditionCheckName, - ConditionCheck: v1beta1.NewConditionCheck(cctr), - PipelineTaskCondition: &ptc, - ResolvedResources: conditionResources, - } - - rccs = append(rccs, &rcc) - } - return rccs, nil -} - // resolvePipelineTaskResources matches PipelineResources referenced by pt inputs and outputs with the // providedResources and returns an instance of ResolvedTaskResources. func resolvePipelineTaskResources(pt v1beta1.PipelineTask, ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind, providedResources map[string]*resourcev1alpha1.PipelineResource) (*resources.ResolvedTaskResources, error) { diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go index 0c38ba4af19..0ae6947f3a6 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go @@ -72,10 +72,7 @@ var pts = []v1beta1.PipelineTask{{ Retries: 2, }, { Name: "mytask6", - TaskRef: &v1beta1.TaskRef{Name: "taskWithConditions"}, - Conditions: []v1beta1.PipelineTaskCondition{{ - ConditionRef: "always-true", - }}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, }, { Name: "mytask7", TaskRef: &v1beta1.TaskRef{Name: "taskWithOneParent"}, @@ -174,25 +171,6 @@ var runs = []v1alpha1.Run{{ Spec: v1alpha1.RunSpec{}, }} -var condition = v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "always-true", - }, - Spec: v1alpha1.ConditionSpec{ - Check: v1beta1.Step{}, - }, -} - -var conditionChecks = []v1beta1.TaskRun{{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: "namespace", - Name: "always-true", - }, - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{}, - }, -}} - var gitDeclaredResource = v1beta1.PipelineDeclaredResource{ Name: "git-resource", Type: resourcev1alpha1.PipelineResourceTypeGit, @@ -447,166 +425,6 @@ var oneRunFailedState = PipelineRunState{{ Run: nil, }} -var successTaskConditionCheckState = TaskConditionCheckState{{ - ConditionCheckName: "myconditionCheck", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(makeSucceeded(conditionChecks[0])), -}} - -var failedTaskConditionCheckState = TaskConditionCheckState{{ - ConditionCheckName: "myconditionCheck", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(makeFailed(conditionChecks[0])), -}} - -var conditionCheckSuccessNoTaskStartedState = PipelineRunState{{ - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: successTaskConditionCheckState, -}} - -var conditionCheckStartedState = PipelineRunState{{ - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: TaskConditionCheckState{{ - ConditionCheckName: "myconditionCheck", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(makeStarted(conditionChecks[0])), - }}, -}} - -var conditionCheckFailedWithNoOtherTasksState = PipelineRunState{{ - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: failedTaskConditionCheckState, -}} - -var conditionCheckFailedWithOthersPassedState = PipelineRunState{{ - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: failedTaskConditionCheckState, -}, - { - PipelineTask: &pts[0], - TaskRunName: "pipelinerun-mytask1", - TaskRun: makeSucceeded(trs[0]), - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - }, -} - -var conditionCheckFailedWithOthersFailedState = PipelineRunState{{ - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: failedTaskConditionCheckState, -}, - { - PipelineTask: &pts[0], - TaskRunName: "pipelinerun-mytask1", - TaskRun: makeFailed(trs[0]), - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - }, -} - -// skipped == condition check failure -// task -> parent.cc skipped -var taskWithParentSkippedState = PipelineRunState{{ - TaskRunName: "taskrunName", - PipelineTask: &pts[5], - ResolvedConditionChecks: failedTaskConditionCheckState, -}, { - TaskRunName: "childtaskrun", - PipelineTask: &pts[6], -}} - -// task -> 2 parents -> one of which is skipped -var taskWithMultipleParentsSkippedState = PipelineRunState{{ - TaskRunName: "task0taskrun", - PipelineTask: &pts[0], - TaskRun: makeSucceeded(trs[0]), // This parent is successful -}, { - TaskRunName: "taskrunName", - PipelineTask: &pts[5], - ResolvedConditionChecks: failedTaskConditionCheckState, // This one was skipped -}, { - TaskRunName: "childtaskrun", - PipelineTask: &pts[7], // This should also be skipped. -}} - -// task -> parent -> grandparent is a skipped task -var taskWithGrandParentSkippedState = PipelineRunState{{ - TaskRunName: "task0taskrun", - PipelineTask: &pts[0], - TaskRun: makeSucceeded(trs[0]), // Passed -}, { - TaskRunName: "skippedTaskRun", - PipelineTask: &pts[5], - ResolvedConditionChecks: failedTaskConditionCheckState, // Skipped -}, { - TaskRunName: "anothertaskrun", - PipelineTask: &pts[7], // Should be skipped -}, { - TaskRunName: "taskrun", - PipelineTask: &pts[8], // Should also be skipped -}} - -var taskWithGrandParentsOneFailedState = PipelineRunState{{ - TaskRunName: "task0taskrun", - PipelineTask: &pts[0], - TaskRun: makeSucceeded(trs[0]), // Passed -}, { - TaskRunName: "skippedTaskRun", - PipelineTask: &pts[5], - TaskRun: makeFailed(trs[0]), // Failed; so pipeline should fail - ResolvedConditionChecks: successTaskConditionCheckState, -}, { - TaskRunName: "anothertaskrun", - PipelineTask: &pts[7], -}, { - TaskRunName: "taskrun", - PipelineTask: &pts[8], -}} - -var taskWithGrandParentsOneNotRunState = PipelineRunState{{ - TaskRunName: "task0taskrun", - PipelineTask: &pts[0], - TaskRun: makeSucceeded(trs[0]), // Passed -}, { - TaskRunName: "skippedTaskRun", - PipelineTask: &pts[5], - // No TaskRun so task has not been run, and pipeline should be running - ResolvedConditionChecks: successTaskConditionCheckState, -}, { - TaskRunName: "anothertaskrun", - PipelineTask: &pts[7], -}, { - TaskRunName: "taskrun", - PipelineTask: &pts[8], -}} - var taskCancelled = PipelineRunState{{ PipelineTask: &pts[4], TaskRunName: "pipelinerun-mytask1", @@ -697,114 +515,6 @@ func TestIsSkipped(t *testing.T) { state PipelineRunState expected map[string]bool }{{ - name: "tasks-condition-passed", - state: PipelineRunState{{ - PipelineTask: &pts[0], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: successTaskConditionCheckState, - }}, - expected: map[string]bool{ - "mytask1": false, - }, - }, { - name: "tasks-condition-failed", - state: PipelineRunState{{ - PipelineTask: &pts[0], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: failedTaskConditionCheckState, - }}, - expected: map[string]bool{ - "mytask1": true, - }, - }, { - name: "tasks-multiple-conditions-passed-failed", - state: PipelineRunState{{ - PipelineTask: &pts[0], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: TaskConditionCheckState{{ - ConditionCheckName: "myconditionCheck", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(makeFailed(conditionChecks[0])), - }, { - ConditionCheckName: "myconditionCheck", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(makeSucceeded(conditionChecks[0])), - }}, - }}, - expected: map[string]bool{ - "mytask1": true, - }, - }, { - name: "tasks-condition-running", - state: conditionCheckStartedState, - expected: map[string]bool{ - "mytask6": false, - }, - }, { - name: "tasks-parent-condition-passed", - state: PipelineRunState{{ - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: successTaskConditionCheckState, - }, { - PipelineTask: &pts[6], - }}, - expected: map[string]bool{ - "mytask7": false, - }, - }, { - name: "tasks-parent-condition-failed", - state: PipelineRunState{{ - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: failedTaskConditionCheckState, - }, { - PipelineTask: &pts[6], - }}, - expected: map[string]bool{ - "mytask7": true, - }, - }, { - name: "tasks-parent-condition-running", - state: PipelineRunState{{ - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: TaskConditionCheckState{{ - ConditionCheckName: "myconditionCheck", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(makeStarted(conditionChecks[0])), - }}, - }, { - PipelineTask: &pts[6], - }}, - expected: map[string]bool{ - "mytask7": false, - }, - }, { name: "tasks-failed", state: oneFailedState, expected: map[string]bool{ @@ -1171,57 +881,6 @@ func TestIsSkipped(t *testing.T) { "mytask22": true, "mytask23": true, }, - }, { - name: "tasks-parent-condition-failed-parent-when-expressions-passed", - state: PipelineRunState{{ - // skipped because conditions fail - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: failedTaskConditionCheckState, - }, { - // skipped because when expressions evaluate to false - PipelineTask: &pts[10], - TaskRunName: "pipelinerun-guardedtask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - }, { - // skipped because of parent task guarded using conditions is skipped, regardless of another parent task - // being guarded with when expressions - PipelineTask: &v1beta1.PipelineTask{ - Name: "mytask18", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - RunAfter: []string{"mytask6", "mytask11"}, - }, - TaskRunName: "pipelinerun-ordering-dependent-task-1", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - }, { - // not skipped regardless of its parent task being skipped because when expressions - PipelineTask: &v1beta1.PipelineTask{ - Name: "mytask19", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - RunAfter: []string{"mytask11"}, - }, - TaskRunName: "pipelinerun-ordering-dependent-task-2", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - }}, - expected: map[string]bool{ - "mytask6": true, - "mytask11": true, - "mytask18": true, - "mytask19": false, - }, }} { t.Run(tc.name, func(t *testing.T) { d, err := dagFromState(tc.state) @@ -1421,64 +1080,6 @@ func TestSkipBecauseParentTaskWasSkipped(t *testing.T) { state PipelineRunState expected map[string]bool }{{ - name: "tasks-parent-condition-passed", - state: PipelineRunState{{ - // parent task that has a condition that passed - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: successTaskConditionCheckState, - }, { - // child task that's not skipped (conditional parent task was not skipped) - PipelineTask: &pts[6], - }}, - expected: map[string]bool{ - "mytask7": false, - }, - }, { - name: "tasks-parent-condition-failed", - state: PipelineRunState{{ - // parent task that has a condition that failed and is skipped - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: failedTaskConditionCheckState, - }, { - // child task skipped because its parent has a condition that failed (and was skipped) - PipelineTask: &pts[6], - }}, - expected: map[string]bool{ - "mytask7": true, - }, - }, { - name: "tasks-parent-condition-running", - state: PipelineRunState{{ - // parent task has a condition that's still running - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: TaskConditionCheckState{{ - ConditionCheckName: "myconditionCheck", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(makeStarted(conditionChecks[0])), - }}, - }, { - // child task not skipped because parent is not yet done - PipelineTask: &pts[6], - }}, - expected: map[string]bool{ - "mytask7": false, - }, - }, { name: "when-expression-task-but-without-parent-done", state: PipelineRunState{{ // parent task has when expressions but is not yet done @@ -1568,58 +1169,6 @@ func TestSkipBecauseParentTaskWasSkipped(t *testing.T) { "mytask18": false, "mytask19": false, }, - }, { - name: "tasks-parent-condition-failed-parent-when-expressions-passed", - state: PipelineRunState{{ - // parent task is skipped because conditions fail, not because of its parent tasks - PipelineTask: &pts[5], - TaskRunName: "pipelinerun-conditionaltask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - ResolvedConditionChecks: failedTaskConditionCheckState, - }, { - // parent task is skipped because when expressions evaluate to false, not because of its parent tasks - PipelineTask: &pts[10], - TaskRunName: "pipelinerun-guardedtask", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - }, { - // skipped because of parent task guarded using conditions is skipped, regardless of another parent task - // being guarded with when expressions that are scoped to task - PipelineTask: &v1beta1.PipelineTask{ - Name: "mytask18", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - RunAfter: []string{"mytask6", "mytask11"}, - }, - TaskRunName: "pipelinerun-ordering-dependent-task-1", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - }, { - // child task is not skipped regardless of its parent task being skipped due to when expressions evaluating - // to false, because when expressions are scoped to task only - PipelineTask: &v1beta1.PipelineTask{ - Name: "mytask19", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - RunAfter: []string{"mytask11"}, - }, - TaskRunName: "pipelinerun-ordering-dependent-task-2", - TaskRun: nil, - ResolvedTaskResources: &resources.ResolvedTaskResources{ - TaskSpec: &task.Spec, - }, - }}, - expected: map[string]bool{ - "mytask6": false, - "mytask11": false, - "mytask18": true, - "mytask19": false, - }, }} { t.Run(tc.name, func(t *testing.T) { d, err := dagFromState(tc.state) @@ -1820,11 +1369,10 @@ func TestResolvePipelineRun(t *testing.T) { // that is not done as part of Run resolution getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } pipelineState := PipelineRunState{} for _, task := range p.Spec.Tasks { - ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, task, providedResources) + ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, task, providedResources) if err != nil { t.Fatalf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err) } @@ -1910,7 +1458,6 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) { } return nil, kerrors.NewNotFound(v1beta1.Resource("run"), name) } - nopGetCondition := func(string) (*v1alpha1.Condition, error) { return nil, errors.New("GetCondition should not be called") } pipelineState := PipelineRunState{} ctx := context.Background() cfg := config.NewStore(logtesting.TestLogger(t)) @@ -1922,7 +1469,7 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) { }) ctx = cfg.ToContext(ctx) for _, task := range pts { - ps, err := ResolvePipelineRunTask(ctx, pr, nopGetTask, nopGetTaskRun, getRun, nopGetCondition, task, nil) + ps, err := ResolvePipelineRunTask(ctx, pr, nopGetTask, nopGetTaskRun, getRun, task, nil) if err != nil { t.Fatalf("ResolvePipelineRunTask: %v", err) } @@ -1965,7 +1512,6 @@ func TestResolvePipelineRun_PipelineTaskHasNoResources(t *testing.T) { getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", @@ -1973,7 +1519,7 @@ func TestResolvePipelineRun_PipelineTaskHasNoResources(t *testing.T) { } pipelineState := PipelineRunState{} for _, task := range pts { - ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, task, providedResources) + ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, task, providedResources) if err != nil { t.Errorf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err) } @@ -2010,15 +1556,12 @@ func TestResolvePipelineRun_TaskDoesntExist(t *testing.T) { getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, kerrors.NewNotFound(v1beta1.Resource("taskrun"), name) } - getCondition := func(name string) (*v1alpha1.Condition, error) { - return nil, nil - } pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, } - _, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, pt, providedResources) + _, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt, providedResources) switch err := err.(type) { case nil: t.Fatalf("Expected error getting non-existent Tasks for Pipeline %s but got none", p.Name) @@ -2076,9 +1619,6 @@ func TestResolvePipelineRun_ResourceBindingsDontExist(t *testing.T) { getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { - return nil, nil - } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -2088,7 +1628,7 @@ func TestResolvePipelineRun_ResourceBindingsDontExist(t *testing.T) { }, } pipelineState := PipelineRunState{} - ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, tt.p.Spec.Tasks[0], providedResources) + ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, tt.p.Spec.Tasks[0], providedResources) if err == nil { t.Fatalf("Expected error when bindings are in incorrect state for Pipeline %s but got none: %s", p.ObjectMeta.Name, err) } @@ -2149,8 +1689,7 @@ func TestResolvePipelineRun_withExistingTaskRuns(t *testing.T) { // that is not done as part of Run resolution getTask := func(_ context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } - resolvedTask, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, p.Spec.Tasks[0], providedResources) + resolvedTask, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, p.Spec.Tasks[0], providedResources) if err != nil { t.Fatalf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err) } @@ -2216,9 +1755,8 @@ func TestResolvedPipelineRun_PipelineTaskHasOptionalResources(t *testing.T) { return taskWithOptionalResourcesDeprecated, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } - actualTask, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, p.Spec.Tasks[0], providedResources) + actualTask, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, p.Spec.Tasks[0], providedResources) if err != nil { t.Fatalf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err) } @@ -2243,391 +1781,6 @@ func TestResolvedPipelineRun_PipelineTaskHasOptionalResources(t *testing.T) { } } -func TestResolveConditionChecks(t *testing.T) { - names.TestingSeed() - ccName := "pipelinerun-mytask1-always-true" - - cc := &v1beta1.TaskRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: ccName, - }, - } - - ptc := v1beta1.PipelineTaskCondition{ - ConditionRef: "always-true", - } - - pt := v1beta1.PipelineTask{ - Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Conditions: []v1beta1.PipelineTaskCondition{ptc}, - } - providedResources := map[string]*resourcev1alpha1.PipelineResource{} - - getTask := func(_ context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } - pr := v1beta1.PipelineRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pipelinerun", - }, - } - - for _, tc := range []struct { - name string - getTaskRun resources.GetTaskRun - expectedConditionCheck TaskConditionCheckState - }{{ - name: "conditionCheck exists", - getTaskRun: func(name string) (*v1beta1.TaskRun, error) { - switch name { - case "pipelinerun-mytask1-always-true-0": - return cc, nil - case "pipelinerun-mytask1": - return &trs[0], nil - default: - return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) - } - }, - expectedConditionCheck: TaskConditionCheckState{{ - ConditionRegisterName: "always-true-0", - ConditionCheckName: "pipelinerun-mytask1-always-true-0", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(cc), - PipelineTaskCondition: &ptc, - ResolvedResources: providedResources, - }}, - }, { - name: "conditionCheck doesn't exist", - getTaskRun: func(name string) (*v1beta1.TaskRun, error) { - if name == "pipelinerun-mytask1-always-true-0" { - return nil, nil - } else if name == "pipelinerun-mytask1" { - return &trs[0], nil - } - return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) - }, - expectedConditionCheck: TaskConditionCheckState{{ - ConditionRegisterName: "always-true-0", - ConditionCheckName: "pipelinerun-mytask1-always-true-0", - Condition: &condition, - PipelineTaskCondition: &ptc, - ResolvedResources: providedResources, - }}, - }} { - t.Run(tc.name, func(t *testing.T) { - ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, tc.getTaskRun, nopGetRun, getCondition, pt, providedResources) - if err != nil { - t.Fatalf("Did not expect error when resolving PipelineRun without Conditions: %v", err) - } - pipelineState := PipelineRunState{ps} - - if d := cmp.Diff(tc.expectedConditionCheck, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { - t.Fatalf("ConditionChecks did not resolve as expected for case %s %s", tc.name, diff.PrintWantGot(d)) - } - }) - } -} - -func TestResolveConditionChecks_MultipleConditions(t *testing.T) { - names.TestingSeed() - ccName1 := "pipelinerun-mytask1-always-true" - ccName2 := "pipelinerun-mytask1-always-true" - - cc1 := &v1beta1.TaskRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: ccName1, - }, - } - - cc2 := &v1beta1.TaskRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: ccName2, - }, - } - - ptc1 := v1beta1.PipelineTaskCondition{ - ConditionRef: "always-true", - Params: []v1beta1.Param{{ - Name: "path", Value: *v1beta1.NewArrayOrString("$(params.path)"), - }, { - Name: "image", Value: *v1beta1.NewArrayOrString("$(params.image)"), - }}, - } - - ptc2 := v1beta1.PipelineTaskCondition{ - ConditionRef: "always-true", - Params: []v1beta1.Param{{ - Name: "path", Value: *v1beta1.NewArrayOrString("$(params.path-test)"), - }, { - Name: "image", Value: *v1beta1.NewArrayOrString("$(params.image-test)"), - }}, - } - - pt := v1beta1.PipelineTask{ - Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Conditions: []v1beta1.PipelineTaskCondition{ptc1, ptc2}, - } - providedResources := map[string]*resourcev1alpha1.PipelineResource{} - - getTask := func(_ context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } - pr := v1beta1.PipelineRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pipelinerun", - }, - } - - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { - switch name { - case "pipelinerun-mytask1-always-true-0": - return cc1, nil - case "pipelinerun-mytask1": - return &trs[0], nil - case "pipelinerun-mytask1-always-true-1": - return cc2, nil - } - return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) - } - expectedConditionCheck := TaskConditionCheckState{{ - ConditionRegisterName: "always-true-0", - ConditionCheckName: "pipelinerun-mytask1-always-true-0", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(cc1), - PipelineTaskCondition: &ptc1, - ResolvedResources: providedResources, - }, { - ConditionRegisterName: "always-true-1", - ConditionCheckName: "pipelinerun-mytask1-always-true-1", - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(cc2), - PipelineTaskCondition: &ptc2, - ResolvedResources: providedResources, - }} - - ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, pt, providedResources) - if err != nil { - t.Fatalf("Did not expect error when resolving PipelineRun without Conditions: %v", err) - } - pipelineState := PipelineRunState{ps} - - if d := cmp.Diff(expectedConditionCheck, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { - t.Fatalf("ConditionChecks did not resolve as expected: %s", diff.PrintWantGot(d)) - } -} -func TestResolveConditionChecks_ConditionDoesNotExist(t *testing.T) { - names.TestingSeed() - trName := "pipelinerun-mytask1" - ccName := "pipelinerun-mytask1-does-not-exist" - - pt := v1beta1.PipelineTask{ - Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Conditions: []v1beta1.PipelineTaskCondition{{ - ConditionRef: "does-not-exist", - }}, - } - providedResources := map[string]*resourcev1alpha1.PipelineResource{} - - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { - if name == ccName { - return nil, fmt.Errorf("should not be called") - } else if name == trName { - return &trs[0], nil - } - return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) - } - getCondition := func(name string) (*v1alpha1.Condition, error) { - return nil, kerrors.NewNotFound(v1beta1.Resource("condition"), name) - } - pr := v1beta1.PipelineRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pipelinerun", - }, - } - - _, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, pt, providedResources) - - switch err := err.(type) { - case nil: - t.Fatalf("Expected error getting non-existent Conditions but got none") - case *ConditionNotFoundError: - // expected error - default: - t.Fatalf("Expected specific error type returned by func for non-existent Condition got %s", err) - } -} - -func TestResolveConditionCheck_UseExistingConditionCheckName(t *testing.T) { - names.TestingSeed() - - trName := "pipelinerun-mytask1" - ccName := "some-random-name" - - cc := &v1beta1.TaskRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: ccName, - }, - Spec: v1beta1.TaskRunSpec{}, - } - - ptc := v1beta1.PipelineTaskCondition{ - ConditionRef: "always-true", - } - - pt := v1beta1.PipelineTask{ - Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Conditions: []v1beta1.PipelineTaskCondition{ptc}, - } - providedResources := map[string]*resourcev1alpha1.PipelineResource{} - - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { - if name == ccName { - return cc, nil - } else if name == trName { - return &trs[0], nil - } - return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) - } - getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } - - ccStatus := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) - ccStatus[ccName] = &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: "always-true-0", - } - trStatus := make(map[string]*v1beta1.PipelineRunTaskRunStatus) - trStatus[trName] = &v1beta1.PipelineRunTaskRunStatus{ - PipelineTaskName: "mytask-1", - ConditionChecks: ccStatus, - } - pr := v1beta1.PipelineRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pipelinerun", - }, - Status: v1beta1.PipelineRunStatus{ - Status: duckv1beta1.Status{}, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - TaskRuns: trStatus, - }, - }, - } - - ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, pt, providedResources) - if err != nil { - t.Fatalf("Did not expect error when resolving PipelineRun without Conditions: %v", err) - } - pipelineState := PipelineRunState{ps} - expectedConditionChecks := TaskConditionCheckState{{ - ConditionRegisterName: "always-true-0", - ConditionCheckName: ccName, - Condition: &condition, - ConditionCheck: v1beta1.NewConditionCheck(cc), - PipelineTaskCondition: &ptc, - ResolvedResources: providedResources, - }} - - if d := cmp.Diff(expectedConditionChecks, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { - t.Fatalf("ConditionChecks did not resolve as expected %s", diff.PrintWantGot(d)) - } -} - -func TestResolvedConditionCheck_WithResources(t *testing.T) { - names.TestingSeed() - - condition := &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "always-true", - }, - Spec: v1alpha1.ConditionSpec{ - Resources: []v1alpha1.ResourceDeclaration{{ - Name: "workspace", - Type: resourcev1alpha1.PipelineResourceTypeGit, - }}, - }, - } - - gitResource := &resourcev1alpha1.PipelineResource{ - ObjectMeta: metav1.ObjectMeta{ - Name: "some-repo", - Namespace: "foo", - }, - Spec: resourcev1alpha1.PipelineResourceSpec{Type: resourcev1alpha1.PipelineResourceTypeGit}, - } - - ptc := v1beta1.PipelineTaskCondition{ - ConditionRef: "always-true", - Resources: []v1beta1.PipelineTaskInputResource{{ - Name: "workspace", - Resource: "blah", // The name used in the pipeline - }}, - } - - pt := v1beta1.PipelineTask{ - Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Conditions: []v1beta1.PipelineTaskCondition{ptc}, - } - - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } - - // This err result is required to satisfy the type alias on this function, but it triggers - // a false positive in the linter: https://github.com/mvdan/unparam/issues/40 - // nolint: unparam - getCondition := func(_ string) (*v1alpha1.Condition, error) { - return condition, nil - } - - pr := v1beta1.PipelineRun{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pipelinerun", - }, - } - - for _, tc := range []struct { - name string - providedResources map[string]*resourcev1alpha1.PipelineResource - wantErr bool - expected map[string]*resourcev1alpha1.PipelineResource - }{{ - name: "resource exists", - providedResources: map[string]*resourcev1alpha1.PipelineResource{"blah": gitResource}, - expected: map[string]*resourcev1alpha1.PipelineResource{"workspace": gitResource}, - }, { - name: "resource does not exist", - providedResources: map[string]*resourcev1alpha1.PipelineResource{}, - wantErr: true, - }} { - t.Run(tc.name, func(t *testing.T) { - ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, pt, tc.providedResources) - - if tc.wantErr { - if err == nil { - t.Fatalf("Did not get error when it was expected for test %s", tc.name) - } - } else { - if err != nil { - t.Fatalf("Unexpected error when no error expected: %v", err) - } - pipelineState := PipelineRunState{ps} - expectedConditionChecks := TaskConditionCheckState{{ - ConditionRegisterName: "always-true-0", - ConditionCheckName: "pipelinerun-mytask1-always-true-0", - Condition: condition, - PipelineTaskCondition: &ptc, - ResolvedResources: tc.expected, - }} - if d := cmp.Diff(expectedConditionChecks, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { - t.Fatalf("ConditionChecks did not resolve as expected %s", diff.PrintWantGot(d)) - } - } - }) - } -} - func TestValidateResourceBindings(t *testing.T) { p := &v1beta1.Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: "pipelines"}, @@ -3081,7 +2234,6 @@ func TestResolvePipeline_WhenExpressions(t *testing.T) { providedResources := map[string]*resourcev1alpha1.PipelineResource{} getTask := func(_ context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", @@ -3099,7 +2251,7 @@ func TestResolvePipeline_WhenExpressions(t *testing.T) { } t.Run("When Expressions exist", func(t *testing.T) { - _, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, getCondition, pt, providedResources) + _, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt, providedResources) if err != nil { t.Fatalf("Did not expect error when resolving PipelineRun: %v", err) } @@ -3115,7 +2267,6 @@ func TestIsCustomTask(t *testing.T) { getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, error) { return task, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } getRun := func(name string) (*v1alpha1.Run, error) { return nil, nil } - getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } for _, tc := range []struct { name string @@ -3221,7 +2372,7 @@ func TestIsCustomTask(t *testing.T) { }, }) ctx = cfg.ToContext(ctx) - rprt, err := ResolvePipelineRunTask(ctx, pr, getTask, getTaskRun, getRun, getCondition, tc.pt, nil) + rprt, err := ResolvePipelineRunTask(ctx, pr, getTask, getTaskRun, getRun, tc.pt, nil) if err != nil { t.Fatalf("Did not expect error when resolving PipelineRun: %v", err) } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go index 5593411a2d3..0502971a68c 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go @@ -58,7 +58,7 @@ type PipelineRunFacts struct { // SkipCache is a hash of PipelineTask names that stores whether a task will be // executed or not, because it's either not reachable via the DAG due to the pipeline - // state, or because it has failed conditions. + // state, or because it was skipped due to when expressions. // We cache this data along the state, because it's expensive to compute, it requires // traversing potentially the whole graph; this way it can built incrementally, when // needed, via the `Skip` method in pipelinerunresolution.go @@ -142,7 +142,8 @@ func (state PipelineRunState) GetTaskRunsStatus(pr *v1beta1.PipelineRun) map[str if rprt.IsCustomTask() { continue } - if rprt.TaskRun == nil && rprt.ResolvedConditionChecks == nil { + + if rprt.TaskRun == nil { continue } @@ -167,29 +168,6 @@ func (rprt *ResolvedPipelineRunTask) getTaskRunStatus(taskRunName string, tr *v1 prtrs.Status = &tr.Status } - if len(rprt.ResolvedConditionChecks) > 0 { - cStatus := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) - for _, c := range rprt.ResolvedConditionChecks { - cStatus[c.ConditionCheckName] = &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: c.ConditionRegisterName, - } - if c.ConditionCheck != nil { - cStatus[c.ConditionCheckName].Status = c.NewConditionCheckStatus() - } - } - prtrs.ConditionChecks = cStatus - if rprt.ResolvedConditionChecks.IsDone() && !rprt.ResolvedConditionChecks.IsSuccess() { - if prtrs.Status == nil { - prtrs.Status = &v1beta1.TaskRunStatus{} - } - prtrs.Status.SetCondition(&apis.Condition{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionFalse, - Reason: ReasonConditionCheckFailed, - Message: fmt.Sprintf("ConditionChecks failed for Task %s in PipelineRun %s", taskRunName, pr.Name), - }) - } - } return prtrs } @@ -219,9 +197,6 @@ func (state PipelineRunState) GetRunsStatus(pr *v1beta1.PipelineRun) map[string] if !rprt.IsCustomTask() { continue } - if rprt.Run == nil && rprt.ResolvedConditionChecks == nil { - continue - } var prrs *v1beta1.PipelineRunRunStatus if rprt.Run != nil { @@ -239,7 +214,6 @@ func (state PipelineRunState) GetRunsStatus(pr *v1beta1.PipelineRun) map[string] prrs.Status = &rprt.Run.Status } - // TODO(#3133): Include any condition check taskResults here too. status[rprt.RunName] = prrs } return status @@ -268,18 +242,11 @@ func (state PipelineRunState) GetChildReferences(taskRunVersion string, runVersi var childRefs []v1beta1.ChildStatusReference for _, rprt := range state { - // If this is for a TaskRun, but there isn't yet a specified TaskRun and we haven't resolved condition checks yet, - // skip this entry. - if !rprt.CustomTask && rprt.TaskRun == nil && rprt.ResolvedConditionChecks == nil { - continue - } - var childRef v1beta1.ChildStatusReference if rprt.CustomTask { - childRef = rprt.getChildRefForRun(runVersion) - } else { - childRef = rprt.getChildRefForTaskRun(taskRunVersion) + childRefs = append(childRefs, rprt.getChildRefForRun(runVersion)) + } else if rprt.TaskRun != nil { + childRefs = append(childRefs, rprt.getChildRefForTaskRun(taskRunVersion)) } - childRefs = append(childRefs, childRef) } return childRefs } @@ -305,22 +272,6 @@ func (rprt *ResolvedPipelineRunTask) getChildRefForTaskRun(taskRunVersion string taskRunVersion = rprt.TaskRun.APIVersion } - var childConditions []*v1beta1.PipelineRunChildConditionCheckStatus - if len(rprt.ResolvedConditionChecks) > 0 { - for _, c := range rprt.ResolvedConditionChecks { - condCheck := &v1beta1.PipelineRunChildConditionCheckStatus{ - PipelineRunConditionCheckStatus: v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: c.ConditionRegisterName, - }, - ConditionCheckName: c.ConditionCheckName, - } - if c.ConditionCheck != nil { - condCheck.Status = c.NewConditionCheckStatus() - } - - childConditions = append(childConditions, condCheck) - } - } return v1beta1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ APIVersion: taskRunVersion, @@ -329,7 +280,6 @@ func (rprt *ResolvedPipelineRunTask) getChildRefForTaskRun(taskRunVersion string Name: rprt.TaskRunName, PipelineTaskName: rprt.PipelineTask.Name, WhenExpressions: rprt.PipelineTask.WhenExpressions, - ConditionChecks: childConditions, } } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go index 8bc64639168..65dfbfd7ec9 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go @@ -1010,28 +1010,6 @@ func TestPipelineRunState_CompletedOrSkippedDAGTasks(t *testing.T) { name: "all-finished", state: allFinishedState, expectedNames: []string{pts[0].Name, pts[1].Name}, - }, { - name: "conditional task not skipped as the condition execution was successful", - state: conditionCheckSuccessNoTaskStartedState, - expectedNames: []string{}, - }, { - name: "conditional task not skipped as the condition has not started executing yet", - state: conditionCheckStartedState, - expectedNames: []string{}, - }, { - name: "conditional task skipped as the condition execution resulted in failure", - state: conditionCheckFailedWithNoOtherTasksState, - expectedNames: []string{pts[5].Name}, - }, { - name: "conditional task skipped as the condition execution resulted in failure but the other pipeline task" + - "not skipped since it finished execution successfully", - state: conditionCheckFailedWithOthersPassedState, - expectedNames: []string{pts[5].Name, pts[0].Name}, - }, { - name: "conditional task skipped as the condition execution resulted in failure but the other pipeline task" + - "not skipped since it failed", - state: conditionCheckFailedWithOthersFailedState, - expectedNames: []string{pts[5].Name, pts[0].Name}, }, { name: "large deps, not started", state: largePipelineState, @@ -1182,98 +1160,6 @@ func TestPipelineRunState_GetFinalTasks(t *testing.T) { DAGTasks: []v1beta1.PipelineTask{pts[0]}, finalTasks: []v1beta1.PipelineTask{pts[1]}, expectedFinalTasks: PipelineRunState{oneFinishedState[1]}, - }, { - // tasks: [ mytask6 with condition] - // finally: [mytask2] - name: "06 - DAG task condition started, no final tasks", - desc: "DAG task (mytask6) condition started - do not schedule final tasks (mytask1)", - state: append(conditionCheckStartedState, noneStartedState[0]), - DAGTasks: []v1beta1.PipelineTask{pts[5]}, - finalTasks: []v1beta1.PipelineTask{pts[0]}, - expectedFinalTasks: PipelineRunState{}, - }, { - // tasks: [ mytask6 with condition] - // finally: [mytask2] - name: "07 - DAG task condition done, no final tasks", - desc: "DAG task (mytask6) condition finished, mytask6 not started - do not schedule final tasks (mytask2)", - state: append(conditionCheckSuccessNoTaskStartedState, noneStartedState[0]), - DAGTasks: []v1beta1.PipelineTask{pts[5]}, - finalTasks: []v1beta1.PipelineTask{pts[0]}, - expectedFinalTasks: PipelineRunState{}, - }, { - // tasks: [ mytask6 with condition] - // finally: [mytask2] - name: "08 - DAG task skipped, return final tasks", - desc: "DAG task (mytask6) condition failed - schedule final tasks (mytask2) ", - state: append(conditionCheckFailedWithNoOtherTasksState, noneStartedState[0]), - DAGTasks: []v1beta1.PipelineTask{pts[5]}, - finalTasks: []v1beta1.PipelineTask{pts[0]}, - expectedFinalTasks: PipelineRunState{noneStartedState[0]}, - }, { - // tasks: [ mytask1, mytask6 with condition] - // finally: [mytask2] - name: "09 - DAG task succeeded/skipped, return final tasks ", - desc: "DAG task (mytask1) finished, mytask6 condition failed - schedule final tasks (mytask2)", - state: append(conditionCheckFailedWithOthersPassedState, noneStartedState[1]), - DAGTasks: []v1beta1.PipelineTask{pts[5], pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, - expectedFinalTasks: PipelineRunState{noneStartedState[1]}, - }, { - // tasks: [ mytask1, mytask6 with condition] - // finally: [mytask2] - name: "10 - DAG task failed/skipped, return final tasks", - desc: "DAG task (mytask1) failed, mytask6 condition failed - schedule final tasks (mytask2)", - state: append(conditionCheckFailedWithOthersFailedState, noneStartedState[1]), - DAGTasks: []v1beta1.PipelineTask{pts[5], pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, - expectedFinalTasks: PipelineRunState{noneStartedState[1]}, - }, { - // tasks: [ mytask6 with condition, mytask7 runAfter mytask6] - // finally: [mytask2] - name: "11 - DAG task skipped, return final tasks", - desc: "DAG task (mytask6) condition failed, mytask6 and mytask7 skipped - schedule final tasks (mytask2)", - state: append(taskWithParentSkippedState, noneStartedState[1]), - DAGTasks: []v1beta1.PipelineTask{pts[5], pts[6]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, - expectedFinalTasks: PipelineRunState{noneStartedState[1]}, - }, { - // tasks: [ mytask1, mytask6 with condition, mytask8 runAfter mytask6] - // finally: [mytask2] - name: "12 - DAG task succeeded/skipped, return final tasks", - desc: "DAG task (mytask1) finished - DAG task (mytask6) condition failed, mytask6 and mytask8 skipped - schedule final tasks (mytask2)", - state: append(taskWithMultipleParentsSkippedState, noneStartedState[1]), - DAGTasks: []v1beta1.PipelineTask{pts[0], pts[5], pts[7]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, - expectedFinalTasks: PipelineRunState{noneStartedState[1]}, - }, { - // tasks: [ mytask1, mytask6 with condition, mytask8 runAfter mytask6, mytask9 runAfter mytask1 and mytask6] - // finally: [mytask2] - name: "13 - DAG task succeeded/skipped - return final tasks", - desc: "DAG task (mytask1) finished - DAG task (mytask6) condition failed, mytask6, mytask8, and mytask9 skipped" + - "- schedule final tasks (mytask2)", - state: append(taskWithGrandParentSkippedState, noneStartedState[1]), - DAGTasks: []v1beta1.PipelineTask{pts[0], pts[5], pts[7], pts[8]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, - expectedFinalTasks: PipelineRunState{noneStartedState[1]}, - }, { - //tasks: [ mytask1, mytask6 with condition, mytask8 runAfter mytask6, mytask9 runAfter mytask1 and mytask6] - //finally: [mytask2] - name: "14 - DAG task succeeded, skipped - return final tasks", - desc: "DAG task (mytask1) finished - DAG task (mytask6) failed - mytask8 and mytask9 skipped" + - "- schedule final tasks (mytask2)", - state: append(taskWithGrandParentsOneFailedState, noneStartedState[1]), - DAGTasks: []v1beta1.PipelineTask{pts[0], pts[5], pts[7], pts[8]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, - expectedFinalTasks: PipelineRunState{noneStartedState[1]}, - }, { - //tasks: [ mytask1, mytask6 with condition, mytask8 runAfter mytask6, mytask9 runAfter mytask1 and mytask6] - //finally: [mytask2] - name: "15 - DAG task succeeded/started - no final tasks", - desc: "DAG task (mytask1) finished - DAG task (mytask6) started - do no schedule final tasks", - state: append(taskWithGrandParentsOneNotRunState, noneStartedState[1]), - DAGTasks: []v1beta1.PipelineTask{pts[0], pts[5], pts[7], pts[8]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, - expectedFinalTasks: PipelineRunState{}, }} for _, tc := range tcs { dagGraph, err := dag.Build(v1beta1.PipelineTaskList(tc.DAGTasks), v1beta1.PipelineTaskList(tc.DAGTasks).Deps()) @@ -1352,10 +1238,9 @@ func TestGetPipelineConditionStatus(t *testing.T) { // 1 runAfter the passed one, currently running // 1 runAfter the failed one, which is marked as incomplete var taskMultipleFailuresSkipRunning = PipelineRunState{{ - TaskRunName: "task0taskrun", - PipelineTask: &pts[5], - TaskRun: makeSucceeded(trs[0]), - ResolvedConditionChecks: successTaskConditionCheckState, + TaskRunName: "task0taskrun", + PipelineTask: &pts[5], + TaskRun: makeSucceeded(trs[0]), }, { TaskRunName: "runningTaskRun", // this is running PipelineTask: &pts[6], @@ -1370,10 +1255,9 @@ func TestGetPipelineConditionStatus(t *testing.T) { taskMultipleFailuresOneCancel = append(taskMultipleFailuresOneCancel, cancelledTask[0]) var taskNotRunningWithSuccesfulParentsOneFailed = PipelineRunState{{ - TaskRunName: "task0taskrun", - PipelineTask: &pts[5], - TaskRun: makeSucceeded(trs[0]), - ResolvedConditionChecks: successTaskConditionCheckState, + TaskRunName: "task0taskrun", + PipelineTask: &pts[5], + TaskRun: makeSucceeded(trs[0]), }, { TaskRunName: "notRunningTaskRun", // runAfter pts[5], not started yet PipelineTask: &pts[6], @@ -1465,74 +1349,6 @@ func TestGetPipelineConditionStatus(t *testing.T) { expectedStatus: corev1.ConditionUnknown, expectedReason: v1beta1.PipelineRunReasonRunning.String(), expectedIncomplete: 1, - }, { - name: "condition-success-no-task started", - state: conditionCheckSuccessNoTaskStartedState, - expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), - expectedIncomplete: 1, - }, { - name: "condition-check-in-progress", - state: conditionCheckStartedState, - expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), - expectedIncomplete: 1, - }, { - name: "condition-failed-no-other-tasks", // 1 task pipeline with a condition that fails - state: conditionCheckFailedWithNoOtherTasksState, - expectedStatus: corev1.ConditionTrue, - expectedReason: v1beta1.PipelineRunReasonCompleted.String(), - expectedSkipped: 1, - expectedIncomplete: 1, - }, { - name: "condition-failed-another-task-succeeded", // 1 task skipped due to condition, but others pass - state: conditionCheckFailedWithOthersPassedState, - expectedStatus: corev1.ConditionTrue, - expectedReason: v1beta1.PipelineRunReasonCompleted.String(), - expectedSucceeded: 1, - expectedSkipped: 1, - }, { - name: "condition-failed-another-task-failed", // 1 task skipped due to condition, but others failed - state: conditionCheckFailedWithOthersFailedState, - expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), - expectedFailed: 1, - expectedSkipped: 1, - }, { - name: "task skipped due to condition failure in parent", - state: taskWithParentSkippedState, - expectedStatus: corev1.ConditionTrue, - expectedReason: v1beta1.PipelineRunReasonCompleted.String(), - expectedSkipped: 2, - }, { - name: "task with multiple parent tasks -> one of which is skipped", - state: taskWithMultipleParentsSkippedState, - expectedStatus: corev1.ConditionTrue, - expectedReason: v1beta1.PipelineRunReasonCompleted.String(), - expectedSkipped: 2, - expectedSucceeded: 1, - }, { - name: "task with grand parent task skipped", - state: taskWithGrandParentSkippedState, - expectedStatus: corev1.ConditionTrue, - expectedReason: v1beta1.PipelineRunReasonCompleted.String(), - expectedSkipped: 3, - expectedSucceeded: 1, - }, { - name: "task with grand parents; one parent failed", - state: taskWithGrandParentsOneFailedState, - expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), - expectedSucceeded: 1, - expectedSkipped: 2, - expectedFailed: 1, - }, { - name: "task with grand parents; one not run yet", - state: taskWithGrandParentsOneNotRunState, - expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), - expectedSucceeded: 1, - expectedIncomplete: 3, }, { name: "task that was cancelled", state: taskCancelledFailed, @@ -1567,13 +1383,6 @@ func TestGetPipelineConditionStatus(t *testing.T) { expectedSucceeded: 1, expectedFailed: 1, expectedSkipped: 1, - }, { - name: "task with grand parents; one not run yet", - state: taskWithGrandParentsOneNotRunState, - expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), - expectedSucceeded: 1, - expectedIncomplete: 3, }, { name: "cancelled task should result in cancelled pipeline", state: cancelledTask, @@ -2354,93 +2163,6 @@ status: } } -// TestUpdateTaskRunStateWithConditionChecks runs "getTaskRunsStatus" and verifies how it updates a PipelineRun status -// from several TaskRun with Conditions associated to the PipelineRun -func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { - taskrunName := "task-run" - - pipelineTask := v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{Name: "unit-test-task"}, - Conditions: []v1beta1.PipelineTaskCondition{{ - ConditionRef: "success-condition", - }, { - ConditionRef: "fail-condition", - }}, - } - - successrcc, successConditionCheckStatus, failingrcc, failingConditionCheckStatus := getConditionCheckStatusData(t) - - failedTaskRunStatus := v1beta1.TaskRunStatus{ - Status: duckv1beta1.Status{ - Conditions: []apis.Condition{{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionFalse, - Reason: ReasonConditionCheckFailed, - Message: fmt.Sprintf("ConditionChecks failed for Task %s in PipelineRun %s", taskrunName, "test-pipeline-run"), - }}, - }, - } - - tcs := []struct { - name string - rcc TaskConditionCheckState - expectedStatus v1beta1.PipelineRunTaskRunStatus - }{{ - name: "success-condition-checks", - rcc: TaskConditionCheckState{&successrcc}, - expectedStatus: v1beta1.PipelineRunTaskRunStatus{ - ConditionChecks: map[string]*v1beta1.PipelineRunConditionCheckStatus{ - successrcc.ConditionCheck.Name: successConditionCheckStatus, - }, - }, - }, { - name: "failing-condition-checks", - rcc: TaskConditionCheckState{&failingrcc}, - expectedStatus: v1beta1.PipelineRunTaskRunStatus{ - Status: &failedTaskRunStatus, - ConditionChecks: map[string]*v1beta1.PipelineRunConditionCheckStatus{ - failingrcc.ConditionCheck.Name: failingConditionCheckStatus, - }, - }, - }, { - name: "multiple-condition-checks", - rcc: TaskConditionCheckState{&successrcc, &failingrcc}, - expectedStatus: v1beta1.PipelineRunTaskRunStatus{ - Status: &failedTaskRunStatus, - ConditionChecks: map[string]*v1beta1.PipelineRunConditionCheckStatus{ - successrcc.ConditionCheck.Name: successConditionCheckStatus, - failingrcc.ConditionCheck.Name: failingConditionCheckStatus, - }, - }, - }} - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - pr := parse.MustParsePipelineRun(t, ` -metadata: - name: test-pipeline-run - namespace: foo -spec: - pipelineRef: - name: test-pipeline -`) - state := PipelineRunState{{ - PipelineTask: &pipelineTask, - TaskRunName: taskrunName, - ResolvedConditionChecks: tc.rcc, - }} - pr.Status.InitializeConditions(testClock) - status := state.GetTaskRunsStatus(pr) - expected := map[string]*v1beta1.PipelineRunTaskRunStatus{ - taskrunName: &tc.expectedStatus, - } - if d := cmp.Diff(status, expected, cmpopts.IgnoreFields(apis.Condition{}, "LastTransitionTime.Inner.Time")); d != "" { - t.Fatalf("Did not get expected status for %s %s", tc.name, diff.PrintWantGot(d)) - } - }) - } -} - func TestPipelineRunState_GetResultsFuncs(t *testing.T) { state := PipelineRunState{{ TaskRunName: "successful-task-with-results", @@ -2638,8 +2360,6 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { } func TestPipelineRunState_GetChildReferences(t *testing.T) { - successrcc, successConditionCheckStatus, failingrcc, failingConditionCheckStatus := getConditionCheckStatusData(t) - testCases := []struct { name string state PipelineRunState @@ -2724,39 +2444,6 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }}, }}, }, - { - name: "task-with-condition-check", - state: PipelineRunState{{ - TaskRunName: "task-with-condition-check-run", - PipelineTask: &v1beta1.PipelineTask{ - Name: "task-with-condition-check-1", - TaskRef: &v1beta1.TaskRef{ - Name: "task-with-condition-check", - Kind: "Task", - APIVersion: "v1beta1", - }, - }, - ResolvedConditionChecks: TaskConditionCheckState{&successrcc, &failingrcc}, - }}, - childRefs: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "TaskRun", - }, - Name: "task-with-condition-check-run", - PipelineTaskName: "task-with-condition-check-1", - ConditionChecks: []*v1beta1.PipelineRunChildConditionCheckStatus{ - { - PipelineRunConditionCheckStatus: *successConditionCheckStatus, - ConditionCheckName: successrcc.ConditionCheck.Name, - }, - { - PipelineRunConditionCheckStatus: *failingConditionCheckStatus, - ConditionCheckName: failingrcc.ConditionCheck.Name, - }, - }, - }}, - }, { name: "single-custom-task", state: PipelineRunState{{ @@ -2854,99 +2541,3 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }) } } - -// conditionCheckFromTaskRun takes a pointer to a TaskRun and wraps it into a ConditionCheck -func conditionCheckFromTaskRun(tr *v1beta1.TaskRun) *v1beta1.ConditionCheck { - cc := v1beta1.ConditionCheck(*tr) - return &cc -} - -func getConditionCheckStatusData(t *testing.T) (ResolvedConditionCheck, *v1beta1.PipelineRunConditionCheckStatus, ResolvedConditionCheck, *v1beta1.PipelineRunConditionCheckStatus) { - successConditionCheckName := "success-condition" - failingConditionCheckName := "fail-condition" - - successCondition := parse.MustParseCondition(t, ` -metadata: - name: cond-1 - namespace: foo -`) - - failingCondition := parse.MustParseCondition(t, ` -metadata: - name: cond-2 - namespace: foo -`) - - successConditionCheck := parse.MustParseTaskRun(t, fmt.Sprintf(` -metadata: - name: %s - namespace: foo -spec: -status: - conditions: - - type: Succeeded - status: "True" - steps: - - container: - terminated: - exitCode: 0 -`, successConditionCheckName)) - - failingConditionCheck := parse.MustParseTaskRun(t, fmt.Sprintf(` -metadata: - name: %s - namespace: foo -spec: -status: - conditions: - - type: Succeeded - status: "False" - steps: - - container: - terminated: - exitCode: 127 -`, failingConditionCheckName)) - - successrcc := ResolvedConditionCheck{ - ConditionRegisterName: successCondition.Name + "-0", - ConditionCheckName: successConditionCheckName, - Condition: successCondition, - ConditionCheck: conditionCheckFromTaskRun(successConditionCheck), - } - failingrcc := ResolvedConditionCheck{ - ConditionRegisterName: failingCondition.Name + "-0", - ConditionCheckName: failingConditionCheckName, - Condition: failingCondition, - ConditionCheck: conditionCheckFromTaskRun(failingConditionCheck), - } - - successConditionCheckStatus := &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: successrcc.ConditionRegisterName, - Status: &v1beta1.ConditionCheckStatus{ - ConditionCheckStatusFields: v1beta1.ConditionCheckStatusFields{ - Check: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ExitCode: 0}, - }, - }, - Status: duckv1beta1.Status{ - Conditions: []apis.Condition{{Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue}}, - }, - }, - } - - failingConditionCheckStatus := &v1beta1.PipelineRunConditionCheckStatus{ - ConditionName: failingrcc.ConditionRegisterName, - Status: &v1beta1.ConditionCheckStatus{ - ConditionCheckStatusFields: v1beta1.ConditionCheckStatusFields{ - Check: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ExitCode: 127}, - }, - }, - Status: duckv1beta1.Status{ - Conditions: []apis.Condition{{Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse}}, - }, - }, - } - - return successrcc, successConditionCheckStatus, failingrcc, failingConditionCheckStatus -} diff --git a/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go b/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go index 93fb1c5b0fb..6785cd44a29 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go +++ b/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go @@ -59,11 +59,9 @@ func TestValidatePipelineTaskResults_ValidStates(t *testing.T) { }, { PipelineTask: &v1beta1.PipelineTask{ Name: "pt2", - Conditions: []v1beta1.PipelineTaskCondition{{ - Params: []v1beta1.Param{{ - Name: "p", - Value: *v1beta1.NewArrayOrString("$(tasks.pt1.results.result)"), - }}, + Params: []v1beta1.Param{{ + Name: "p", + Value: *v1beta1.NewArrayOrString("$(tasks.pt1.results.result)"), }}, }, }}, @@ -78,11 +76,9 @@ func TestValidatePipelineTaskResults_ValidStates(t *testing.T) { }, { PipelineTask: &v1beta1.PipelineTask{ Name: "pt2", - Conditions: []v1beta1.PipelineTaskCondition{{ - Params: []v1beta1.Param{{ - Name: "p", - Value: *v1beta1.NewArrayOrString("$(tasks.pt1.results.a-dynamic-custom-task-result)"), - }}, + Params: []v1beta1.Param{{ + Name: "p", + Value: *v1beta1.NewArrayOrString("$(tasks.pt1.results.a-dynamic-custom-task-result)"), }}, }, }}, @@ -113,19 +109,6 @@ func TestValidatePipelineTaskResults_IncorrectTaskName(t *testing.T) { }}, }, }}, - }, { - desc: "invalid result reference in condition", - state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - Name: "pt1", - Conditions: []v1beta1.PipelineTaskCondition{{ - Params: []v1beta1.Param{{ - Name: "p1", - Value: *v1beta1.NewArrayOrString(missingPipelineTaskVariable), - }}, - }}, - }, - }}, }, { desc: "invalid result reference in when expression", state: PipelineRunState{{ @@ -180,19 +163,6 @@ func TestValidatePipelineTaskResults_IncorrectResultName(t *testing.T) { }}, }, }}, - }, { - desc: "invalid result reference in condition", - state: PipelineRunState{pt1, { - PipelineTask: &v1beta1.PipelineTask{ - Name: "pt2", - Conditions: []v1beta1.PipelineTaskCondition{{ - Params: []v1beta1.Param{{ - Name: "p1", - Value: *v1beta1.NewArrayOrString("$(tasks.pt1.results.result1)"), - }}, - }}, - }, - }}, }, { desc: "invalid result reference in when expression", state: PipelineRunState{pt1, { diff --git a/pkg/status/status.go b/pkg/status/status.go index 07434af199b..4952ab27636 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -90,7 +90,6 @@ func GetFullPipelineTaskStatuses(ctx context.Context, client versioned.Interface trStatuses[cr.Name] = &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: cr.PipelineTaskName, - ConditionChecks: cr.GetConditionChecks(), WhenExpressions: cr.WhenExpressions, } diff --git a/test/clients.go b/test/clients.go index dcb60a72a60..3e0510e7846 100644 --- a/test/clients.go +++ b/test/clients.go @@ -61,7 +61,6 @@ type clients struct { TaskRunClient v1beta1.TaskRunInterface PipelineRunClient v1beta1.PipelineRunInterface PipelineResourceClient resourcev1alpha1.PipelineResourceInterface - ConditionClient v1alpha1.ConditionInterface RunClient v1alpha1.RunInterface } @@ -98,7 +97,6 @@ func newClients(t *testing.T, configPath, clusterName, namespace string) *client c.TaskRunClient = cs.TektonV1beta1().TaskRuns(namespace) c.PipelineRunClient = cs.TektonV1beta1().PipelineRuns(namespace) c.PipelineResourceClient = rcs.TektonV1alpha1().PipelineResources(namespace) - c.ConditionClient = cs.TektonV1alpha1().Conditions(namespace) c.RunClient = cs.TektonV1alpha1().Runs(namespace) return c } diff --git a/test/controller.go b/test/controller.go index a536a175a3f..9844d3f12d1 100644 --- a/test/controller.go +++ b/test/controller.go @@ -29,7 +29,6 @@ import ( informersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" informersv1beta1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1" fakepipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client/fake" - fakeconditioninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/condition/fake" fakeruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/run/fake" fakeclustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask/fake" fakepipelineinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipeline/fake" @@ -73,7 +72,6 @@ type Data struct { Tasks []*v1beta1.Task ClusterTasks []*v1beta1.ClusterTask PipelineResources []*v1alpha1.PipelineResource - Conditions []*v1alpha1.Condition Runs []*v1alpha1.Run Pods []*corev1.Pod Namespaces []*corev1.Namespace @@ -100,7 +98,6 @@ type Informers struct { Task informersv1beta1.TaskInformer ClusterTask informersv1beta1.ClusterTaskInformer PipelineResource resourceinformersv1alpha1.PipelineResourceInformer - Condition informersv1alpha1.ConditionInformer Pod coreinformers.PodInformer ConfigMap coreinformers.ConfigMapInformer ServiceAccount coreinformers.ServiceAccountInformer @@ -184,7 +181,6 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers Task: faketaskinformer.Get(ctx), ClusterTask: fakeclustertaskinformer.Get(ctx), PipelineResource: fakeresourceinformer.Get(ctx), - Condition: fakeconditioninformer.Get(ctx), Pod: fakefilteredpodinformer.Get(ctx, v1beta1.ManagedByLabelKey), ConfigMap: fakeconfigmapinformer.Get(ctx), ServiceAccount: fakeserviceaccountinformer.Get(ctx), @@ -237,13 +233,6 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers t.Fatal(err) } } - c.Pipeline.PrependReactor("*", "conditions", AddToInformer(t, i.Condition.Informer().GetIndexer())) - for _, cond := range d.Conditions { - cond := cond.DeepCopy() // Avoid assumptions that the informer's copy is modified. - if _, err := c.Pipeline.TektonV1alpha1().Conditions(cond.Namespace).Create(ctx, cond, metav1.CreateOptions{}); err != nil { - t.Fatal(err) - } - } c.Pipeline.PrependReactor("*", "runs", AddToInformer(t, i.Run.Informer().GetIndexer())) for _, run := range d.Runs { run := run.DeepCopy() // Avoid assumptions that the informer's copy is modified. diff --git a/test/e2e-common.sh b/test/e2e-common.sh index 32e45003880..78958a00eaf 100755 --- a/test/e2e-common.sh +++ b/test/e2e-common.sh @@ -62,7 +62,7 @@ function uninstall_pipeline_crd_version() { } function delete_pipeline_resources() { - for res in conditions pipelineresources tasks clustertasks pipelines taskruns pipelineruns; do + for res in pipelineresources tasks clustertasks pipelines taskruns pipelineruns; do kubectl delete --ignore-not-found=true ${res}.tekton.dev --all done } diff --git a/test/parse/yaml.go b/test/parse/yaml.go index 6693a6d1248..065a9c4dde7 100644 --- a/test/parse/yaml.go +++ b/test/parse/yaml.go @@ -134,16 +134,6 @@ kind: PipelineResource return &resource } -// MustParseCondition takes YAML and parses it into a *v1alpha1.Condition -func MustParseCondition(t *testing.T, yaml string) *v1alpha1.Condition { - var cond v1alpha1.Condition - yaml = `apiVersion: tekton.dev/v1alpha1 -kind: Condition -` + yaml - mustParseYAML(t, yaml, &cond) - return &cond -} - func mustParseYAML(t *testing.T, yaml string, i runtime.Object) { if _, _, err := scheme.Codecs.UniversalDeserializer().Decode([]byte(yaml), nil, i); err != nil { t.Fatalf("mustParseYAML (%s): %v", yaml, err) diff --git a/test/pipelinefinally_test.go b/test/pipelinefinally_test.go index 5d087c47f2f..465d84b22b5 100644 --- a/test/pipelinefinally_test.go +++ b/test/pipelinefinally_test.go @@ -29,8 +29,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/test/diff" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" @@ -56,11 +54,6 @@ func TestPipelineLevelFinally_OneDAGTaskFailed_InvalidTaskResult_Failure(t *test knativetest.CleanupOnInterrupt(func() { tearDown(ctx, t, c, namespace) }, t.Logf) defer tearDown(ctx, t, c, namespace) - cond := getCondition(t, namespace) - if _, err := c.ConditionClient.Create(ctx, cond, metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create Condition `%s`: %s", cond1Name, err) - } - task := getFailTask(t, namespace) task.Spec.Results = append(task.Spec.Results, v1beta1.TaskResult{ Name: "result", @@ -202,8 +195,11 @@ spec: - name: dagtask3 taskRef: name: %s - conditions: - - conditionRef: %s + when: + - input: banana + operator: in + values: + - apple - name: dagtask4 taskRef: name: %s @@ -222,7 +218,7 @@ spec: taskConsumingResultInWhenExpression.Name, taskConsumingResultInWhenExpression.Name, taskConsumingResultInWhenExpression.Name, taskConsumingResultInWhenExpression.Name, // Tasks - task.Name, delayedTask.Name, successTask.Name, cond.Name, successTask.Name, taskProducingResult.Name)) + task.Name, delayedTask.Name, successTask.Name, successTask.Name, taskProducingResult.Name)) if _, err := c.PipelineClient.Create(ctx, pipeline, metav1.CreateOptions{}); err != nil { t.Fatalf("Failed to create Pipeline: %s", err) } @@ -247,9 +243,9 @@ spec: t.Fatalf("Error listing TaskRuns for PipelineRun %s: %s", pipelineRun.Name, err) } - // expecting taskRuns for dagtask1, dagtask2, dagtask3 (with condition failure), dagtask5, finaltask1, finaltask2, + // expecting taskRuns for dagtask1, dagtask2, dagtask5, finaltask1, finaltask2, // finaltaskconsumingdagtask5, guardedfinaltaskusingdagtask5result1, guardedfinaltaskusingdagtask5status1 - expectedTaskRunsCount := 9 + expectedTaskRunsCount := 8 if len(taskrunList.Items) != expectedTaskRunsCount { var s []string for _, n := range taskrunList.Items { @@ -349,6 +345,11 @@ spec: expectedSkippedTasks := []v1beta1.SkippedTask{{ Name: "dagtask3", Reason: v1beta1.StoppingSkip, + WhenExpressions: v1beta1.WhenExpressions{{ + Input: "banana", + Operator: "in", + Values: []string{"apple"}, + }}, }, { Name: "dagtask4", Reason: v1beta1.StoppingSkip, @@ -698,6 +699,7 @@ spec: } func isSuccessful(t *testing.T, taskRunName string, conds duckv1beta1.Conditions) bool { + t.Helper() for _, c := range conds { if c.Type == apis.ConditionSucceeded { if c.Status != corev1.ConditionTrue { @@ -711,6 +713,7 @@ func isSuccessful(t *testing.T, taskRunName string, conds duckv1beta1.Conditions } func isCancelled(t *testing.T, taskRunName string, conds duckv1beta1.Conditions) bool { + t.Helper() for _, c := range conds { if c.Type == apis.ConditionSucceeded { return true @@ -721,6 +724,7 @@ func isCancelled(t *testing.T, taskRunName string, conds duckv1beta1.Conditions) } func isSkipped(t *testing.T, taskRunName string, conds duckv1beta1.Conditions) bool { + t.Helper() for _, c := range conds { if c.Type == apis.ConditionSucceeded { if c.Status != corev1.ConditionFalse && c.Reason != resources.ReasonConditionCheckFailed { @@ -828,18 +832,6 @@ spec: `, helpers.ObjectNameForTest(t), namespace, paramName)) } -func getCondition(t *testing.T, namespace string) *v1alpha1.Condition { - return parse.MustParseCondition(t, fmt.Sprintf(` -metadata: - name: %s - namespace: %s -spec: - check: - image: ubuntu - script: 'exit 1' -`, helpers.ObjectNameForTest(t), namespace)) -} - func getPipelineRun(t *testing.T, namespace, p string) *v1beta1.PipelineRun { return parse.MustParsePipelineRun(t, fmt.Sprintf(` metadata: diff --git a/test/pipelinerun_test.go b/test/pipelinerun_test.go index c65aa5c520e..20f797e7780 100644 --- a/test/pipelinerun_test.go +++ b/test/pipelinerun_test.go @@ -48,7 +48,6 @@ var ( secretName = "secret" saName = "service-account" task1Name = "task1" - cond1Name = "cond-1" ) func TestPipelineRunStatusSpec(t *testing.T) { @@ -259,39 +258,6 @@ spec: // 1 from PipelineRun and 1 from Tasks defined in pipelinerun expectedNumberOfEvents: 2, pipelineRunFunc: getHelloWorldPipelineRun, - }, { - name: "pipeline succeeds when task skipped due to failed condition", - testSetup: func(ctx context.Context, t *testing.T, c *clients, namespace string, _ int) (map[string]*v1alpha1.PipelineResource, *v1beta1.Pipeline) { - t.Helper() - cond := getFailingCondition(t) - if _, err := c.ConditionClient.Create(ctx, cond, metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create Condition `%s`: %s", cond.Name, err) - } - - task := parse.MustParseTask(t, fmt.Sprintf(` -metadata: - name: %s - namespace: %s -spec: - steps: - - image: ubuntu - command: ['/bin/bash'] - args: ['-c', 'echo hello, world'] -`, helpers.ObjectNameForTest(t), namespace)) - if _, err := c.TaskClient.Create(ctx, task, metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create Task `%s`: %s", task.Name, err) - } - p := getPipelineWithFailingCondition(t, namespace, task.Name, cond.Name) - if _, err := c.PipelineClient.Create(ctx, p, metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create Pipeline `%s`: %s", p.Name, err) - } - - return nil, p - }, - expectedTaskRuns: []string{}, - // 1 from PipelineRun; 0 from taskrun since it should not be executed due to condition failing - expectedNumberOfEvents: 1, - pipelineRunFunc: getConditionalPipelineRun, }, { name: "pipelinerun succeeds with LimitRange minimum in namespace", testSetup: func(ctx context.Context, t *testing.T, c *clients, namespace string, index int) (map[string]*v1alpha1.PipelineResource, *v1beta1.Pipeline) { @@ -1051,50 +1017,6 @@ func assertAnnotationsMatch(t *testing.T, expectedAnnotations, actualAnnotations } } -func getPipelineWithFailingCondition(t *testing.T, namespace string, taskName, condName string) *v1beta1.Pipeline { - return parse.MustParsePipeline(t, fmt.Sprintf(` -metadata: - name: %s - namespace: %s -spec: - tasks: - - name: %s - taskRef: - name: %s - conditions: - - conditionRef: %s - - name: task2 - taskRef: - name: %s - runAfter: ['%s'] -`, helpers.ObjectNameForTest(t), namespace, task1Name, taskName, condName, taskName, task1Name)) -} - -func getFailingCondition(t *testing.T) *v1alpha1.Condition { - return parse.MustParseCondition(t, fmt.Sprintf(` -metadata: - name: %s -spec: - check: - image: ubuntu - command: ['/bin/bash'] - args: ['exit 1'] -`, helpers.ObjectNameForTest(t))) -} - -func getConditionalPipelineRun(t *testing.T, _ int, namespace string, pipelineName string, _ map[string]*v1alpha1.PipelineResource) *v1beta1.PipelineRun { - return parse.MustParsePipelineRun(t, fmt.Sprintf(` -metadata: - name: %s - namespace: %s - labels: - hello-world-key: hello-world-vaule -spec: - pipelineRef: - name: %s -`, helpers.ObjectNameForTest(t), namespace, pipelineName)) -} - func getLimitRange(name, namespace, resourceCPU, resourceMemory, resourceEphemeralStorage string) *corev1.LimitRange { return &corev1.LimitRange{ ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, diff --git a/test/v1alpha1/clients.go b/test/v1alpha1/clients.go index aea51d3e718..f359aa10a18 100644 --- a/test/v1alpha1/clients.go +++ b/test/v1alpha1/clients.go @@ -59,7 +59,6 @@ type clients struct { TaskRunClient v1alpha1.TaskRunInterface PipelineRunClient v1alpha1.PipelineRunInterface PipelineResourceClient resourcev1alpha1.PipelineResourceInterface - ConditionClient v1alpha1.ConditionInterface } // newClients instantiates and returns several clientsets required for making requests to the @@ -94,6 +93,5 @@ func newClients(t *testing.T, configPath, clusterName, namespace string) *client c.TaskRunClient = cs.TektonV1alpha1().TaskRuns(namespace) c.PipelineRunClient = cs.TektonV1alpha1().PipelineRuns(namespace) c.PipelineResourceClient = rcs.TektonV1alpha1().PipelineResources(namespace) - c.ConditionClient = cs.TektonV1alpha1().Conditions(namespace) return c } diff --git a/test/v1alpha1/controller.go b/test/v1alpha1/controller.go index ebac2cce8f6..f9644510bce 100644 --- a/test/v1alpha1/controller.go +++ b/test/v1alpha1/controller.go @@ -26,7 +26,6 @@ import ( informersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" fakepipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client/fake" fakeclustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/clustertask/fake" - fakeconditioninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/condition/fake" fakepipelineinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/pipeline/fake" fakepipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/pipelinerun/fake" faketaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/task/fake" @@ -53,7 +52,6 @@ type Data struct { Tasks []*v1alpha1.Task ClusterTasks []*v1alpha1.ClusterTask PipelineResources []*v1alpha1.PipelineResource - Conditions []*v1alpha1.Condition Pods []*corev1.Pod Namespaces []*corev1.Namespace } @@ -73,7 +71,6 @@ type Informers struct { Task informersv1alpha1.TaskInformer ClusterTask informersv1alpha1.ClusterTaskInformer PipelineResource resourceinformersv1alpha1.PipelineResourceInformer - Condition informersv1alpha1.ConditionInformer Pod coreinformers.PodInformer } @@ -100,7 +97,6 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers Task: faketaskinformer.Get(ctx), ClusterTask: fakeclustertaskinformer.Get(ctx), PipelineResource: fakeresourceinformer.Get(ctx), - Condition: fakeconditioninformer.Get(ctx), Pod: fakefilteredpodinformer.Get(ctx, v1alpha1.ManagedByLabelKey), } @@ -152,14 +148,6 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers t.Fatal(err) } } - for _, cond := range d.Conditions { - if err := i.Condition.Informer().GetIndexer().Add(cond); err != nil { - t.Fatal(err) - } - if _, err := c.Pipeline.TektonV1alpha1().Conditions(cond.Namespace).Create(ctx, cond, metav1.CreateOptions{}); err != nil { - t.Fatal(err) - } - } for _, p := range d.Pods { if err := i.Pod.Informer().GetIndexer().Add(p); err != nil { t.Fatal(err) diff --git a/test/v1alpha1/pipelinerun_test.go b/test/v1alpha1/pipelinerun_test.go index dffe3a1964b..dd390e00141 100644 --- a/test/v1alpha1/pipelinerun_test.go +++ b/test/v1alpha1/pipelinerun_test.go @@ -130,39 +130,6 @@ spec: // 1 from PipelineRun and 1 from Tasks defined in pipelinerun expectedNumberOfEvents: 2, pipelineRunFunc: getHelloWorldPipelineRun, - }, { - name: "pipeline succeeds when task skipped due to failed condition", - testSetup: func(ctx context.Context, t *testing.T, c *clients, namespace string, index int) (map[string]*v1alpha1.PipelineResource, *v1alpha1.Pipeline) { - t.Helper() - cond := getFailingCondition(t, namespace) - if _, err := c.ConditionClient.Create(ctx, cond, metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create Condition `%s`: %s", cond.Name, err) - } - - task := parse.MustParseAlphaTask(t, fmt.Sprintf(` -metadata: - name: %s -spec: - steps: - - image: ubuntu - command: ['/bin/bash'] - args: ['-c', 'echo hello, world'] -`, helpers.ObjectNameForTest(t))) - - if _, err := c.TaskClient.Create(ctx, task, metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create Task `%s`: %s", task.Name, err) - } - p := getPipelineWithFailingCondition(t, task.Name, cond.Name) - if _, err := c.PipelineClient.Create(ctx, p, metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create Pipeline `%s`: %s", p.Name, err) - } - - return nil, p - }, - expectedTaskRuns: []string{}, - // 1 from PipelineRun; 0 from taskrun since it should not be executed due to condition failing - expectedNumberOfEvents: 1, - pipelineRunFunc: getConditionalPipelineRun, }} for i, td := range tds { @@ -673,47 +640,3 @@ func assertAnnotationsMatch(t *testing.T, expectedAnnotations, actualAnnotations } } } - -func getPipelineWithFailingCondition(t *testing.T, taskName, condName string) *v1alpha1.Pipeline { - return parse.MustParseAlphaPipeline(t, fmt.Sprintf(` -metadata: - name: %s -spec: - tasks: - - name: %s - taskRef: - name: %s - conditions: - - conditionRef: %s - - name: task2 - taskRef: - name: %s - runAfter: ['%s'] -`, helpers.ObjectNameForTest(t), task1Name, taskName, condName, taskName, task1Name)) -} - -func getFailingCondition(t *testing.T, namespace string) *v1alpha1.Condition { - return parse.MustParseCondition(t, fmt.Sprintf(` -metadata: - name: %s - namespace: %s -spec: - check: - image: ubuntu - command: ['/bin/bash'] - args: ['exit 1'] -`, helpers.ObjectNameForTest(t), namespace)) -} - -func getConditionalPipelineRun(t *testing.T, _ int, namespace string, pipelineName string, _ map[string]*v1alpha1.PipelineResource) *v1alpha1.PipelineRun { - return parse.MustParseAlphaPipelineRun(t, fmt.Sprintf(` -metadata: - name: %s - namespace: %s - labels: - hello-world-key: hello-world-vaule -spec: - pipelineRef: - name: %s -`, helpers.ObjectNameForTest(t), namespace, pipelineName)) -}