From 8123d6332245008983aabe1dc910a63bd2c6f261 Mon Sep 17 00:00:00 2001 From: Chitrang Patel Date: Fri, 20 Oct 2023 15:31:08 -0400 Subject: [PATCH] Introducing the StepAction CRD This PR introduces the StepAction CRD in `v1alpha1`. This is not the complete CRD. As we add support for `params`, `results` etc. we will introduce in follow-up PRs. It is the first of many implementation PRs as described in issue: https://github.com/tektoncd/pipeline/issues/7259 --- cmd/webhook/main.go | 6 + config/200-clusterrole.yaml | 5 +- config/300-stepaction.yaml | 53 + config/clusterrole-aggregate-edit.yaml | 1 + config/clusterrole-aggregate-view.yaml | 1 + docs/pipeline-api.md | 249 +++++ docs/stepactions.md | 56 + hack/ignored-openapi-violations.list | 3 + hack/spec-gen/main.go | 5 + hack/update-openapigen.sh | 2 +- pkg/apis/pipeline/register.go | 8 + .../pipeline/v1alpha1/openapi_generated.go | 981 ++++++++++++++++++ pkg/apis/pipeline/v1alpha1/register.go | 2 + .../v1alpha1/stepaction_conversion.go | 42 + .../pipeline/v1alpha1/stepaction_defaults.go | 26 + .../pipeline/v1alpha1/stepaction_types.go | 122 +++ .../v1alpha1/stepaction_validation.go | 62 ++ .../v1alpha1/stepaction_validation_test.go | 219 ++++ pkg/apis/pipeline/v1alpha1/swagger.json | 515 +++++++++ .../v1alpha1/zz_generated.deepcopy.go | 93 ++ .../v1alpha1/fake/fake_pipeline_client.go | 4 + .../pipeline/v1alpha1/fake/fake_stepaction.go | 130 +++ .../pipeline/v1alpha1/generated_expansion.go | 2 + .../pipeline/v1alpha1/pipeline_client.go | 5 + .../typed/pipeline/v1alpha1/stepaction.go | 178 ++++ .../informers/externalversions/generic.go | 2 + .../pipeline/v1alpha1/interface.go | 7 + .../pipeline/v1alpha1/stepaction.go | 90 ++ .../pipeline/v1alpha1/stepaction/fake/fake.go | 40 + .../v1alpha1/stepaction/filtered/fake/fake.go | 52 + .../stepaction/filtered/stepaction.go | 65 ++ .../v1alpha1/stepaction/stepaction.go | 52 + .../v1alpha1/stepaction/controller.go | 167 +++ .../v1alpha1/stepaction/reconciler.go | 365 +++++++ .../pipeline/v1alpha1/stepaction/state.go | 97 ++ .../pipeline/v1alpha1/expansion_generated.go | 8 + .../listers/pipeline/v1alpha1/stepaction.go | 99 ++ 37 files changed, 3811 insertions(+), 3 deletions(-) create mode 100644 config/300-stepaction.yaml create mode 100644 docs/stepactions.md create mode 100644 pkg/apis/pipeline/v1alpha1/openapi_generated.go create mode 100644 pkg/apis/pipeline/v1alpha1/stepaction_conversion.go create mode 100644 pkg/apis/pipeline/v1alpha1/stepaction_defaults.go create mode 100644 pkg/apis/pipeline/v1alpha1/stepaction_types.go create mode 100644 pkg/apis/pipeline/v1alpha1/stepaction_validation.go create mode 100644 pkg/apis/pipeline/v1alpha1/stepaction_validation_test.go create mode 100644 pkg/apis/pipeline/v1alpha1/swagger.json create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_stepaction.go create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1alpha1/stepaction.go create mode 100644 pkg/client/informers/externalversions/pipeline/v1alpha1/stepaction.go create mode 100644 pkg/client/injection/informers/pipeline/v1alpha1/stepaction/fake/fake.go create mode 100644 pkg/client/injection/informers/pipeline/v1alpha1/stepaction/filtered/fake/fake.go create mode 100644 pkg/client/injection/informers/pipeline/v1alpha1/stepaction/filtered/stepaction.go create mode 100644 pkg/client/injection/informers/pipeline/v1alpha1/stepaction/stepaction.go create mode 100644 pkg/client/injection/reconciler/pipeline/v1alpha1/stepaction/controller.go create mode 100644 pkg/client/injection/reconciler/pipeline/v1alpha1/stepaction/reconciler.go create mode 100644 pkg/client/injection/reconciler/pipeline/v1alpha1/stepaction/state.go create mode 100644 pkg/client/listers/pipeline/v1alpha1/stepaction.go diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 4aacc24148b..b1c8b2d703b 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -52,6 +52,7 @@ import ( var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ // v1alpha1 v1alpha1.SchemeGroupVersion.WithKind("VerificationPolicy"): &v1alpha1.VerificationPolicy{}, + v1alpha1.SchemeGroupVersion.WithKind("StepAction"): &v1alpha1.StepAction{}, // v1beta1 v1beta1.SchemeGroupVersion.WithKind("Pipeline"): &v1beta1.Pipeline{}, v1beta1.SchemeGroupVersion.WithKind("Task"): &v1beta1.Task{}, @@ -152,6 +153,7 @@ func newConfigValidationController(name string) func(context.Context, configmap. func newConversionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl { var ( + v1alpha1GroupVersion = v1alpha1.SchemeGroupVersion.Version v1beta1GroupVersion = v1beta1.SchemeGroupVersion.Version v1GroupVersion = v1.SchemeGroupVersion.Version resolutionv1alpha1GroupVersion = resolutionv1alpha1.SchemeGroupVersion.Version @@ -169,6 +171,10 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher) *contro // conversions to and from all types. // "Zygotes" are the supported versions. map[schema.GroupKind]conversion.GroupKindConversion{ + v1alpha1.Kind("StepAction"): { + DefinitionName: pipeline.StepActionResource.String(), + HubVersion: v1alpha1GroupVersion, + }, v1.Kind("Task"): { DefinitionName: pipeline.TaskResource.String(), HubVersion: v1beta1GroupVersion, diff --git a/config/200-clusterrole.yaml b/config/200-clusterrole.yaml index 4acffe6aa6a..2fd97b4a9f0 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"] + resources: ["tasks", "clustertasks", "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"] + resources: ["tasks/status", "clustertasks/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"] @@ -98,6 +98,7 @@ rules: - resolutionrequests.resolution.tekton.dev - customruns.tekton.dev - verificationpolicies.tekton.dev + - stepactions.tekton.dev # knative.dev/pkg needs list/watch permissions to set up informers for the webhook. - apiGroups: ["apiextensions.k8s.io"] resources: ["customresourcedefinitions"] diff --git a/config/300-stepaction.yaml b/config/300-stepaction.yaml new file mode 100644 index 00000000000..a27eaf20179 --- /dev/null +++ b/config/300-stepaction.yaml @@ -0,0 +1,53 @@ +# Copyright 2023 The Tekton Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: stepactions.tekton.dev + labels: + app.kubernetes.io/instance: default + app.kubernetes.io/part-of: tekton-pipelines + pipeline.tekton.dev/release: "devel" + version: "devel" +spec: + group: tekton.dev + preserveUnknownFields: false + versions: + - name: v1alpha1 + served: true + storage: true + schema: + openAPIV3Schema: + type: object + # One can use x-kubernetes-preserve-unknown-fields: true + # at the root of the schema (and inside any properties, additionalProperties) + # to get the traditional CRD behaviour that nothing is pruned, despite + # setting spec.preserveUnknownProperties: false. + # + # See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/ + # See issue: https://github.com/knative/serving/issues/912 + x-kubernetes-preserve-unknown-fields: true + # Opt into the status subresource so metadata.generation + # starts to increment + subresources: + status: {} + names: + kind: StepAction + plural: stepactions + singular: stepaction + categories: + - tekton + - tekton-pipelines + scope: Namespaced diff --git a/config/clusterrole-aggregate-edit.yaml b/config/clusterrole-aggregate-edit.yaml index 8f5b79b189e..fc67811f2c1 100644 --- a/config/clusterrole-aggregate-edit.yaml +++ b/config/clusterrole-aggregate-edit.yaml @@ -31,6 +31,7 @@ rules: - pipelineruns - runs - customruns + - stepactions verbs: - create - delete diff --git a/config/clusterrole-aggregate-view.yaml b/config/clusterrole-aggregate-view.yaml index 766d76bc16f..2edc274de56 100644 --- a/config/clusterrole-aggregate-view.yaml +++ b/config/clusterrole-aggregate-view.yaml @@ -30,6 +30,7 @@ rules: - pipelineruns - runs - customruns + - stepactions verbs: - get - list diff --git a/docs/pipeline-api.md b/docs/pipeline-api.md index 9b73b9e7e40..39d002be95c 100644 --- a/docs/pipeline-api.md +++ b/docs/pipeline-api.md @@ -6134,6 +6134,8 @@ Resource Types: