From d26556b22349b0c8389206d2cdc2f9deb6c8649d Mon Sep 17 00:00:00 2001 From: Jerome Ju Date: Fri, 9 Sep 2022 15:42:25 +0000 Subject: [PATCH] Add V1 version of PipelineRun CRD This commit adds a v1 version of the PipelineRun CRD, and support to the webhook. Since the version is not served, it will not be available to users at the moment. --- cmd/webhook/main.go | 15 ++++++++++++--- config/300-pipelinerun.yaml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 9c7f34bdeb8..93668dcd01d 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -58,9 +58,10 @@ var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ v1beta1.SchemeGroupVersion.WithKind("TaskRun"): &v1beta1.TaskRun{}, v1beta1.SchemeGroupVersion.WithKind("PipelineRun"): &v1beta1.PipelineRun{}, // v1 - v1.SchemeGroupVersion.WithKind("Task"): &v1.Task{}, - v1.SchemeGroupVersion.WithKind("Pipeline"): &v1.Pipeline{}, - v1.SchemeGroupVersion.WithKind("TaskRun"): &v1.TaskRun{}, + v1.SchemeGroupVersion.WithKind("Task"): &v1.Task{}, + v1.SchemeGroupVersion.WithKind("Pipeline"): &v1.Pipeline{}, + v1.SchemeGroupVersion.WithKind("TaskRun"): &v1.TaskRun{}, + v1.SchemeGroupVersion.WithKind("PipelineRun"): &v1.PipelineRun{}, // resolution // v1alpha1 @@ -173,6 +174,14 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher) *contro v1GroupVersion: &v1.TaskRun{}, }, }, + v1.Kind("PipelineRun"): { + DefinitionName: pipeline.PipelineRunResource.String(), + HubVersion: v1beta1GroupVersion, + Zygotes: map[string]conversion.ConvertibleObject{ + v1beta1GroupVersion: &v1beta1.PipelineRun{}, + v1GroupVersion: &v1.PipelineRun{}, + }, + }, }, // A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata diff --git a/config/300-pipelinerun.yaml b/config/300-pipelinerun.yaml index 683983fa878..b941a296e89 100644 --- a/config/300-pipelinerun.yaml +++ b/config/300-pipelinerun.yaml @@ -56,6 +56,37 @@ spec: # starts to increment subresources: status: {} + - name: v1 + served: false + storage: false + 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 + additionalPrinterColumns: + - name: Succeeded + type: string + jsonPath: ".status.conditions[?(@.type==\"Succeeded\")].status" + - name: Reason + type: string + jsonPath: ".status.conditions[?(@.type==\"Succeeded\")].reason" + - name: StartTime + type: date + jsonPath: .status.startTime + - name: CompletionTime + type: date + jsonPath: .status.completionTime + # Opt into the status subresource so metadata.generation + # starts to increment + subresources: + status: {} names: kind: PipelineRun plural: pipelineruns