diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 71d3e8135fc..a1c4e021e28 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -23,6 +23,8 @@ import ( "os" defaultconfig "github.com/tektoncd/pipeline/pkg/apis/config" + "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" @@ -54,6 +56,8 @@ var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ v1beta1.SchemeGroupVersion.WithKind("ClusterTask"): &v1beta1.ClusterTask{}, v1beta1.SchemeGroupVersion.WithKind("TaskRun"): &v1beta1.TaskRun{}, v1beta1.SchemeGroupVersion.WithKind("PipelineRun"): &v1beta1.PipelineRun{}, + // v1 + v1.SchemeGroupVersion.WithKind("Pipeline"): &v1.Pipeline{}, } func newDefaultingAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl { @@ -131,7 +135,16 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher) *contro "/resource-conversion", // Specify the types of custom resource definitions that should be converted - map[schema.GroupKind]conversion.GroupKindConversion{}, + map[schema.GroupKind]conversion.GroupKindConversion{ + v1.Kind("Pipeline"): { + DefinitionName: pipeline.TaskResource.String(), + HubVersion: v1beta1GroupVersion, + Zygotes: map[string]conversion.ConvertibleObject{ + v1beta1GroupVersion: &v1beta1.Pipeline{}, + v1GroupVersion: &v1.Pipeline{}, + }, + }, + }, // A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata func(ctx context.Context) context.Context { diff --git a/config/300-pipeline.yaml b/config/300-pipeline.yaml index a7798c2330e..bb151297d54 100644 --- a/config/300-pipeline.yaml +++ b/config/300-pipeline.yaml @@ -32,6 +32,20 @@ spec: # starts to increment subresources: status: {} + 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 + - name: v1 + served: false + storage: false schema: openAPIV3Schema: type: object @@ -43,6 +57,10 @@ spec: # 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: Pipeline plural: pipelines @@ -54,7 +72,7 @@ spec: conversion: strategy: Webhook webhook: - conversionReviewVersions: ["v1beta1"] + conversionReviewVersions: ["v1beta1", "v1"] clientConfig: service: name: tekton-pipelines-webhook