From cee55bb0f63d6dfd850a52dd9abfd79745b141ae Mon Sep 17 00:00:00 2001 From: Vibhav Bobade Date: Thu, 27 Feb 2025 23:03:11 +0530 Subject: [PATCH] remove ClusterTask --- cmd/webhook/main.go | 1 - config/200-clusterrole.yaml | 7 +- docs/pipeline-api.md | 224 +---------- .../pipelineruns/clustertask-pipelinerun.yaml | 32 -- examples/v1beta1/taskruns/clustertask.yaml | 19 - examples/v1beta1/taskruns/image-params.yaml | 25 -- examples/v1beta1/taskruns/no-ci/.keep | 0 go.mod | 5 +- pkg/apis/pipeline/controller.go | 3 - pkg/apis/pipeline/register.go | 8 - pkg/apis/pipeline/v1/pipeline_validation.go | 1 - .../pipeline/v1/pipeline_validation_test.go | 8 - pkg/apis/pipeline/v1/taskref_types.go | 3 - .../v1beta1/cluster_task_conversion.go | 42 -- .../v1beta1/cluster_task_conversion_test.go | 36 -- .../pipeline/v1beta1/cluster_task_defaults.go | 30 -- .../pipeline/v1beta1/cluster_task_types.go | 77 ---- .../v1beta1/cluster_task_validation.go | 38 -- .../pipeline/v1beta1/openapi_generated.go | 95 +---- .../pipeline/v1beta1/pipeline_validation.go | 1 - .../v1beta1/pipeline_validation_test.go | 8 - pkg/apis/pipeline/v1beta1/register.go | 2 - pkg/apis/pipeline/v1beta1/swagger.json | 53 +-- pkg/apis/pipeline/v1beta1/task_interface.go | 2 +- pkg/apis/pipeline/v1beta1/taskref_types.go | 5 +- .../pipeline/v1beta1/taskrun_defaults_test.go | 10 - pkg/apis/pipeline/v1beta1/types_test.go | 1 - .../pipeline/v1beta1/zz_generated.deepcopy.go | 60 --- .../typed/pipeline/v1beta1/clustertask.go | 67 ---- .../pipeline/v1beta1/fake/fake_clustertask.go | 126 ------ .../v1beta1/fake/fake_pipeline_client.go | 4 - .../pipeline/v1beta1/generated_expansion.go | 2 - .../typed/pipeline/v1beta1/pipeline_client.go | 5 - .../informers/externalversions/generic.go | 2 - .../pipeline/v1beta1/clustertask.go | 89 ----- .../pipeline/v1beta1/interface.go | 7 - .../v1beta1/clustertask/clustertask.go | 52 --- .../pipeline/v1beta1/clustertask/fake/fake.go | 40 -- .../clustertask/filtered/clustertask.go | 65 ---- .../v1beta1/clustertask/filtered/fake/fake.go | 52 --- .../v1beta1/clustertask/controller.go | 167 -------- .../v1beta1/clustertask/reconciler.go | 365 ------------------ .../pipeline/v1beta1/clustertask/state.go | 97 ----- .../listers/pipeline/v1beta1/clustertask.go | 48 --- .../pipeline/v1beta1/expansion_generated.go | 4 - pkg/reconciler/apiserver/apiserver_test.go | 9 - .../pipelinerun/pipelinerun_test.go | 50 --- .../resources/pipelinerunresolution_test.go | 3 - pkg/reconciler/taskrun/resources/taskref.go | 63 +-- .../taskrun/resources/taskref_test.go | 114 ------ pkg/reconciler/taskrun/taskrun.go | 6 +- pkg/reconciler/taskrun/taskrun_test.go | 154 +++----- pkg/remote/oci/resolver_test.go | 19 +- pkg/taskrunmetrics/metrics.go | 5 - pkg/taskrunmetrics/metrics_test.go | 36 -- pkg/trustedresources/verify_test.go | 10 - test/clients.go | 2 - test/controller.go | 11 - test/e2e-common.sh | 2 +- test/examples_test.go | 22 -- test/parse/yaml.go | 11 - test/util.go | 9 - 62 files changed, 63 insertions(+), 2451 deletions(-) delete mode 100644 examples/v1beta1/pipelineruns/clustertask-pipelinerun.yaml delete mode 100644 examples/v1beta1/taskruns/clustertask.yaml delete mode 100644 examples/v1beta1/taskruns/image-params.yaml delete mode 100644 examples/v1beta1/taskruns/no-ci/.keep delete mode 100644 pkg/apis/pipeline/v1beta1/cluster_task_conversion.go delete mode 100644 pkg/apis/pipeline/v1beta1/cluster_task_conversion_test.go delete mode 100644 pkg/apis/pipeline/v1beta1/cluster_task_defaults.go delete mode 100644 pkg/apis/pipeline/v1beta1/cluster_task_types.go delete mode 100644 pkg/apis/pipeline/v1beta1/cluster_task_validation.go delete mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1beta1/clustertask.go delete mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_clustertask.go delete mode 100644 pkg/client/informers/externalversions/pipeline/v1beta1/clustertask.go delete mode 100644 pkg/client/injection/informers/pipeline/v1beta1/clustertask/clustertask.go delete mode 100644 pkg/client/injection/informers/pipeline/v1beta1/clustertask/fake/fake.go delete mode 100644 pkg/client/injection/informers/pipeline/v1beta1/clustertask/filtered/clustertask.go delete mode 100644 pkg/client/injection/informers/pipeline/v1beta1/clustertask/filtered/fake/fake.go delete mode 100644 pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/controller.go delete mode 100644 pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/reconciler.go delete mode 100644 pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/state.go delete mode 100644 pkg/client/listers/pipeline/v1beta1/clustertask.go diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 7281f0af421..4b22c8bf94d 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -56,7 +56,6 @@ var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ // v1beta1 v1beta1.SchemeGroupVersion.WithKind("Pipeline"): &v1beta1.Pipeline{}, v1beta1.SchemeGroupVersion.WithKind("Task"): &v1beta1.Task{}, - v1beta1.SchemeGroupVersion.WithKind("ClusterTask"): &v1beta1.ClusterTask{}, v1beta1.SchemeGroupVersion.WithKind("TaskRun"): &v1beta1.TaskRun{}, v1beta1.SchemeGroupVersion.WithKind("PipelineRun"): &v1beta1.PipelineRun{}, v1beta1.SchemeGroupVersion.WithKind("CustomRun"): &v1beta1.CustomRun{}, diff --git a/config/200-clusterrole.yaml b/config/200-clusterrole.yaml index 2fd97b4a9f0..f8cd0f96288 100644 --- a/config/200-clusterrole.yaml +++ b/config/200-clusterrole.yaml @@ -32,7 +32,7 @@ rules: # Controller needs cluster access to all of the CRDs that it is responsible for # managing. - apiGroups: ["tekton.dev"] - resources: ["tasks", "clustertasks", "taskruns", "pipelines", "pipelineruns", "customruns", "stepactions"] + resources: ["tasks", "taskruns", "pipelines", "pipelineruns", "customruns", "stepactions"] verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] - apiGroups: ["tekton.dev"] resources: ["verificationpolicies"] @@ -41,7 +41,7 @@ rules: resources: ["taskruns/finalizers", "pipelineruns/finalizers", "customruns/finalizers"] verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] - apiGroups: ["tekton.dev"] - resources: ["tasks/status", "clustertasks/status", "taskruns/status", "pipelines/status", "pipelineruns/status", "customruns/status", "verificationpolicies/status", "stepactions/status"] + resources: ["tasks/status", "taskruns/status", "pipelines/status", "pipelineruns/status", "customruns/status", "verificationpolicies/status", "stepactions/status"] verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] # resolution.tekton.dev - apiGroups: ["resolution.tekton.dev"] @@ -93,7 +93,6 @@ rules: - pipelines.tekton.dev - pipelineruns.tekton.dev - tasks.tekton.dev - - clustertasks.tekton.dev - taskruns.tekton.dev - resolutionrequests.resolution.tekton.dev - customruns.tekton.dev @@ -148,5 +147,5 @@ metadata: app.kubernetes.io/part-of: tekton-pipelines rules: - apiGroups: ["tekton.dev"] - resources: ["tasks", "clustertasks", "taskruns", "pipelines", "pipelineruns", "customruns"] + resources: ["tasks", "taskruns", "pipelines", "pipelineruns", "customruns"] verbs: ["get", "list", "watch"] diff --git a/docs/pipeline-api.md b/docs/pipeline-api.md index d013bca86cb..03a4110de68 100644 --- a/docs/pipeline-api.md +++ b/docs/pipeline-api.md @@ -5170,11 +5170,7 @@ failed step will not exit

Description -

"ClusterTask"

-

ClusterTaskRefKind is the task type for a reference to a task with cluster scope. -ClusterTasks are not supported in v1, but v1 types may reference ClusterTasks.

- -

"Task"

+

"Task"

NamespacedTaskKind indicates that the task type has a namespaced scope.

@@ -8470,8 +8466,6 @@ controller.

Resource Types: -

ClusterTask -

-
-

ClusterTask is a Task with a cluster scope. ClusterTasks are used to -represent Tasks that should be publicly addressable from any namespace in the -cluster.

-

Deprecated: Please use the cluster resolver instead.

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescription
-apiVersion
-string
- -tekton.dev/v1beta1 - -
-kind
-string -
ClusterTask
-metadata
- - -Kubernetes meta/v1.ObjectMeta - - -
-(Optional) -Refer to the Kubernetes API documentation for the fields of the -metadata field. -
-spec
- - -TaskSpec - - -
-(Optional) -

Spec holds the desired state of the Task from the client

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-resources
- - -TaskResources - - -
-(Optional) -

Resources is a list input and output resource to run the task -Resources are represented in TaskRuns as bindings to instances of -PipelineResources.

-

Deprecated: Unused, preserved only for backwards compatibility

-
-params
- - -ParamSpecs - - -
-(Optional) -

Params is a list of input parameters required to run the task. Params -must be supplied as inputs in TaskRuns unless they declare a default -value.

-
-displayName
- -string - -
-(Optional) -

DisplayName is a user-facing name of the task that may be -used to populate a UI.

-
-description
- -string - -
-(Optional) -

Description is a user-facing description of the task that may be -used to populate a UI.

-
-steps
- - -[]Step - - -
-

Steps are the steps of the build; each step is run sequentially with the -source mounted into /workspace.

-
-volumes
- - -[]Kubernetes core/v1.Volume - - -
-

Volumes is a collection of volumes that are available to mount into the -steps of the build.

-
-stepTemplate
- - -StepTemplate - - -
-

StepTemplate can be used as the basis for all step containers within the -Task, so that the steps inherit settings on the base container.

-
-sidecars
- - -[]Sidecar - - -
-

Sidecars are run alongside the Task’s step containers. They begin before -the steps start and end after the steps complete.

-
-workspaces
- - -[]WorkspaceDeclaration - - -
-

Workspaces are the volumes that this Task requires.

-
-results
- - -[]TaskResult - - -
-

Results are values that this Task can output

-
-

CustomRun

@@ -14967,7 +14752,7 @@ failed step will not exit

TaskObject

-

TaskObject is implemented by Task and ClusterTask

+

TaskObject is implemented by Task

TaskRef

@@ -15008,8 +14793,7 @@ TaskKind

TaskKind indicates the Kind of the Task: 1. Namespaced Task when Kind is set to “Task”. If Kind is “”, it defaults to “Task”. -2. Cluster-Scoped Task when Kind is set to “ClusterTask” -3. Custom Task when Kind is non-empty and APIVersion is non-empty

+2. Custom Task when Kind is non-empty and APIVersion is non-empty

@@ -16054,7 +15838,7 @@ Kubernetes core/v1.ResourceRequirements

TaskSpec

-(Appears on:ClusterTask, Task, EmbeddedTask, TaskRunSpec, TaskRunStatusFields) +(Appears on:Task, EmbeddedTask, TaskRunSpec, TaskRunStatusFields)

TaskSpec defines the desired state of Task.

diff --git a/examples/v1beta1/pipelineruns/clustertask-pipelinerun.yaml b/examples/v1beta1/pipelineruns/clustertask-pipelinerun.yaml deleted file mode 100644 index 458043ca5dd..00000000000 --- a/examples/v1beta1/pipelineruns/clustertask-pipelinerun.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Note: ClusterTasks are deprecated. Please use the cluster resolver instead. -# https://github.com/tektoncd/pipeline/blob/main/docs/cluster-resolver.md -apiVersion: tekton.dev/v1beta1 -kind: ClusterTask -metadata: - name: cluster-task-pipeline-4 -spec: - steps: - - name: task-two-step-one - image: mirror.gcr.io/ubuntu - command: ["/bin/bash"] - args: ['-c', 'echo success'] ---- -apiVersion: tekton.dev/v1beta1 -kind: Pipeline -metadata: - name: sample-pipeline-cluster-task-4 -spec: - tasks: - - name: cluster-task-pipeline-4 - taskRef: - name: cluster-task-pipeline-4 - kind: ClusterTask ---- -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - name: demo-pipeline-run-4 -spec: - pipelineRef: - name: sample-pipeline-cluster-task-4 - serviceAccountName: 'default' diff --git a/examples/v1beta1/taskruns/clustertask.yaml b/examples/v1beta1/taskruns/clustertask.yaml deleted file mode 100644 index 1dd8b6b8696..00000000000 --- a/examples/v1beta1/taskruns/clustertask.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Note: ClusterTasks are deprecated. Please use the cluster resolver instead. -# https://github.com/tektoncd/pipeline/blob/main/docs/cluster-resolver.md -apiVersion: tekton.dev/v1beta1 -kind: ClusterTask -metadata: - name: clustertask-v1beta1 -spec: - steps: - - image: mirror.gcr.io/ubuntu - script: echo hello ---- -apiVersion: tekton.dev/v1beta1 -kind: TaskRun -metadata: - generateName: clustertask- -spec: - taskRef: - name: clustertask-v1beta1 - kind: ClusterTask diff --git a/examples/v1beta1/taskruns/image-params.yaml b/examples/v1beta1/taskruns/image-params.yaml deleted file mode 100644 index ec1f4f85be0..00000000000 --- a/examples/v1beta1/taskruns/image-params.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: tekton.dev/v1beta1 -kind: ClusterTask -metadata: - name: image-params -spec: - params: - - name: image - type: string - default: ubuntu - - name: imagePullPolicy - type: string - default: IfNotPresent - steps: - - image: $(params.image) - imagePullPolicy: $(params.imagePullPolicy) - script: echo hello ---- -apiVersion: tekton.dev/v1beta1 -kind: TaskRun -metadata: - generateName: image-params- -spec: - taskRef: - name: image-params - kind: ClusterTask diff --git a/examples/v1beta1/taskruns/no-ci/.keep b/examples/v1beta1/taskruns/no-ci/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/go.mod b/go.mod index 55734c70d8a..bfa4a870453 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,8 @@ module github.com/tektoncd/pipeline -go 1.22.7 -toolchain go1.23.4 +go 1.22.11 + +toolchain go1.24.0 require ( github.com/Microsoft/go-winio v0.6.2 // indirect diff --git a/pkg/apis/pipeline/controller.go b/pkg/apis/pipeline/controller.go index 5f155007093..a5b2580c30b 100644 --- a/pkg/apis/pipeline/controller.go +++ b/pkg/apis/pipeline/controller.go @@ -29,9 +29,6 @@ const ( // TaskControllerName holds the name of the Task controller TaskControllerName = "Task" - // ClusterTaskControllerName holds the name of the Task controller - ClusterTaskControllerName = "ClusterTask" - // RunControllerName holds the name of the Custom Task controller RunControllerName = "Run" diff --git a/pkg/apis/pipeline/register.go b/pkg/apis/pipeline/register.go index 9971a9b79d6..40662f31882 100644 --- a/pkg/apis/pipeline/register.go +++ b/pkg/apis/pipeline/register.go @@ -22,9 +22,6 @@ const ( // GroupName is the Kubernetes resource group name for Pipeline types. GroupName = "tekton.dev" - // ClusterTaskLabelKey is used as the label identifier for a ClusterTask - ClusterTaskLabelKey = GroupName + "/clusterTask" - // StepActionLabelKey is used as the label identifier for a StepAction StepActionLabelKey = GroupName + "/stepAction" @@ -71,11 +68,6 @@ var ( Group: GroupName, Resource: "tasks", } - // ClusterTaskResource represents a Tekton ClusterTask - ClusterTaskResource = schema.GroupResource{ - Group: GroupName, - Resource: "clustertasks", - } // TaskRunResource represents a Tekton TaskRun TaskRunResource = schema.GroupResource{ Group: GroupName, diff --git a/pkg/apis/pipeline/v1/pipeline_validation.go b/pkg/apis/pipeline/v1/pipeline_validation.go index c17293a02b9..718252a0aea 100644 --- a/pkg/apis/pipeline/v1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1/pipeline_validation.go @@ -188,7 +188,6 @@ func (pt PipelineTask) Validate(ctx context.Context) (errs *apis.FieldError) { taskKinds := map[TaskKind]bool{ "": true, NamespacedTaskKind: true, - ClusterTaskRefKind: true, } if pt.OnError != "" { diff --git a/pkg/apis/pipeline/v1/pipeline_validation_test.go b/pkg/apis/pipeline/v1/pipeline_validation_test.go index 2dd9b22d55b..78efda9fa88 100644 --- a/pkg/apis/pipeline/v1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1/pipeline_validation_test.go @@ -80,14 +80,6 @@ func TestPipeline_Validate_Success(t *testing.T) { Tasks: []PipelineTask{{Name: "foo", TaskRef: &TaskRef{Name: "bar", Kind: NamespacedTaskKind}}}, }, }, - }, { - name: "valid reference to clusterTask", - p: &Pipeline{ - ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: PipelineSpec{ - Tasks: []PipelineTask{{Name: "foo", TaskRef: &TaskRef{Name: "bar", Kind: ClusterTaskRefKind}}}, - }, - }, }, { name: "valid task with pipelineRef", wc: cfgtesting.EnableAlphaAPIFields, diff --git a/pkg/apis/pipeline/v1/taskref_types.go b/pkg/apis/pipeline/v1/taskref_types.go index f7558333cfc..2bb395dac27 100644 --- a/pkg/apis/pipeline/v1/taskref_types.go +++ b/pkg/apis/pipeline/v1/taskref_types.go @@ -42,9 +42,6 @@ type TaskKind string const ( // NamespacedTaskKind indicates that the task type has a namespaced scope. NamespacedTaskKind TaskKind = "Task" - // ClusterTaskRefKind is the task type for a reference to a task with cluster scope. - // ClusterTasks are not supported in v1, but v1 types may reference ClusterTasks. - ClusterTaskRefKind TaskKind = "ClusterTask" ) // IsCustomTask checks whether the reference is to a Custom Task diff --git a/pkg/apis/pipeline/v1beta1/cluster_task_conversion.go b/pkg/apis/pipeline/v1beta1/cluster_task_conversion.go deleted file mode 100644 index e7bac12b36d..00000000000 --- a/pkg/apis/pipeline/v1beta1/cluster_task_conversion.go +++ /dev/null @@ -1,42 +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 ( - "context" - "fmt" - - "knative.dev/pkg/apis" -) - -var _ apis.Convertible = (*ClusterTask)(nil) - -// ConvertTo implements apis.Convertible -func (ct *ClusterTask) ConvertTo(ctx context.Context, sink apis.Convertible) error { - if apis.IsInDelete(ctx) { - return nil - } - return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) -} - -// ConvertFrom implements apis.Convertible -func (ct *ClusterTask) ConvertFrom(ctx context.Context, source apis.Convertible) error { - if apis.IsInDelete(ctx) { - return nil - } - return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) -} diff --git a/pkg/apis/pipeline/v1beta1/cluster_task_conversion_test.go b/pkg/apis/pipeline/v1beta1/cluster_task_conversion_test.go deleted file mode 100644 index 8dce05a0e3f..00000000000 --- a/pkg/apis/pipeline/v1beta1/cluster_task_conversion_test.go +++ /dev/null @@ -1,36 +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 v1beta1_test - -import ( - "context" - "testing" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" -) - -func TestClusterTaskConversionBadType(t *testing.T) { - good, bad := &v1beta1.ClusterTask{}, &v1beta1.Pipeline{} - - if err := good.ConvertTo(context.Background(), bad); err == nil { - t.Errorf("ConvertTo() = %#v, wanted error", bad) - } - - if err := good.ConvertFrom(context.Background(), bad); err == nil { - t.Errorf("ConvertFrom() = %#v, wanted error", good) - } -} diff --git a/pkg/apis/pipeline/v1beta1/cluster_task_defaults.go b/pkg/apis/pipeline/v1beta1/cluster_task_defaults.go deleted file mode 100644 index fda6d76eadc..00000000000 --- a/pkg/apis/pipeline/v1beta1/cluster_task_defaults.go +++ /dev/null @@ -1,30 +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 ( - "context" - - "knative.dev/pkg/apis" -) - -var _ apis.Defaultable = (*ClusterTask)(nil) - -// SetDefaults sets the default values for the ClusterTask's Spec. -func (t *ClusterTask) SetDefaults(ctx context.Context) { - t.Spec.SetDefaults(ctx) -} diff --git a/pkg/apis/pipeline/v1beta1/cluster_task_types.go b/pkg/apis/pipeline/v1beta1/cluster_task_types.go deleted file mode 100644 index aaaf03b9cf7..00000000000 --- a/pkg/apis/pipeline/v1beta1/cluster_task_types.go +++ /dev/null @@ -1,77 +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 ( - "github.com/tektoncd/pipeline/pkg/apis/pipeline" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +genclient:noStatus -// +genclient:nonNamespaced -// +genreconciler:krshapedlogic=false -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ClusterTask is a Task with a cluster scope. ClusterTasks are used to -// represent Tasks that should be publicly addressable from any namespace in the -// cluster. -// -// Deprecated: Please use the cluster resolver instead. -type ClusterTask struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Spec holds the desired state of the Task from the client - // +optional - Spec TaskSpec `json:"spec,omitempty"` -} - -var _ kmeta.OwnerRefable = (*ClusterTask)(nil) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ClusterTaskList contains a list of ClusterTask -type ClusterTaskList struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - Items []ClusterTask `json:"items"` -} - -// TaskSpec returns the ClusterTask's Spec -func (t *ClusterTask) TaskSpec() TaskSpec { - return t.Spec -} - -// TaskMetadata returns the ObjectMeta for the ClusterTask -func (t *ClusterTask) TaskMetadata() metav1.ObjectMeta { - return t.ObjectMeta -} - -// Copy returns a DeepCopy of the ClusterTask -func (t *ClusterTask) Copy() TaskObject { - return t.DeepCopy() -} - -// GetGroupVersionKind implements kmeta.OwnerRefable. -func (*ClusterTask) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind(pipeline.ClusterTaskControllerName) -} diff --git a/pkg/apis/pipeline/v1beta1/cluster_task_validation.go b/pkg/apis/pipeline/v1beta1/cluster_task_validation.go deleted file mode 100644 index 5dfa6278c48..00000000000 --- a/pkg/apis/pipeline/v1beta1/cluster_task_validation.go +++ /dev/null @@ -1,38 +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 ( - "context" - - "github.com/tektoncd/pipeline/pkg/apis/validate" - "knative.dev/pkg/apis" -) - -var _ apis.Validatable = (*ClusterTask)(nil) - -// Validate performs validation of the metadata and spec of this ClusterTask. -func (t *ClusterTask) Validate(ctx context.Context) *apis.FieldError { - if apis.IsInDelete(ctx) { - return nil - } - errs := validate.ObjectMetadata(t.GetObjectMeta()).ViaField("metadata") - errs = errs.Also(t.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) - // We do not support propagated parameters in ClusterTasks. - // Validate that all params the ClusterTask uses are declared. - return errs.Also(ValidateUsageOfDeclaredParameters(ctx, t.Spec.Steps, t.Spec.Params)) -} diff --git a/pkg/apis/pipeline/v1beta1/openapi_generated.go b/pkg/apis/pipeline/v1beta1/openapi_generated.go index b87eecea0bf..26bd4820568 100644 --- a/pkg/apis/pipeline/v1beta1/openapi_generated.go +++ b/pkg/apis/pipeline/v1beta1/openapi_generated.go @@ -36,8 +36,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "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.ConfigSource": schema_pkg_apis_pipeline_v1beta1_ConfigSource(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CustomRun": schema_pkg_apis_pipeline_v1beta1_CustomRun(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CustomRunList": schema_pkg_apis_pipeline_v1beta1_CustomRunList(ref), @@ -683,97 +681,6 @@ func schema_pkg_apis_pipeline_v1beta1_CloudEventDeliveryState(ref common.Referen } } -func schema_pkg_apis_pipeline_v1beta1_ClusterTask(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ClusterTask is a Task with a cluster scope. ClusterTasks are used to represent Tasks that should be publicly addressable from any namespace in the cluster.\n\nDeprecated: Please use the cluster resolver instead.", - 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{ - Description: "Spec holds the desired state of the Task from the client", - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskSpec"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, - } -} - -func schema_pkg_apis_pipeline_v1beta1_ClusterTaskList(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ClusterTaskList contains a list of ClusterTask", - 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.ListMeta"), - }, - }, - "items": { - SchemaProps: spec.SchemaProps{ - 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.ClusterTask"), - }, - }, - }, - }, - }, - }, - Required: []string{"items"}, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTask", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, - } -} - func schema_pkg_apis_pipeline_v1beta1_ConfigSource(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -4910,7 +4817,7 @@ func schema_pkg_apis_pipeline_v1beta1_TaskRef(ref common.ReferenceCallback) comm }, "kind": { SchemaProps: spec.SchemaProps{ - Description: "TaskKind indicates the Kind of the Task: 1. Namespaced Task when Kind is set to \"Task\". If Kind is \"\", it defaults to \"Task\". 2. Cluster-Scoped Task when Kind is set to \"ClusterTask\" 3. Custom Task when Kind is non-empty and APIVersion is non-empty", + Description: "TaskKind indicates the Kind of the Task: 1. Namespaced Task when Kind is set to \"Task\". If Kind is \"\", it defaults to \"Task\". 2. Custom Task when Kind is non-empty and APIVersion is non-empty", Type: []string{"string"}, Format: "", }, diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation.go b/pkg/apis/pipeline/v1beta1/pipeline_validation.go index 8f8d6a1f002..b8345db6b22 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation.go @@ -193,7 +193,6 @@ func (pt PipelineTask) Validate(ctx context.Context) (errs *apis.FieldError) { taskKinds := map[TaskKind]bool{ "": true, NamespacedTaskKind: true, - ClusterTaskKind: true, } if pt.OnError != "" { diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go index 234f7832676..94ffd31fac9 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go @@ -80,14 +80,6 @@ func TestPipeline_Validate_Success(t *testing.T) { Tasks: []PipelineTask{{Name: "foo", TaskRef: &TaskRef{Name: "bar", Kind: NamespacedTaskKind}}}, }, }, - }, { - name: "valid Cluster Task without apiversion", - p: &Pipeline{ - ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: PipelineSpec{ - Tasks: []PipelineTask{{Name: "foo", TaskRef: &TaskRef{Name: "task", Kind: ClusterTaskKind}}}, - }, - }, }, { name: "valid task with pipelineRef", wc: cfgtesting.EnableAlphaAPIFields, diff --git a/pkg/apis/pipeline/v1beta1/register.go b/pkg/apis/pipeline/v1beta1/register.go index c33fa8a848b..e5164996a71 100644 --- a/pkg/apis/pipeline/v1beta1/register.go +++ b/pkg/apis/pipeline/v1beta1/register.go @@ -50,8 +50,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { &TaskList{}, &Pipeline{}, &PipelineList{}, - &ClusterTask{}, - &ClusterTaskList{}, &TaskRun{}, &TaskRunList{}, &PipelineRun{}, diff --git a/pkg/apis/pipeline/v1beta1/swagger.json b/pkg/apis/pipeline/v1beta1/swagger.json index 7e2d8d9d95c..a48fb473430 100644 --- a/pkg/apis/pipeline/v1beta1/swagger.json +++ b/pkg/apis/pipeline/v1beta1/swagger.json @@ -294,57 +294,6 @@ } } }, - "v1beta1.ClusterTask": { - "description": "ClusterTask is a Task with a cluster scope. ClusterTasks are used to represent Tasks that should be publicly addressable from any namespace in the cluster.\n\nDeprecated: Please use the cluster resolver instead.", - "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": { - "description": "Spec holds the desired state of the Task from the client", - "default": {}, - "$ref": "#/definitions/v1beta1.TaskSpec" - } - } - }, - "v1beta1.ClusterTaskList": { - "description": "ClusterTaskList contains a list of ClusterTask", - "type": "object", - "required": [ - "items" - ], - "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" - }, - "items": { - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1beta1.ClusterTask" - } - }, - "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.ListMeta" - } - } - }, "v1beta1.ConfigSource": { "description": "ConfigSource contains the information that can uniquely identify where a remote built definition came from i.e. Git repositories, Tekton Bundles in OCI registry and hub.", "type": "object", @@ -2702,7 +2651,7 @@ "type": "string" }, "kind": { - "description": "TaskKind indicates the Kind of the Task: 1. Namespaced Task when Kind is set to \"Task\". If Kind is \"\", it defaults to \"Task\". 2. Cluster-Scoped Task when Kind is set to \"ClusterTask\" 3. Custom Task when Kind is non-empty and APIVersion is non-empty", + "description": "TaskKind indicates the Kind of the Task: 1. Namespaced Task when Kind is set to \"Task\". If Kind is \"\", it defaults to \"Task\". 2. Custom Task when Kind is non-empty and APIVersion is non-empty", "type": "string" }, "name": { diff --git a/pkg/apis/pipeline/v1beta1/task_interface.go b/pkg/apis/pipeline/v1beta1/task_interface.go index ac018081be0..91acc8327c5 100644 --- a/pkg/apis/pipeline/v1beta1/task_interface.go +++ b/pkg/apis/pipeline/v1beta1/task_interface.go @@ -21,7 +21,7 @@ import ( "knative.dev/pkg/apis" ) -// TaskObject is implemented by Task and ClusterTask +// TaskObject is implemented by Task type TaskObject interface { apis.Defaultable TaskMetadata() metav1.ObjectMeta diff --git a/pkg/apis/pipeline/v1beta1/taskref_types.go b/pkg/apis/pipeline/v1beta1/taskref_types.go index 9781a4a2133..b3bb2c9f1e4 100644 --- a/pkg/apis/pipeline/v1beta1/taskref_types.go +++ b/pkg/apis/pipeline/v1beta1/taskref_types.go @@ -22,8 +22,7 @@ type TaskRef struct { Name string `json:"name,omitempty"` // TaskKind indicates the Kind of the Task: // 1. Namespaced Task when Kind is set to "Task". If Kind is "", it defaults to "Task". - // 2. Cluster-Scoped Task when Kind is set to "ClusterTask" - // 3. Custom Task when Kind is non-empty and APIVersion is non-empty + // 2. Custom Task when Kind is non-empty and APIVersion is non-empty Kind TaskKind `json:"kind,omitempty"` // API version of the referent // Note: A Task with non-empty APIVersion and Kind is considered a Custom Task @@ -51,8 +50,6 @@ type TaskKind string const ( // NamespacedTaskKind indicates that the task type has a namespaced scope. NamespacedTaskKind TaskKind = "Task" - // ClusterTaskKind indicates that task type has a cluster scope. - ClusterTaskKind TaskKind = "ClusterTask" ) // IsCustomTask checks whether the reference is to a Custom Task diff --git a/pkg/apis/pipeline/v1beta1/taskrun_defaults_test.go b/pkg/apis/pipeline/v1beta1/taskrun_defaults_test.go index f0801824d85..0ee24d91f2d 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_defaults_test.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_defaults_test.go @@ -64,16 +64,6 @@ func TestTaskRunSpec_SetDefaults(t *testing.T) { ServiceAccountName: config.DefaultServiceAccountValue, Timeout: &metav1.Duration{Duration: 500 * time.Millisecond}, }, - }, { - desc: "timeout is nil", - trs: &v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{Kind: v1beta1.ClusterTaskKind}, - }, - want: &v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{Kind: v1beta1.ClusterTaskKind}, - ServiceAccountName: config.DefaultServiceAccountValue, - Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute}, - }, }, { desc: "pod template is nil", trs: &v1beta1.TaskRunSpec{}, diff --git a/pkg/apis/pipeline/v1beta1/types_test.go b/pkg/apis/pipeline/v1beta1/types_test.go index 546b8fce5db..6304c03a798 100644 --- a/pkg/apis/pipeline/v1beta1/types_test.go +++ b/pkg/apis/pipeline/v1beta1/types_test.go @@ -25,7 +25,6 @@ import ( func TestTypes(t *testing.T) { // Assert that types satisfy webhook interface. - // var _ resourcesemantics.GenericCRD = (*v1beta1.ClusterTask)(nil) var _ resourcesemantics.GenericCRD = (*v1beta1.TaskRun)(nil) var _ resourcesemantics.GenericCRD = (*v1beta1.Task)(nil) var _ resourcesemantics.GenericCRD = (*v1beta1.Pipeline)(nil) diff --git a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go index 8c2afe35a6f..837040d7846 100644 --- a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go @@ -170,66 +170,6 @@ func (in *CloudEventDeliveryState) DeepCopy() *CloudEventDeliveryState { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterTask) DeepCopyInto(out *ClusterTask) { - *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 ClusterTask. -func (in *ClusterTask) DeepCopy() *ClusterTask { - if in == nil { - return nil - } - out := new(ClusterTask) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterTask) 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 *ClusterTaskList) DeepCopyInto(out *ClusterTaskList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ClusterTask, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterTaskList. -func (in *ClusterTaskList) DeepCopy() *ClusterTaskList { - if in == nil { - return nil - } - out := new(ClusterTaskList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterTaskList) 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 Combination) DeepCopyInto(out *Combination) { { diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/clustertask.go b/pkg/client/clientset/versioned/typed/pipeline/v1beta1/clustertask.go deleted file mode 100644 index 7fe66809358..00000000000 --- a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/clustertask.go +++ /dev/null @@ -1,67 +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 v1beta1 - -import ( - "context" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - 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" - gentype "k8s.io/client-go/gentype" -) - -// ClusterTasksGetter has a method to return a ClusterTaskInterface. -// A group's client should implement this interface. -type ClusterTasksGetter interface { - ClusterTasks() ClusterTaskInterface -} - -// ClusterTaskInterface has methods to work with ClusterTask resources. -type ClusterTaskInterface interface { - Create(ctx context.Context, clusterTask *v1beta1.ClusterTask, opts v1.CreateOptions) (*v1beta1.ClusterTask, error) - Update(ctx context.Context, clusterTask *v1beta1.ClusterTask, opts v1.UpdateOptions) (*v1beta1.ClusterTask, 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) (*v1beta1.ClusterTask, error) - List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ClusterTaskList, 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 *v1beta1.ClusterTask, err error) - ClusterTaskExpansion -} - -// clusterTasks implements ClusterTaskInterface -type clusterTasks struct { - *gentype.ClientWithList[*v1beta1.ClusterTask, *v1beta1.ClusterTaskList] -} - -// newClusterTasks returns a ClusterTasks -func newClusterTasks(c *TektonV1beta1Client) *clusterTasks { - return &clusterTasks{ - gentype.NewClientWithList[*v1beta1.ClusterTask, *v1beta1.ClusterTaskList]( - "clustertasks", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1beta1.ClusterTask { return &v1beta1.ClusterTask{} }, - func() *v1beta1.ClusterTaskList { return &v1beta1.ClusterTaskList{} }), - } -} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_clustertask.go b/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_clustertask.go deleted file mode 100644 index 2fcf6a04080..00000000000 --- a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_clustertask.go +++ /dev/null @@ -1,126 +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" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeClusterTasks implements ClusterTaskInterface -type FakeClusterTasks struct { - Fake *FakeTektonV1beta1 -} - -var clustertasksResource = v1beta1.SchemeGroupVersion.WithResource("clustertasks") - -var clustertasksKind = v1beta1.SchemeGroupVersion.WithKind("ClusterTask") - -// Get takes name of the clusterTask, and returns the corresponding clusterTask object, and an error if there is any. -func (c *FakeClusterTasks) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ClusterTask, err error) { - emptyResult := &v1beta1.ClusterTask{} - obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(clustertasksResource, name, options), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.ClusterTask), err -} - -// List takes label and field selectors, and returns the list of ClusterTasks that match those selectors. -func (c *FakeClusterTasks) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ClusterTaskList, err error) { - emptyResult := &v1beta1.ClusterTaskList{} - obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(clustertasksResource, clustertasksKind, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.ClusterTaskList{ListMeta: obj.(*v1beta1.ClusterTaskList).ListMeta} - for _, item := range obj.(*v1beta1.ClusterTaskList).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 clusterTasks. -func (c *FakeClusterTasks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(clustertasksResource, opts)) -} - -// Create takes the representation of a clusterTask and creates it. Returns the server's representation of the clusterTask, and an error, if there is any. -func (c *FakeClusterTasks) Create(ctx context.Context, clusterTask *v1beta1.ClusterTask, opts v1.CreateOptions) (result *v1beta1.ClusterTask, err error) { - emptyResult := &v1beta1.ClusterTask{} - obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(clustertasksResource, clusterTask, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.ClusterTask), err -} - -// Update takes the representation of a clusterTask and updates it. Returns the server's representation of the clusterTask, and an error, if there is any. -func (c *FakeClusterTasks) Update(ctx context.Context, clusterTask *v1beta1.ClusterTask, opts v1.UpdateOptions) (result *v1beta1.ClusterTask, err error) { - emptyResult := &v1beta1.ClusterTask{} - obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(clustertasksResource, clusterTask, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.ClusterTask), err -} - -// Delete takes name of the clusterTask and deletes it. Returns an error if one occurs. -func (c *FakeClusterTasks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(clustertasksResource, name, opts), &v1beta1.ClusterTask{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeClusterTasks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(clustertasksResource, opts, listOpts) - - _, err := c.Fake.Invokes(action, &v1beta1.ClusterTaskList{}) - return err -} - -// Patch applies the patch and returns the patched clusterTask. -func (c *FakeClusterTasks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ClusterTask, err error) { - emptyResult := &v1beta1.ClusterTask{} - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(clustertasksResource, name, pt, data, opts, subresources...), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.ClusterTask), err -} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_pipeline_client.go index 326e2fbb252..b4bc7d28b24 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_pipeline_client.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_pipeline_client.go @@ -28,10 +28,6 @@ type FakeTektonV1beta1 struct { *testing.Fake } -func (c *FakeTektonV1beta1) ClusterTasks() v1beta1.ClusterTaskInterface { - return &FakeClusterTasks{c} -} - func (c *FakeTektonV1beta1) CustomRuns(namespace string) v1beta1.CustomRunInterface { return &FakeCustomRuns{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/pipeline/v1beta1/generated_expansion.go index 87f277c5c7a..14e3f6b8f28 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1beta1/generated_expansion.go @@ -18,8 +18,6 @@ limitations under the License. package v1beta1 -type ClusterTaskExpansion interface{} - type CustomRunExpansion interface{} type PipelineExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1beta1/pipeline_client.go index fcd65e7ce35..cf722037731 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1beta1/pipeline_client.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1beta1/pipeline_client.go @@ -28,7 +28,6 @@ import ( type TektonV1beta1Interface interface { RESTClient() rest.Interface - ClusterTasksGetter CustomRunsGetter PipelinesGetter PipelineRunsGetter @@ -42,10 +41,6 @@ type TektonV1beta1Client struct { restClient rest.Interface } -func (c *TektonV1beta1Client) ClusterTasks() ClusterTaskInterface { - return newClusterTasks(c) -} - func (c *TektonV1beta1Client) CustomRuns(namespace string) CustomRunInterface { return newCustomRuns(c, namespace) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index fe44a25ab11..c5327619948 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -73,8 +73,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1alpha1().VerificationPolicies().Informer()}, nil // Group=tekton.dev, Version=v1beta1 - case v1beta1.SchemeGroupVersion.WithResource("clustertasks"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1beta1().ClusterTasks().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("customruns"): return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1beta1().CustomRuns().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("pipelines"): diff --git a/pkg/client/informers/externalversions/pipeline/v1beta1/clustertask.go b/pkg/client/informers/externalversions/pipeline/v1beta1/clustertask.go deleted file mode 100644 index 8c006c47df6..00000000000 --- a/pkg/client/informers/externalversions/pipeline/v1beta1/clustertask.go +++ /dev/null @@ -1,89 +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 v1beta1 - -import ( - "context" - time "time" - - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - versioned "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - internalinterfaces "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/internalinterfaces" - v1beta1 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" - 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" -) - -// ClusterTaskInformer provides access to a shared informer and lister for -// ClusterTasks. -type ClusterTaskInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1beta1.ClusterTaskLister -} - -type clusterTaskInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewClusterTaskInformer constructs a new informer for ClusterTask 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 NewClusterTaskInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredClusterTaskInformer(client, resyncPeriod, indexers, nil) -} - -// NewFilteredClusterTaskInformer constructs a new informer for ClusterTask 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 NewFilteredClusterTaskInformer(client versioned.Interface, 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.TektonV1beta1().ClusterTasks().List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.TektonV1beta1().ClusterTasks().Watch(context.TODO(), options) - }, - }, - &pipelinev1beta1.ClusterTask{}, - resyncPeriod, - indexers, - ) -} - -func (f *clusterTaskInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredClusterTaskInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *clusterTaskInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&pipelinev1beta1.ClusterTask{}, f.defaultInformer) -} - -func (f *clusterTaskInformer) Lister() v1beta1.ClusterTaskLister { - return v1beta1.NewClusterTaskLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/externalversions/pipeline/v1beta1/interface.go b/pkg/client/informers/externalversions/pipeline/v1beta1/interface.go index 2821b942ca9..4256abd2627 100644 --- a/pkg/client/informers/externalversions/pipeline/v1beta1/interface.go +++ b/pkg/client/informers/externalversions/pipeline/v1beta1/interface.go @@ -24,8 +24,6 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // ClusterTasks returns a ClusterTaskInformer. - ClusterTasks() ClusterTaskInformer // CustomRuns returns a CustomRunInformer. CustomRuns() CustomRunInformer // Pipelines returns a PipelineInformer. @@ -51,11 +49,6 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// ClusterTasks returns a ClusterTaskInformer. -func (v *version) ClusterTasks() ClusterTaskInformer { - return &clusterTaskInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - // CustomRuns returns a CustomRunInformer. func (v *version) CustomRuns() CustomRunInformer { return &customRunInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/injection/informers/pipeline/v1beta1/clustertask/clustertask.go b/pkg/client/injection/informers/pipeline/v1beta1/clustertask/clustertask.go deleted file mode 100644 index 7626993d1db..00000000000 --- a/pkg/client/injection/informers/pipeline/v1beta1/clustertask/clustertask.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 clustertask - -import ( - context "context" - - v1beta1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1" - factory "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterInformer(withInformer) -} - -// 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().V1beta1().ClusterTasks() - return context.WithValue(ctx, Key{}, inf), inf.Informer() -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context) v1beta1.ClusterTaskInformer { - untyped := ctx.Value(Key{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1.ClusterTaskInformer from context.") - } - return untyped.(v1beta1.ClusterTaskInformer) -} diff --git a/pkg/client/injection/informers/pipeline/v1beta1/clustertask/fake/fake.go b/pkg/client/injection/informers/pipeline/v1beta1/clustertask/fake/fake.go deleted file mode 100644 index bdc51ac14f6..00000000000 --- a/pkg/client/injection/informers/pipeline/v1beta1/clustertask/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" - clustertask "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" -) - -var Get = clustertask.Get - -func init() { - injection.Fake.RegisterInformer(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := fake.Get(ctx) - inf := f.Tekton().V1beta1().ClusterTasks() - return context.WithValue(ctx, clustertask.Key{}, inf), inf.Informer() -} diff --git a/pkg/client/injection/informers/pipeline/v1beta1/clustertask/filtered/clustertask.go b/pkg/client/injection/informers/pipeline/v1beta1/clustertask/filtered/clustertask.go deleted file mode 100644 index 4efdbc7419b..00000000000 --- a/pkg/client/injection/informers/pipeline/v1beta1/clustertask/filtered/clustertask.go +++ /dev/null @@ -1,65 +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" - - v1beta1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1" - filtered "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterFilteredInformers(withInformer) -} - -// 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().V1beta1().ClusterTasks() - ctx = context.WithValue(ctx, Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context, selector string) v1beta1.ClusterTaskInformer { - 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/v1beta1.ClusterTaskInformer with selector %s from context.", selector) - } - return untyped.(v1beta1.ClusterTaskInformer) -} diff --git a/pkg/client/injection/informers/pipeline/v1beta1/clustertask/filtered/fake/fake.go b/pkg/client/injection/informers/pipeline/v1beta1/clustertask/filtered/fake/fake.go deleted file mode 100644 index 4fc0b864695..00000000000 --- a/pkg/client/injection/informers/pipeline/v1beta1/clustertask/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/v1beta1/clustertask/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().V1beta1().ClusterTasks() - ctx = context.WithValue(ctx, filtered.Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/controller.go b/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/controller.go deleted file mode 100644 index 1b138da51c2..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/controller.go +++ /dev/null @@ -1,167 +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 clustertask - -import ( - context "context" - fmt "fmt" - reflect "reflect" - strings "strings" - - versionedscheme "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" - client "github.com/tektoncd/pipeline/pkg/client/injection/client" - clustertask "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask" - zap "go.uber.org/zap" - corev1 "k8s.io/api/core/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - scheme "k8s.io/client-go/kubernetes/scheme" - v1 "k8s.io/client-go/kubernetes/typed/core/v1" - record "k8s.io/client-go/tools/record" - kubeclient "knative.dev/pkg/client/injection/kube/client" - controller "knative.dev/pkg/controller" - logging "knative.dev/pkg/logging" - logkey "knative.dev/pkg/logging/logkey" - reconciler "knative.dev/pkg/reconciler" -) - -const ( - defaultControllerAgentName = "clustertask-controller" - defaultFinalizerName = "clustertasks.tekton.dev" -) - -// NewImpl returns a controller.Impl that handles queuing and feeding work from -// the queue through an implementation of controller.Reconciler, delegating to -// the provided Interface and optional Finalizer methods. OptionsFn is used to return -// controller.ControllerOptions to be used by the internal reconciler. -func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsFn) *controller.Impl { - logger := logging.FromContext(ctx) - - // Check the options function input. It should be 0 or 1. - if len(optionsFns) > 1 { - logger.Fatal("Up to one options function is supported, found: ", len(optionsFns)) - } - - clustertaskInformer := clustertask.Get(ctx) - - lister := clustertaskInformer.Lister() - - var promoteFilterFunc func(obj interface{}) bool - var promoteFunc = func(bkt reconciler.Bucket) {} - - rec := &reconcilerImpl{ - LeaderAwareFuncs: reconciler.LeaderAwareFuncs{ - PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { - - // Signal promotion event - promoteFunc(bkt) - - all, err := lister.List(labels.Everything()) - if err != nil { - return err - } - for _, elt := range all { - if promoteFilterFunc != nil { - if ok := promoteFilterFunc(elt); !ok { - continue - } - } - enq(bkt, types.NamespacedName{ - Namespace: elt.GetNamespace(), - Name: elt.GetName(), - }) - } - return nil - }, - }, - Client: client.Get(ctx), - Lister: lister, - reconciler: r, - finalizerName: defaultFinalizerName, - } - - ctrType := reflect.TypeOf(r).Elem() - ctrTypeName := fmt.Sprintf("%s.%s", ctrType.PkgPath(), ctrType.Name()) - ctrTypeName = strings.ReplaceAll(ctrTypeName, "/", ".") - - logger = logger.With( - zap.String(logkey.ControllerType, ctrTypeName), - zap.String(logkey.Kind, "tekton.dev.ClusterTask"), - ) - - impl := controller.NewContext(ctx, rec, controller.ControllerOptions{WorkQueueName: ctrTypeName, Logger: logger}) - agentName := defaultControllerAgentName - - // Pass impl to the options. Save any optional results. - for _, fn := range optionsFns { - opts := fn(impl) - if opts.ConfigStore != nil { - rec.configStore = opts.ConfigStore - } - if opts.FinalizerName != "" { - rec.finalizerName = opts.FinalizerName - } - if opts.AgentName != "" { - agentName = opts.AgentName - } - if opts.DemoteFunc != nil { - rec.DemoteFunc = opts.DemoteFunc - } - if opts.PromoteFilterFunc != nil { - promoteFilterFunc = opts.PromoteFilterFunc - } - if opts.PromoteFunc != nil { - promoteFunc = opts.PromoteFunc - } - } - - rec.Recorder = createRecorder(ctx, agentName) - - return impl -} - -func createRecorder(ctx context.Context, agentName string) record.EventRecorder { - logger := logging.FromContext(ctx) - - recorder := controller.GetEventRecorder(ctx) - if recorder == nil { - // Create event broadcaster - logger.Debug("Creating event broadcaster") - eventBroadcaster := record.NewBroadcaster() - watches := []watch.Interface{ - eventBroadcaster.StartLogging(logger.Named("event-broadcaster").Infof), - eventBroadcaster.StartRecordingToSink( - &v1.EventSinkImpl{Interface: kubeclient.Get(ctx).CoreV1().Events("")}), - } - recorder = eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: agentName}) - go func() { - <-ctx.Done() - for _, w := range watches { - w.Stop() - } - }() - } - - return recorder -} - -func init() { - versionedscheme.AddToScheme(scheme.Scheme) -} diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/reconciler.go b/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/reconciler.go deleted file mode 100644 index 4a6dc086431..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/reconciler.go +++ /dev/null @@ -1,365 +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 clustertask - -import ( - context "context" - json "encoding/json" - fmt "fmt" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - versioned "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" - zap "go.uber.org/zap" - v1 "k8s.io/api/core/v1" - errors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - sets "k8s.io/apimachinery/pkg/util/sets" - record "k8s.io/client-go/tools/record" - controller "knative.dev/pkg/controller" - logging "knative.dev/pkg/logging" - reconciler "knative.dev/pkg/reconciler" -) - -// Interface defines the strongly typed interfaces to be implemented by a -// controller reconciling v1beta1.ClusterTask. -type Interface interface { - // ReconcileKind implements custom logic to reconcile v1beta1.ClusterTask. Any changes - // to the objects .Status or .Finalizers will be propagated to the stored - // object. It is recommended that implementors do not call any update calls - // for the Kind inside of ReconcileKind, it is the responsibility of the calling - // controller to propagate those properties. The resource passed to ReconcileKind - // will always have an empty deletion timestamp. - ReconcileKind(ctx context.Context, o *v1beta1.ClusterTask) reconciler.Event -} - -// Finalizer defines the strongly typed interfaces to be implemented by a -// controller finalizing v1beta1.ClusterTask. -type Finalizer interface { - // FinalizeKind implements custom logic to finalize v1beta1.ClusterTask. Any changes - // to the objects .Status or .Finalizers will be ignored. Returning a nil or - // Normal type reconciler.Event will allow the finalizer to be deleted on - // the resource. The resource passed to FinalizeKind will always have a set - // deletion timestamp. - FinalizeKind(ctx context.Context, o *v1beta1.ClusterTask) reconciler.Event -} - -// ReadOnlyInterface defines the strongly typed interfaces to be implemented by a -// controller reconciling v1beta1.ClusterTask if they want to process resources for which -// they are not the leader. -type ReadOnlyInterface interface { - // ObserveKind implements logic to observe v1beta1.ClusterTask. - // This method should not write to the API. - ObserveKind(ctx context.Context, o *v1beta1.ClusterTask) reconciler.Event -} - -type doReconcile func(ctx context.Context, o *v1beta1.ClusterTask) reconciler.Event - -// reconcilerImpl implements controller.Reconciler for v1beta1.ClusterTask resources. -type reconcilerImpl struct { - // LeaderAwareFuncs is inlined to help us implement reconciler.LeaderAware. - reconciler.LeaderAwareFuncs - - // Client is used to write back status updates. - Client versioned.Interface - - // Listers index properties about resources. - Lister pipelinev1beta1.ClusterTaskLister - - // Recorder is an event recorder for recording Event resources to the - // Kubernetes API. - Recorder record.EventRecorder - - // configStore allows for decorating a context with config maps. - // +optional - configStore reconciler.ConfigStore - - // reconciler is the implementation of the business logic of the resource. - reconciler Interface - - // finalizerName is the name of the finalizer to reconcile. - finalizerName string -} - -// Check that our Reconciler implements controller.Reconciler. -var _ controller.Reconciler = (*reconcilerImpl)(nil) - -// Check that our generated Reconciler is always LeaderAware. -var _ reconciler.LeaderAware = (*reconcilerImpl)(nil) - -func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versioned.Interface, lister pipelinev1beta1.ClusterTaskLister, recorder record.EventRecorder, r Interface, options ...controller.Options) controller.Reconciler { - // Check the options function input. It should be 0 or 1. - if len(options) > 1 { - logger.Fatal("Up to one options struct is supported, found: ", len(options)) - } - - // Fail fast when users inadvertently implement the other LeaderAware interface. - // For the typed reconcilers, Promote shouldn't take any arguments. - if _, ok := r.(reconciler.LeaderAware); ok { - logger.Fatalf("%T implements the incorrect LeaderAware interface. Promote() should not take an argument as genreconciler handles the enqueuing automatically.", r) - } - - rec := &reconcilerImpl{ - LeaderAwareFuncs: reconciler.LeaderAwareFuncs{ - PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { - all, err := lister.List(labels.Everything()) - if err != nil { - return err - } - for _, elt := range all { - // TODO: Consider letting users specify a filter in options. - enq(bkt, types.NamespacedName{ - Namespace: elt.GetNamespace(), - Name: elt.GetName(), - }) - } - return nil - }, - }, - Client: client, - Lister: lister, - Recorder: recorder, - reconciler: r, - finalizerName: defaultFinalizerName, - } - - for _, opts := range options { - if opts.ConfigStore != nil { - rec.configStore = opts.ConfigStore - } - if opts.FinalizerName != "" { - rec.finalizerName = opts.FinalizerName - } - if opts.DemoteFunc != nil { - rec.DemoteFunc = opts.DemoteFunc - } - } - - return rec -} - -// Reconcile implements controller.Reconciler -func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { - logger := logging.FromContext(ctx) - - // Initialize the reconciler state. This will convert the namespace/name - // string into a distinct namespace and name, determine if this instance of - // the reconciler is the leader, and any additional interfaces implemented - // by the reconciler. Returns an error is the resource key is invalid. - s, err := newState(key, r) - if err != nil { - logger.Error("Invalid resource key: ", key) - return nil - } - - // If we are not the leader, and we don't implement either ReadOnly - // observer interfaces, then take a fast-path out. - if s.isNotLeaderNorObserver() { - return controller.NewSkipKey(key) - } - - // If configStore is set, attach the frozen configuration to the context. - if r.configStore != nil { - ctx = r.configStore.ToContext(ctx) - } - - // Add the recorder to context. - ctx = controller.WithEventRecorder(ctx, r.Recorder) - - // Get the resource with this namespace/name. - - getter := r.Lister - - original, err := getter.Get(s.name) - - if errors.IsNotFound(err) { - // The resource may no longer exist, in which case we stop processing and call - // the ObserveDeletion handler if appropriate. - logger.Debugf("Resource %q no longer exists", key) - if del, ok := r.reconciler.(reconciler.OnDeletionInterface); ok { - return del.ObserveDeletion(ctx, types.NamespacedName{ - Namespace: s.namespace, - Name: s.name, - }) - } - return nil - } else if err != nil { - return err - } - - // Don't modify the informers copy. - resource := original.DeepCopy() - - var reconcileEvent reconciler.Event - - name, do := s.reconcileMethodFor(resource) - // Append the target method to the logger. - logger = logger.With(zap.String("targetMethod", name)) - switch name { - case reconciler.DoReconcileKind: - // Set and update the finalizer on resource if r.reconciler - // implements Finalizer. - if resource, err = r.setFinalizerIfFinalizer(ctx, resource); err != nil { - return fmt.Errorf("failed to set finalizers: %w", err) - } - - // Reconcile this copy of the resource and then write back any status - // updates regardless of whether the reconciliation errored out. - reconcileEvent = do(ctx, resource) - - case reconciler.DoFinalizeKind: - // For finalizing reconcilers, if this resource being marked for deletion - // and reconciled cleanly (nil or normal event), remove the finalizer. - reconcileEvent = do(ctx, resource) - - if resource, err = r.clearFinalizer(ctx, resource, reconcileEvent); err != nil { - return fmt.Errorf("failed to clear finalizers: %w", err) - } - - case reconciler.DoObserveKind: - // Observe any changes to this resource, since we are not the leader. - reconcileEvent = do(ctx, resource) - - } - - // Report the reconciler event, if any. - if reconcileEvent != nil { - var event *reconciler.ReconcilerEvent - if reconciler.EventAs(reconcileEvent, &event) { - logger.Infow("Returned an event", zap.Any("event", reconcileEvent)) - r.Recorder.Event(resource, event.EventType, event.Reason, event.Error()) - - // the event was wrapped inside an error, consider the reconciliation as failed - if _, isEvent := reconcileEvent.(*reconciler.ReconcilerEvent); !isEvent { - return reconcileEvent - } - return nil - } - - if controller.IsSkipKey(reconcileEvent) { - // This is a wrapped error, don't emit an event. - } else if ok, _ := controller.IsRequeueKey(reconcileEvent); ok { - // This is a wrapped error, don't emit an event. - } else { - logger.Errorw("Returned an error", zap.Error(reconcileEvent)) - r.Recorder.Event(resource, v1.EventTypeWarning, "InternalError", reconcileEvent.Error()) - } - return reconcileEvent - } - - return nil -} - -// updateFinalizersFiltered will update the Finalizers of the resource. -// TODO: this method could be generic and sync all finalizers. For now it only -// updates defaultFinalizerName or its override. -func (r *reconcilerImpl) updateFinalizersFiltered(ctx context.Context, resource *v1beta1.ClusterTask, desiredFinalizers sets.Set[string]) (*v1beta1.ClusterTask, error) { - // Don't modify the informers copy. - existing := resource.DeepCopy() - - var finalizers []string - - // If there's nothing to update, just return. - existingFinalizers := sets.New[string](existing.Finalizers...) - - if desiredFinalizers.Has(r.finalizerName) { - if existingFinalizers.Has(r.finalizerName) { - // Nothing to do. - return resource, nil - } - // Add the finalizer. - finalizers = append(existing.Finalizers, r.finalizerName) - } else { - if !existingFinalizers.Has(r.finalizerName) { - // Nothing to do. - return resource, nil - } - // Remove the finalizer. - existingFinalizers.Delete(r.finalizerName) - finalizers = sets.List(existingFinalizers) - } - - mergePatch := map[string]interface{}{ - "metadata": map[string]interface{}{ - "finalizers": finalizers, - "resourceVersion": existing.ResourceVersion, - }, - } - - patch, err := json.Marshal(mergePatch) - if err != nil { - return resource, err - } - - patcher := r.Client.TektonV1beta1().ClusterTasks() - - resourceName := resource.Name - updated, err := patcher.Patch(ctx, resourceName, types.MergePatchType, patch, metav1.PatchOptions{}) - if err != nil { - r.Recorder.Eventf(existing, v1.EventTypeWarning, "FinalizerUpdateFailed", - "Failed to update finalizers for %q: %v", resourceName, err) - } else { - r.Recorder.Eventf(updated, v1.EventTypeNormal, "FinalizerUpdate", - "Updated %q finalizers", resource.GetName()) - } - return updated, err -} - -func (r *reconcilerImpl) setFinalizerIfFinalizer(ctx context.Context, resource *v1beta1.ClusterTask) (*v1beta1.ClusterTask, error) { - if _, ok := r.reconciler.(Finalizer); !ok { - return resource, nil - } - - finalizers := sets.New[string](resource.Finalizers...) - - // If this resource is not being deleted, mark the finalizer. - if resource.GetDeletionTimestamp().IsZero() { - finalizers.Insert(r.finalizerName) - } - - // Synchronize the finalizers filtered by r.finalizerName. - return r.updateFinalizersFiltered(ctx, resource, finalizers) -} - -func (r *reconcilerImpl) clearFinalizer(ctx context.Context, resource *v1beta1.ClusterTask, reconcileEvent reconciler.Event) (*v1beta1.ClusterTask, error) { - if _, ok := r.reconciler.(Finalizer); !ok { - return resource, nil - } - if resource.GetDeletionTimestamp().IsZero() { - return resource, nil - } - - finalizers := sets.New[string](resource.Finalizers...) - - if reconcileEvent != nil { - var event *reconciler.ReconcilerEvent - if reconciler.EventAs(reconcileEvent, &event) { - if event.EventType == v1.EventTypeNormal { - finalizers.Delete(r.finalizerName) - } - } - } else { - finalizers.Delete(r.finalizerName) - } - - // Synchronize the finalizers filtered by r.finalizerName. - return r.updateFinalizersFiltered(ctx, resource, finalizers) -} diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/state.go b/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/state.go deleted file mode 100644 index 7768f05d646..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/clustertask/state.go +++ /dev/null @@ -1,97 +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 clustertask - -import ( - fmt "fmt" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - types "k8s.io/apimachinery/pkg/types" - cache "k8s.io/client-go/tools/cache" - reconciler "knative.dev/pkg/reconciler" -) - -// state is used to track the state of a reconciler in a single run. -type state struct { - // key is the original reconciliation key from the queue. - key string - // namespace is the namespace split from the reconciliation key. - namespace string - // name is the name split from the reconciliation key. - name string - // reconciler is the reconciler. - reconciler Interface - // roi is the read only interface cast of the reconciler. - roi ReadOnlyInterface - // isROI (Read Only Interface) the reconciler only observes reconciliation. - isROI bool - // isLeader the instance of the reconciler is the elected leader. - isLeader bool -} - -func newState(key string, r *reconcilerImpl) (*state, error) { - // Convert the namespace/name string into a distinct namespace and name. - namespace, name, err := cache.SplitMetaNamespaceKey(key) - if err != nil { - return nil, fmt.Errorf("invalid resource key: %s", key) - } - - roi, isROI := r.reconciler.(ReadOnlyInterface) - - isLeader := r.IsLeaderFor(types.NamespacedName{ - Namespace: namespace, - Name: name, - }) - - return &state{ - key: key, - namespace: namespace, - name: name, - reconciler: r.reconciler, - roi: roi, - isROI: isROI, - isLeader: isLeader, - }, nil -} - -// isNotLeaderNorObserver checks to see if this reconciler with the current -// state is enabled to do any work or not. -// isNotLeaderNorObserver returns true when there is no work possible for the -// reconciler. -func (s *state) isNotLeaderNorObserver() bool { - if !s.isLeader && !s.isROI { - // If we are not the leader, and we don't implement the ReadOnly - // interface, then take a fast-path out. - return true - } - return false -} - -func (s *state) reconcileMethodFor(o *v1beta1.ClusterTask) (string, doReconcile) { - if o.GetDeletionTimestamp().IsZero() { - if s.isLeader { - return reconciler.DoReconcileKind, s.reconciler.ReconcileKind - } else if s.isROI { - return reconciler.DoObserveKind, s.roi.ObserveKind - } - } else if fin, ok := s.reconciler.(Finalizer); s.isLeader && ok { - return reconciler.DoFinalizeKind, fin.FinalizeKind - } - return "unknown", nil -} diff --git a/pkg/client/listers/pipeline/v1beta1/clustertask.go b/pkg/client/listers/pipeline/v1beta1/clustertask.go deleted file mode 100644 index 734d32656d1..00000000000 --- a/pkg/client/listers/pipeline/v1beta1/clustertask.go +++ /dev/null @@ -1,48 +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 v1beta1 - -import ( - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" - "k8s.io/client-go/tools/cache" -) - -// ClusterTaskLister helps list ClusterTasks. -// All objects returned here must be treated as read-only. -type ClusterTaskLister interface { - // List lists all ClusterTasks in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1beta1.ClusterTask, err error) - // Get retrieves the ClusterTask from the index for a given name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1beta1.ClusterTask, error) - ClusterTaskListerExpansion -} - -// clusterTaskLister implements the ClusterTaskLister interface. -type clusterTaskLister struct { - listers.ResourceIndexer[*v1beta1.ClusterTask] -} - -// NewClusterTaskLister returns a new ClusterTaskLister. -func NewClusterTaskLister(indexer cache.Indexer) ClusterTaskLister { - return &clusterTaskLister{listers.New[*v1beta1.ClusterTask](indexer, v1beta1.Resource("clustertask"))} -} diff --git a/pkg/client/listers/pipeline/v1beta1/expansion_generated.go b/pkg/client/listers/pipeline/v1beta1/expansion_generated.go index 0fe1994d1d8..a48910c9e76 100644 --- a/pkg/client/listers/pipeline/v1beta1/expansion_generated.go +++ b/pkg/client/listers/pipeline/v1beta1/expansion_generated.go @@ -18,10 +18,6 @@ limitations under the License. package v1beta1 -// ClusterTaskListerExpansion allows custom methods to be added to -// ClusterTaskLister. -type ClusterTaskListerExpansion interface{} - // CustomRunListerExpansion allows custom methods to be added to // CustomRunLister. type CustomRunListerExpansion interface{} diff --git a/pkg/reconciler/apiserver/apiserver_test.go b/pkg/reconciler/apiserver/apiserver_test.go index 06f91abd8c5..45215535816 100644 --- a/pkg/reconciler/apiserver/apiserver_test.go +++ b/pkg/reconciler/apiserver/apiserver_test.go @@ -49,11 +49,6 @@ func TestDryRunCreate_Valid_DifferentGVKs(t *testing.T) { name: "v1beta1 stepaction", obj: &v1beta1.StepAction{}, wantObj: &v1beta1.StepAction{}, - }, { - name: "unsupported gvk", - obj: &v1beta1.ClusterTask{}, - wantErr: true, - wantObj: nil, }} for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { @@ -98,10 +93,6 @@ func TestDryRunCreate_Invalid_DifferentGVKs(t *testing.T) { name: "v1beta1 stepaction", obj: &v1beta1.StepAction{}, wantErr: apiserver.ErrReferencedObjectValidationFailed, - }, { - name: "unsupported gvk", - obj: &v1beta1.ClusterTask{}, - wantErr: cmpopts.AnyError, }} for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 890c5f828a8..e64383c1d52 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -302,19 +302,6 @@ spec: retries: 5 taskRef: name: unit-test-task - - name: unit-test-cluster-task - params: - - name: foo - value: somethingfun - - name: bar - value: $(params.bar) - - name: contextRunParam - value: $(context.pipelineRun.name) - - name: contextPipelineParam - value: $(context.pipeline.name) - taskRef: - kind: ClusterTask - name: unit-test-cluster-task `)} ts := []*v1.Task{ parse.MustParseV1Task(t, ` @@ -335,28 +322,11 @@ spec: type: string `), } - clusterTasks := []*v1beta1.ClusterTask{ - parse.MustParseClusterTask(t, ` -metadata: - name: unit-test-cluster-task -spec: - params: - - name: foo - type: string - - name: bar - type: string - - name: contextRunParam - type: string - - name: contextPipelineParam - type: string -`), - } d := test.Data{ PipelineRuns: prs, Pipelines: ps, Tasks: ts, - ClusterTasks: clusterTasks, ConfigMaps: []*corev1.ConfigMap{newFeatureFlagsConfigMap()}, } prt := newPipelineRunTest(t, d) @@ -15854,15 +15824,6 @@ spec: value: $(params.bar) taskRef: name: unit-test-task - - name: unit-test-cluster-task - params: - - name: foo - value: somethingfun - - name: bar - value: $(params.bar) - taskRef: - kind: ClusterTask - name: unit-test-cluster-task `)} ts := []*v1.Task{ parse.MustParseV1Task(t, ` @@ -15875,22 +15836,11 @@ spec: - name: bar `), } - clusterTasks := []*v1beta1.ClusterTask{ - parse.MustParseClusterTask(t, ` -metadata: - name: unit-test-cluster-task -spec: - params: - - name: foo - - name: bar -`), - } d := test.Data{ PipelineRuns: prs, Pipelines: ps, Tasks: ts, - ClusterTasks: clusterTasks, ConfigMaps: []*corev1.ConfigMap{newFeatureFlagsConfigMap()}, } prt := newPipelineRunTest(t, d) diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go index eadd98ea569..bd528e2fd66 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go @@ -63,9 +63,6 @@ var pts = []v1.PipelineTask{{ }, { Name: "mytask2", TaskRef: &v1.TaskRef{Name: "task"}, -}, { - Name: "mytask3", - TaskRef: &v1.TaskRef{Name: "clustertask"}, }, { Name: "mytask4", TaskRef: &v1.TaskRef{Name: "task"}, diff --git a/pkg/reconciler/taskrun/resources/taskref.go b/pkg/reconciler/taskrun/resources/taskref.go index 8b493cbf7e1..70a5a1ce77d 100644 --- a/pkg/reconciler/taskrun/resources/taskref.go +++ b/pkg/reconciler/taskrun/resources/taskref.go @@ -39,7 +39,7 @@ import ( "knative.dev/pkg/kmeta" ) -// GetTaskKind returns the referenced Task kind (Task, ClusterTask, ...) if the TaskRun is using TaskRef. +// GetTaskKind returns the referenced Task kind (Task, ...) if the TaskRun is using TaskRef. func GetTaskKind(taskrun *v1.TaskRun) v1.TaskKind { kind := v1.NamespacedTaskKind if taskrun.Spec.TaskRef != nil && taskrun.Spec.TaskRef.Kind != "" { @@ -212,7 +212,7 @@ func extendObjectReplacements(objectReplacements map[string]map[string]string, o // A VerificationResult is returned if trusted resources is enabled, VerificationResult contains the result type and err. // or the returned data isn't a valid *v1beta1.Task. func resolveTask(ctx context.Context, resolver remote.Resolver, name, namespace string, kind v1.TaskKind, k8s kubernetes.Interface, tekton clientset.Interface, verificationPolicies []*v1alpha1.VerificationPolicy) (*v1.Task, *v1.RefSource, *trustedresources.VerificationResult, error) { - // Because the resolver will only return references with the same kind (eg ClusterTask), this will ensure we + // Because the resolver will only return references with the same kind (eg ClusterTask (not supported anymore)), this will ensure we // don't accidentally return a Task with the same name but different kind. obj, refSource, err := resolver.Get(ctx, strings.TrimSuffix(strings.ToLower(string(kind)), "s"), name) if err != nil { @@ -307,25 +307,6 @@ func readRuntimeObjectAsTask(ctx context.Context, namespace string, obj runtime. } return t, &vr, nil } - case *v1beta1.ClusterTask: - obj.SetDefaults(ctx) - // Cleanup object from things we don't care about - // FIXME: extract this in a function - obj.ObjectMeta.OwnerReferences = nil - t, err := convertClusterTaskToTask(ctx, *obj) - if err != nil { - return nil, nil, err - } - // Issue a dry-run request to create the remote Task, so that it can undergo validation from validating admission webhooks - // without actually creating the Task on the cluster - o, err := apiserver.DryRunValidate(ctx, namespace, t, tekton) - if err != nil { - return nil, nil, err - } - if mutatedTask, ok := o.(*v1.Task); ok { - mutatedTask.ObjectMeta = obj.ObjectMeta - return mutatedTask, nil, nil - } case *v1.Task: // This SetDefaults is currently not necessary, but for consistency, it is recommended to add it. // Avoid forgetting to add it in the future when there is a v2 version, causing similar problems. @@ -359,15 +340,6 @@ type LocalTaskRefResolver struct { // return an error if it can't find an appropriate Task for any reason. // TODO(#6666): support local task verification func (l *LocalTaskRefResolver) GetTask(ctx context.Context, name string) (*v1.Task, *v1.RefSource, *trustedresources.VerificationResult, error) { - if l.Kind == v1.ClusterTaskRefKind { - task, err := l.Tektonclient.TektonV1beta1().ClusterTasks().Get(ctx, name, metav1.GetOptions{}) - if err != nil { - return nil, nil, nil, err - } - v1task, err := convertClusterTaskToTask(ctx, *task) - return v1task, nil, nil, err - } - // If we are going to resolve this reference locally, we need a namespace scope. if l.Namespace == "" { return nil, nil, nil, fmt.Errorf("must specify namespace to resolve reference to task %s", name) @@ -398,34 +370,3 @@ func (l *LocalStepActionRefResolver) GetStepAction(ctx context.Context, name str } return stepAction, nil, nil } - -// convertClusterTaskToTask converts deprecated v1beta1 ClusterTasks to Tasks for -// the rest of reconciling process since GetTask func and its upstream callers only -// fetches the task spec and stores it in the taskrun status while the kind info -// is not being used. -func convertClusterTaskToTask(ctx context.Context, ct v1beta1.ClusterTask) (*v1.Task, error) { - t := &v1beta1.Task{ - TypeMeta: metav1.TypeMeta{ - Kind: "Task", - APIVersion: "tekton.dev/v1beta1", - }, - // We need to keep ObjectMeta to keep consistent with the existing Task logic. - // TaskRun will inherit the original Annotations and Labels information. - ObjectMeta: ct.ObjectMeta, - } - - t.Spec = ct.Spec - - v1Task := &v1.Task{ - TypeMeta: metav1.TypeMeta{ - Kind: "Task", - APIVersion: "tekton.dev/v1", - }, - } - - if err := t.ConvertTo(ctx, v1Task); err != nil { - return nil, err - } - - return v1Task, nil -} diff --git a/pkg/reconciler/taskrun/resources/taskref_test.go b/pkg/reconciler/taskrun/resources/taskref_test.go index 2354743e63a..e558edc4fe2 100644 --- a/pkg/reconciler/taskrun/resources/taskref_test.go +++ b/pkg/reconciler/taskrun/resources/taskref_test.go @@ -82,20 +82,6 @@ var ( }}, }, } - simpleClusterTask = &v1beta1.ClusterTask{ - ObjectMeta: metav1.ObjectMeta{ - Name: "simple", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "ClusterTask", - }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Image: "something", - }}, - }, - } sampleRefSource = &v1.RefSource{ URI: "abc.com", Digest: map[string]string{ @@ -224,48 +210,6 @@ func TestLocalTaskRef(t *testing.T) { }, wantErr: nil, }, - { - name: "local-clustertask", - namespace: "default", - tasks: []runtime.Object{ - &v1beta1.ClusterTask{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cluster-task", - Annotations: map[string]string{ - "foo": "bar", - }, - Labels: map[string]string{ - "foo": "bar", - }, - }, - }, - &v1beta1.ClusterTask{ - ObjectMeta: metav1.ObjectMeta{ - Name: "sample-task", - }, - }, - }, - ref: &v1.TaskRef{ - Name: "cluster-task", - Kind: "ClusterTask", - }, - expected: &v1.Task{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1", - Kind: "Task", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "cluster-task", - Annotations: map[string]string{ - "foo": "bar", - }, - Labels: map[string]string{ - "foo": "bar", - }, - }, - }, - wantErr: nil, - }, { name: "task-not-found", namespace: "default", @@ -276,17 +220,6 @@ func TestLocalTaskRef(t *testing.T) { expected: nil, wantErr: errors.New(`tasks.tekton.dev "simple" not found`), }, - { - name: "clustertask-not-found", - namespace: "default", - tasks: []runtime.Object{}, - ref: &v1.TaskRef{ - Name: "cluster-task", - Kind: "ClusterTask", - }, - expected: nil, - wantErr: errors.New(`clustertasks.tekton.dev "cluster-task" not found`), - }, { name: "local-task-missing-namespace", namespace: "", @@ -757,38 +690,6 @@ func TestGetTaskFunc_Local(t *testing.T) { }, expected: simpleNamespacedTask, expectedKind: v1.NamespacedTaskKind, - }, { - name: "local-cluster-task", - localTasks: []runtime.Object{simpleClusterTask}, - remoteTasks: []runtime.Object{ - &v1beta1.ClusterTask{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1alpha1", Kind: "ClusterTask"}, - ObjectMeta: metav1.ObjectMeta{Name: "simple"}, - }, - &v1beta1.ClusterTask{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1alpha1", Kind: "ClusterTask"}, - ObjectMeta: metav1.ObjectMeta{Name: "sample"}, - }, - }, - ref: &v1.TaskRef{ - Name: "simple", - Kind: v1.ClusterTaskRefKind, - }, - expected: &v1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "simple", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1", - Kind: "Task", - }, - Spec: v1.TaskSpec{ - Steps: []v1.Step{{ - Image: "something", - }}, - }, - }, - expectedKind: v1.NamespacedTaskKind, }, } @@ -1074,14 +975,6 @@ func TestGetTaskFunc_RemoteResolution(t *testing.T) { taskYAMLString, }, "\n"), wantTask: parse.MustParseV1TaskAndSetDefaults(t, taskYAMLString), - }, { - name: "v1beta1 cluster task", - taskYAML: strings.Join([]string{ - "kind: ClusterTask", - "apiVersion: tekton.dev/v1beta1", - taskYAMLString, - }, "\n"), - wantTask: parse.MustParseV1TaskAndSetDefaults(t, taskYAMLString), }, { name: "v1 task", taskYAML: strings.Join([]string{ @@ -1151,13 +1044,6 @@ func TestGetTaskFunc_RemoteResolution_ValidationFailure(t *testing.T) { "apiVersion: tekton.dev/v1beta1", taskYAMLString, }, "\n"), - }, { - name: "invalid v1beta1 clustertask", - taskYAML: strings.Join([]string{ - "kind: ClusterTask", - "apiVersion: tekton.dev/v1beta1", - taskYAMLString, - }, "\n"), }, { name: "invalid v1 task", taskYAML: strings.Join([]string{ diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index f977315be16..bdc343ea4f5 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -1053,11 +1053,7 @@ func storeTaskSpecAndMergeMeta(ctx context.Context, tr *v1.TaskRun, ts *v1.TaskS // Propagate labels from Task to TaskRun. TaskRun labels take precedences over Task. tr.ObjectMeta.Labels = kmap.Union(meta.Labels, tr.ObjectMeta.Labels) if tr.Spec.TaskRef != nil { - if tr.Spec.TaskRef.Kind == v1.ClusterTaskRefKind { - tr.ObjectMeta.Labels[pipeline.ClusterTaskLabelKey] = meta.Name - } else { - tr.ObjectMeta.Labels[pipeline.TaskLabelKey] = meta.Name - } + tr.ObjectMeta.Labels[pipeline.TaskLabelKey] = meta.Name } } diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index 49e7ea16a49..204a2cb0091 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -183,16 +183,6 @@ var ( }, } - clustertask = &v1beta1.ClusterTask{ - ObjectMeta: metav1.ObjectMeta{Name: "test-cluster-task"}, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Name: "simple-step", - Image: "foo", - Command: []string{"/mycmd"}, - }}, - }, - } taskSidecar = &v1.Task{ ObjectMeta: objectMeta("test-task-sidecar", "foo"), Spec: v1.TaskSpec{ @@ -479,7 +469,7 @@ spec: }{{ name: "success", taskRun: taskRunSuccess, - wantPod: expectedPod("test-taskrun-run-success-pod", "test-task", "test-taskrun-run-success", "bar", "foo", defaultSAName, false, nil, []stepForExpectedPod{{ + wantPod: expectedPod("test-taskrun-run-success-pod", "test-task", "test-taskrun-run-success", "bar", "foo", defaultSAName, nil, []stepForExpectedPod{{ image: "foo", name: "simple-step", cmd: "/mycmd", @@ -487,7 +477,7 @@ spec: }, { name: "serviceaccount", taskRun: taskRunWithSaSuccess, - wantPod: expectedPod("test-taskrun-with-sa-run-success-pod", "test-with-sa", "test-taskrun-with-sa-run-success", "bar", "foo", "test-sa", false, nil, []stepForExpectedPod{{ + wantPod: expectedPod("test-taskrun-with-sa-run-success-pod", "test-with-sa", "test-taskrun-with-sa-run-success", "bar", "foo", "test-sa", nil, []stepForExpectedPod{{ image: "foo", name: "sa-step", cmd: "/mycmd", @@ -709,17 +699,6 @@ spec: name: mycontainer `) - taskRunWithClusterTask := parse.MustParseV1TaskRun(t, ` -metadata: - name: test-taskrun-with-cluster-task - namespace: foo - uid: bar -spec: - taskRef: - kind: ClusterTask - name: test-cluster-task -`) - taskRunWithLabels := parse.MustParseV1TaskRun(t, ` metadata: labels: @@ -798,15 +777,14 @@ spec: taskruns := []*v1.TaskRun{ taskRunSuccess, taskRunWithSaSuccess, taskRunSubstitution, - taskRunWithTaskSpec, taskRunWithClusterTask, + taskRunWithTaskSpec, taskRunWithLabels, taskRunWithAnnotations, taskRunWithPod, taskRunWithCredentialsVariable, taskRunBundle, } d := test.Data{ - TaskRuns: taskruns, - Tasks: []*v1.Task{simpleTask, saTask, templatedTask}, - ClusterTasks: []*v1beta1.ClusterTask{clustertask}, + TaskRuns: taskruns, + Tasks: []*v1.Task{simpleTask, saTask, templatedTask}, } for _, tc := range []struct { name string @@ -820,7 +798,7 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: expectedPod("test-taskrun-run-success-pod", "test-task", "test-taskrun-run-success", "bar", "foo", config.DefaultServiceAccountValue, false, nil, []stepForExpectedPod{{ + wantPod: expectedPod("test-taskrun-run-success-pod", "test-task", "test-taskrun-run-success", "bar", "foo", config.DefaultServiceAccountValue, nil, []stepForExpectedPod{{ image: "foo", name: "simple-step", cmd: "/mycmd", @@ -832,7 +810,7 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: expectedPod("test-taskrun-with-sa-run-success-pod", "test-with-sa", "test-taskrun-with-sa-run-success", "bar", "foo", "test-sa", false, nil, []stepForExpectedPod{{ + wantPod: expectedPod("test-taskrun-with-sa-run-success-pod", "test-with-sa", "test-taskrun-with-sa-run-success", "bar", "foo", "test-sa", nil, []stepForExpectedPod{{ image: "foo", name: "sa-step", cmd: "/mycmd", @@ -844,7 +822,7 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: expectedPod("test-taskrun-substitution-pod", "test-task-with-substitution", "test-taskrun-substitution", "bar", "foo", config.DefaultServiceAccountValue, false, []corev1.Volume{{ + wantPod: expectedPod("test-taskrun-substitution-pod", "test-task-with-substitution", "test-taskrun-substitution", "bar", "foo", config.DefaultServiceAccountValue, []corev1.Volume{{ Name: "volume-configmap", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ @@ -880,25 +858,13 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: expectedPod("test-taskrun-with-taskspec-pod", "", "test-taskrun-with-taskspec", "bar", "foo", config.DefaultServiceAccountValue, false, nil, []stepForExpectedPod{ + wantPod: expectedPod("test-taskrun-with-taskspec-pod", "", "test-taskrun-with-taskspec", "bar", "foo", config.DefaultServiceAccountValue, nil, []stepForExpectedPod{ { name: "mycontainer", image: "myimage", cmd: "/mycmd", }, }), - }, { - name: "success-with-cluster-task", - taskRun: taskRunWithClusterTask, - wantEvents: []string{ - "Normal Started ", - "Normal Running Not all Steps", - }, - wantPod: expectedPod("test-taskrun-with-cluster-task-pod", "test-cluster-task", "test-taskrun-with-cluster-task", "bar", "foo", config.DefaultServiceAccountValue, true, nil, []stepForExpectedPod{{ - name: "simple-step", - image: "foo", - cmd: "/mycmd", - }}), }, { name: "taskrun-with-pod", taskRun: taskRunWithPod, @@ -906,7 +872,7 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: expectedPod("test-taskrun-with-pod-pod", "test-task", "test-taskrun-with-pod", "bar", "foo", config.DefaultServiceAccountValue, false, nil, []stepForExpectedPod{{ + wantPod: expectedPod("test-taskrun-with-pod-pod", "test-task", "test-taskrun-with-pod", "bar", "foo", config.DefaultServiceAccountValue, nil, []stepForExpectedPod{{ name: "simple-step", image: "foo", cmd: "/mycmd", @@ -918,7 +884,7 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: expectedPod("test-taskrun-with-credentials-variable-pod", "", "test-taskrun-with-credentials-variable", "bar", "foo", config.DefaultServiceAccountValue, false, nil, []stepForExpectedPod{{ + wantPod: expectedPod("test-taskrun-with-credentials-variable-pod", "", "test-taskrun-with-credentials-variable", "bar", "foo", config.DefaultServiceAccountValue, nil, []stepForExpectedPod{{ name: "mycontainer", image: "myimage", cmd: "/mycmd /tekton/creds", @@ -930,7 +896,7 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: expectedPod("test-taskrun-bundle-pod", "test-task", "test-taskrun-bundle", "bar", "foo", config.DefaultServiceAccountValue, false, nil, []stepForExpectedPod{{ + wantPod: expectedPod("test-taskrun-bundle-pod", "test-task", "test-taskrun-bundle", "bar", "foo", config.DefaultServiceAccountValue, nil, []stepForExpectedPod{{ name: "simple-step", image: "foo", cmd: "/mycmd", @@ -1044,10 +1010,9 @@ spec: }, }} d := test.Data{ - ConfigMaps: cms, - TaskRuns: taskruns, - Tasks: []*v1.Task{simpleTask, saTask, templatedTask}, - ClusterTasks: []*v1beta1.ClusterTask{clustertask}, + ConfigMaps: cms, + TaskRuns: taskruns, + Tasks: []*v1.Task{simpleTask, saTask, templatedTask}, } for _, tc := range []struct { name string @@ -1061,7 +1026,7 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: expectedPod("test-taskrun-with-output-config-pod", "", "test-taskrun-with-output-config", "bar", "foo", config.DefaultServiceAccountValue, false, nil, []stepForExpectedPod{{ + wantPod: expectedPod("test-taskrun-with-output-config-pod", "", "test-taskrun-with-output-config", "bar", "foo", config.DefaultServiceAccountValue, nil, []stepForExpectedPod{{ name: "mycontainer", image: "myimage", stdoutPath: "stdout.txt", @@ -1074,19 +1039,17 @@ spec: "Normal Started ", "Normal Running Not all Steps", }, - wantPod: addVolumeMounts(expectedPod("test-taskrun-with-output-config-ws-pod", "", "test-taskrun-with-output-config-ws", "bar", "foo", config.DefaultServiceAccountValue, false, - []corev1.Volume{{ - Name: "ws-d872e", - VolumeSource: corev1.VolumeSource{ - EmptyDir: &corev1.EmptyDirVolumeSource{}, - }, - }}, - []stepForExpectedPod{{ - name: "mycontainer", - image: "myimage", - stdoutPath: "stdout.txt", - cmd: "/mycmd", - }}), + wantPod: addVolumeMounts(expectedPod("test-taskrun-with-output-config-ws-pod", "", "test-taskrun-with-output-config-ws", "bar", "foo", config.DefaultServiceAccountValue, []corev1.Volume{{ + Name: "ws-d872e", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }}, []stepForExpectedPod{{ + name: "mycontainer", + image: "myimage", + stdoutPath: "stdout.txt", + cmd: "/mycmd", + }}), []corev1.VolumeMount{{ Name: "ws-d872e", MountPath: "/workspace/data", @@ -1415,16 +1378,7 @@ spec: taskRef: name: notask `) - withWrongRef := parse.MustParseV1TaskRun(t, ` -metadata: - name: taskrun-with-wrong-ref - namespace: foo -spec: - taskRef: - kind: ClusterTask - name: taskrun-with-wrong-ref -`) - taskRuns := []*v1.TaskRun{noTaskRun, withWrongRef} + taskRuns := []*v1.TaskRun{noTaskRun} tasks := []*v1.Task{simpleTask} d := test.Data{ @@ -1446,15 +1400,6 @@ spec: "Warning Failed", "Warning InternalError", }, - }, { - name: "task run with wrong ref", - taskRun: withWrongRef, - reason: podconvert.ReasonFailedResolution, - wantEvents: []string{ - "Normal Started", - "Warning Failed", - "Warning InternalError", - }, }} for _, tc := range testcases { @@ -1989,9 +1934,8 @@ spec: name: test-task `) d := test.Data{ - TaskRuns: []*v1.TaskRun{tr}, - Tasks: []*v1.Task{simpleTask}, - ClusterTasks: []*v1beta1.ClusterTask{}, + TaskRuns: []*v1.TaskRun{tr}, + Tasks: []*v1.Task{simpleTask}, } for _, v := range []error{ errors.New("etcdserver: leader changed"), @@ -4472,9 +4416,8 @@ spec: name: test-task-with-workspace `) d := test.Data{ - Tasks: []*v1.Task{taskWithWorkspace}, - TaskRuns: []*v1.TaskRun{taskRun}, - ClusterTasks: nil, + Tasks: []*v1.Task{taskWithWorkspace}, + TaskRuns: []*v1.TaskRun{taskRun}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -4532,9 +4475,8 @@ spec: name: test-task-with-workspace `) d := test.Data{ - Tasks: []*v1.Task{taskWithWorkspace}, - TaskRuns: []*v1.TaskRun{taskRun}, - ClusterTasks: nil, + Tasks: []*v1.Task{taskWithWorkspace}, + TaskRuns: []*v1.TaskRun{taskRun}, } d.ConfigMaps = append(d.ConfigMaps, &corev1.ConfigMap{ @@ -4596,9 +4538,8 @@ spec: name: test-task-with-workspace `) d := test.Data{ - Tasks: []*v1.Task{taskWithWorkspace}, - TaskRuns: []*v1.TaskRun{taskRun}, - ClusterTasks: nil, + Tasks: []*v1.Task{taskWithWorkspace}, + TaskRuns: []*v1.TaskRun{taskRun}, } d.ConfigMaps = append(d.ConfigMaps, &corev1.ConfigMap{ @@ -4764,9 +4705,8 @@ spec: for _, tc := range tcs { d := test.Data{ - Tasks: []*v1.Task{taskWithTwoWorkspaces}, - TaskRuns: []*v1.TaskRun{taskRun}, - ClusterTasks: nil, + Tasks: []*v1.Task{taskWithTwoWorkspaces}, + TaskRuns: []*v1.TaskRun{taskRun}, ConfigMaps: []*corev1.ConfigMap{{ ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()}, Data: tc.cfgMap, @@ -4838,9 +4778,8 @@ spec: name: mypvc `) d := test.Data{ - Tasks: []*v1.Task{taskWithWorkspace}, - TaskRuns: []*v1.TaskRun{taskRun}, - ClusterTasks: nil, + Tasks: []*v1.Task{taskWithWorkspace}, + TaskRuns: []*v1.TaskRun{taskRun}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -5973,7 +5912,6 @@ func podVolumeMounts(idx, totalSteps int) []corev1.VolumeMount { Name: "tekton-internal-artifacts", MountPath: "/tekton/artifacts", }) - return mnts } @@ -6011,7 +5949,7 @@ func podArgs(cmd string, stdoutPath string, stderrPath string, additionalArgs [] return args } -func podObjectMeta(name, taskName, taskRunName, taskRunUID, ns string, isClusterTask bool) metav1.ObjectMeta { +func podObjectMeta(name, taskName, taskRunName, taskRunUID, ns string) metav1.ObjectMeta { trueB := true om := metav1.ObjectMeta{ Name: name, @@ -6035,11 +5973,7 @@ func podObjectMeta(name, taskName, taskRunName, taskRunUID, ns string, isCluster } if taskName != "" { - if isClusterTask { - om.Labels[pipeline.ClusterTaskLabelKey] = taskName - } else { - om.Labels[pipeline.TaskLabelKey] = taskName - } + om.Labels[pipeline.TaskLabelKey] = taskName } return om @@ -6057,13 +5991,13 @@ type stepForExpectedPod struct { stderrPath string } -func expectedPod(podName, taskName, taskRunName, taskRunUID, ns, saName string, isClusterTask bool, extraVolumes []corev1.Volume, steps []stepForExpectedPod) *corev1.Pod { +func expectedPod(podName, taskName, taskRunName, taskRunUID, ns, saName string, extraVolumes []corev1.Volume, steps []stepForExpectedPod) *corev1.Pod { stepNames := make([]string, 0, len(steps)) for _, s := range steps { stepNames = append(stepNames, "step-"+s.name) } p := &corev1.Pod{ - ObjectMeta: podObjectMeta(podName, taskName, taskRunName, taskRunUID, ns, isClusterTask), + ObjectMeta: podObjectMeta(podName, taskName, taskRunName, taskRunUID, ns), Spec: corev1.PodSpec{ Volumes: []corev1.Volume{ workspaceVolume, diff --git a/pkg/remote/oci/resolver_test.go b/pkg/remote/oci/resolver_test.go index 9004b7cfe6d..6785de362b8 100644 --- a/pkg/remote/oci/resolver_test.go +++ b/pkg/remote/oci/resolver_test.go @@ -100,24 +100,7 @@ func TestOCIResolver(t *testing.T) { }, mapper: test.DefaultObjectAnnotationMapper, listExpected: []remote.ResolvedObject{{Kind: "task", APIVersion: "v1beta1", Name: "simple-task"}}, - }, - { - name: "cluster-task", - objs: []runtime.Object{ - &v1beta1.ClusterTask{ - ObjectMeta: metav1.ObjectMeta{ - Name: "simple-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "ClusterTask", - }, - }, - }, - mapper: test.DefaultObjectAnnotationMapper, - listExpected: []remote.ResolvedObject{{Kind: "clustertask", APIVersion: "v1beta1", Name: "simple-task"}}, - }, - { + }, { name: "multiple-tasks", objs: []runtime.Object{ &v1beta1.Task{ diff --git a/pkg/taskrunmetrics/metrics.go b/pkg/taskrunmetrics/metrics.go index 94a5dad73b7..0ff15d63068 100644 --- a/pkg/taskrunmetrics/metrics.go +++ b/pkg/taskrunmetrics/metrics.go @@ -383,11 +383,6 @@ func getTaskTagName(tr *v1.TaskRun) string { if hasPipelineTaskTable && len(pipelineTaskTable) > 0 { taskName = pipelineTaskTable } - case tr.Spec.TaskRef != nil && tr.Spec.TaskRef.Kind == v1.ClusterTaskRefKind: - clusterTaskLabel, hasClusterTaskLabel := tr.Labels[pipeline.ClusterTaskLabelKey] - if hasClusterTaskLabel && len(clusterTaskLabel) > 0 { - taskName = clusterTaskLabel - } default: if len(tr.Labels) > 0 { taskLabel, hasTaskLabel := tr.Labels[pipeline.TaskLabelKey] diff --git a/pkg/taskrunmetrics/metrics_test.go b/pkg/taskrunmetrics/metrics_test.go index daf8342dbce..d5f01d29e4e 100644 --- a/pkg/taskrunmetrics/metrics_test.go +++ b/pkg/taskrunmetrics/metrics_test.go @@ -208,42 +208,6 @@ func TestRecordTaskRunDurationCount(t *testing.T) { expectedCount: 1, beforeCondition: nil, countWithReason: false, - }, { - name: "for succeeded taskrun create by pipelinerun", - taskRun: &v1.TaskRun{ - ObjectMeta: metav1.ObjectMeta{Name: "taskrun-1", Namespace: "ns", Labels: map[string]string{ - pipeline.ClusterTaskLabelKey: "task-1", - }}, - Spec: v1.TaskRunSpec{ - TaskRef: &v1.TaskRef{Kind: v1.ClusterTaskRefKind}, - }, - Status: v1.TaskRunStatus{ - Status: duckv1.Status{ - Conditions: duckv1.Conditions{{ - Type: apis.ConditionSucceeded, - Status: corev1.ConditionTrue, - }}, - }, - TaskRunStatusFields: v1.TaskRunStatusFields{ - StartTime: &startTime, - CompletionTime: &completionTime, - }, - }, - }, - metricName: "taskrun_duration_seconds", - expectedDurationTags: map[string]string{ - "task": "task-1", - "taskrun": "taskrun-1", - "namespace": "ns", - "status": "success", - }, - expectedCountTags: map[string]string{ - "status": "success", - }, - expectedDuration: 60, - expectedCount: 1, - beforeCondition: nil, - countWithReason: false, }, { name: "for succeeded taskrun with before condition", taskRun: &v1.TaskRun{ diff --git a/pkg/trustedresources/verify_test.go b/pkg/trustedresources/verify_test.go index 04fde6cfeaf..2934e30e1ef 100644 --- a/pkg/trustedresources/verify_test.go +++ b/pkg/trustedresources/verify_test.go @@ -544,16 +544,6 @@ func TestVerifyResource_V1Pipeline_Error(t *testing.T) { } } -func TestVerifyResource_TypeNotSupported(t *testing.T) { - resource := v1beta1.ClusterTask{} - refSource := &v1.RefSource{URI: "git+https://github.com/tektoncd/catalog.git"} - _, _, k8sclient, vps := test.SetupVerificationPolicies(t) - vr := VerifyResource(context.Background(), &resource, k8sclient, refSource, vps) - if !errors.Is(vr.Err, ErrResourceNotSupported) { - t.Errorf("want:%v got:%v ", ErrResourceNotSupported, vr.Err) - } -} - func signInterface(signer signature.Signer, i interface{}) ([]byte, error) { if signer == nil { return nil, errors.New("signer is nil") diff --git a/test/clients.go b/test/clients.go index dc0424a5275..9a4b10a30c5 100644 --- a/test/clients.go +++ b/test/clients.go @@ -57,7 +57,6 @@ type clients struct { KubeClient kubernetes.Interface V1beta1PipelineClient v1beta1.PipelineInterface - V1beta1ClusterTaskClient v1beta1.ClusterTaskInterface V1beta1TaskClient v1beta1.TaskInterface V1beta1TaskRunClient v1beta1.TaskRunInterface V1beta1PipelineRunClient v1beta1.PipelineRunInterface @@ -99,7 +98,6 @@ func newClients(t *testing.T, configPath, clusterName, namespace string) *client t.Fatalf("failed to create resolution clientset from config file at %s: %s", configPath, err) } c.V1beta1PipelineClient = cs.TektonV1beta1().Pipelines(namespace) - c.V1beta1ClusterTaskClient = cs.TektonV1beta1().ClusterTasks() c.V1beta1TaskClient = cs.TektonV1beta1().Tasks(namespace) c.V1beta1TaskRunClient = cs.TektonV1beta1().TaskRuns(namespace) c.V1beta1PipelineRunClient = cs.TektonV1beta1().PipelineRuns(namespace) diff --git a/test/controller.go b/test/controller.go index d4cc5506135..80e5ba7061c 100644 --- a/test/controller.go +++ b/test/controller.go @@ -38,7 +38,6 @@ import ( faketaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/task/fake" faketaskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/taskrun/fake" fakeverificationpolicyinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/verificationpolicy/fake" - fakeclustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask/fake" fakecustomruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/customrun/fake" fakestepactioninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/fake" fakeresolutionclientset "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/fake" @@ -75,7 +74,6 @@ type Data struct { TaskRuns []*v1.TaskRun Tasks []*v1.Task StepActions []*v1beta1.StepAction - ClusterTasks []*v1beta1.ClusterTask CustomRuns []*v1beta1.CustomRun Pods []*corev1.Pod Namespaces []*corev1.Namespace @@ -105,7 +103,6 @@ type Informers struct { CustomRun informersv1beta1.CustomRunInformer Task informersv1.TaskInformer StepAction informersv1beta1.StepActionInformer - ClusterTask informersv1beta1.ClusterTaskInformer Pod coreinformers.PodInformer ConfigMap coreinformers.ConfigMapInformer ServiceAccount coreinformers.ServiceAccountInformer @@ -192,7 +189,6 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers CustomRun: fakecustomruninformer.Get(ctx), Task: faketaskinformer.Get(ctx), StepAction: fakestepactioninformer.Get(ctx), - ClusterTask: fakeclustertaskinformer.Get(ctx), Pod: fakefilteredpodinformer.Get(ctx, v1.ManagedByLabelKey), ConfigMap: fakeconfigmapinformer.Get(ctx), ServiceAccount: fakeserviceaccountinformer.Get(ctx), @@ -240,13 +236,6 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers t.Fatal(err) } } - c.Pipeline.PrependReactor("*", "clustertasks", AddToInformer(t, i.ClusterTask.Informer().GetIndexer())) - for _, ct := range d.ClusterTasks { - ct := ct.DeepCopy() // Avoid assumptions that the informer's copy is modified. - if _, err := c.Pipeline.TektonV1beta1().ClusterTasks().Create(ctx, ct, metav1.CreateOptions{}); err != nil { - t.Fatal(err) - } - } c.Pipeline.PrependReactor("*", "customruns", AddToInformer(t, i.CustomRun.Informer().GetIndexer())) for _, customRun := range d.CustomRuns { customRun := customRun.DeepCopy() // Avoid assumptions that the informer's copy is modified. diff --git a/test/e2e-common.sh b/test/e2e-common.sh index 679585db9be..b908ed38adb 100755 --- a/test/e2e-common.sh +++ b/test/e2e-common.sh @@ -153,7 +153,7 @@ function uninstall_pipeline_crd_version() { } function delete_tekton_resources() { - for res in tasks clustertasks pipelines taskruns pipelineruns; do + for res in tasks pipelines taskruns pipelineruns; do echo ">> Deleting ${res}" kubectl delete --ignore-not-found=true ${res}.tekton.dev --all done diff --git a/test/examples_test.go b/test/examples_test.go index 3880bc42022..0825f460b41 100644 --- a/test/examples_test.go +++ b/test/examples_test.go @@ -28,7 +28,6 @@ import ( "strings" "testing" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" knativetest "knative.dev/pkg/test" ) @@ -97,17 +96,6 @@ func substituteEnv(input []byte, namespace string) ([]byte, error) { return output, nil } -// deleteClusterTask removes a single clustertask by name using provided -// clientset. Test state is used for logging. deleteClusterTask does not wait -// for the clustertask to be deleted, so it is still possible to have name -// conflicts during test -func deleteClusterTask(ctx context.Context, t *testing.T, c *clients, name string) { - t.Logf("Deleting clustertask %s", name) - if err := c.V1beta1ClusterTaskClient.Delete(ctx, name, metav1.DeleteOptions{}); err != nil { - t.Fatalf("Failed to delete clustertask: %v", err) - } -} - type createFunc func(input []byte, namespace string) ([]byte, error) type waitFunc func(ctx context.Context, t *testing.T, c *clients, name string) @@ -151,16 +139,6 @@ func exampleTest(path string, waitValidateFunc waitFunc, createFunc createFunc, t.Fatalf("Failed to get created Tekton CRD of kind %s: %v", kind, err) } - // NOTE: If an example creates more than one clustertask, they will not all - // be cleaned up - clustertask, err := getCreatedTektonCRD(out, "clustertask") - if clustertask != "" { - knativetest.CleanupOnInterrupt(func() { deleteClusterTask(ctx, t, c, clustertask) }, t.Logf) - defer deleteClusterTask(ctx, t, c, clustertask) - } else if err != nil { - t.Fatalf("Failed to get created clustertask: %v", err) - } - waitValidateFunc(ctx, t, c, name) } } diff --git a/test/parse/yaml.go b/test/parse/yaml.go index 847084b9c26..c5c78b9881f 100644 --- a/test/parse/yaml.go +++ b/test/parse/yaml.go @@ -117,17 +117,6 @@ func MustParseV1TaskAndSetDefaults(t *testing.T, yaml string) *v1.Task { return task } -// MustParseClusterTask takes YAML and parses it into a *v1beta1.ClusterTask -func MustParseClusterTask(t *testing.T, yaml string) *v1beta1.ClusterTask { - t.Helper() - var clusterTask v1beta1.ClusterTask - yaml = `apiVersion: tekton.dev/v1beta1 -kind: ClusterTask -` + yaml - mustParseYAML(t, yaml, &clusterTask) - return &clusterTask -} - // MustParseV1beta1PipelineRun takes YAML and parses it into a *v1beta1.PipelineRun func MustParseV1beta1PipelineRun(t *testing.T, yaml string) *v1beta1.PipelineRun { t.Helper() diff --git a/test/util.go b/test/util.go index e1254e2edb1..316a3d6bc3a 100644 --- a/test/util.go +++ b/test/util.go @@ -201,15 +201,6 @@ func getCRDYaml(ctx context.Context, cs *clients, ns string) ([]byte, error) { output = append(output, bs...) } - v1beta1ClusterTasks, err := cs.V1beta1ClusterTaskClient.List(ctx, metav1.ListOptions{}) - if err != nil { - return nil, fmt.Errorf("could not get v1beta1 clustertasks: %w", err) - } - for _, i := range v1beta1ClusterTasks.Items { - i.SetManagedFields(nil) - printOrAdd(i) - } - v1Tasks, err := cs.V1TaskClient.List(ctx, metav1.ListOptions{}) if err != nil { return nil, fmt.Errorf("could not get v1 tasks: %w", err)