Skip to content

Commit dd90617

Browse files
committed
Add v1 version to Task CRD
This commit adds a v1 version of the Task CRD, and support to the webhook. Since this version is not served, it will not be available to users.
1 parent b754e71 commit dd90617

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

cmd/webhook/main.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"os"
2424

2525
defaultconfig "github.com/tektoncd/pipeline/pkg/apis/config"
26+
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
27+
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
2628
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
2729
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
2830
resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
@@ -54,6 +56,8 @@ var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{
5456
v1beta1.SchemeGroupVersion.WithKind("ClusterTask"): &v1beta1.ClusterTask{},
5557
v1beta1.SchemeGroupVersion.WithKind("TaskRun"): &v1beta1.TaskRun{},
5658
v1beta1.SchemeGroupVersion.WithKind("PipelineRun"): &v1beta1.PipelineRun{},
59+
// v1
60+
v1.SchemeGroupVersion.WithKind("Task"): &v1.Task{},
5761
}
5862

5963
func newDefaultingAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
@@ -126,12 +130,27 @@ func newConfigValidationController(ctx context.Context, cmw configmap.Watcher) *
126130
}
127131

128132
func newConversionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
133+
// nolint: revive
134+
var (
135+
v1beta1GroupVersion = v1beta1.SchemeGroupVersion.Version
136+
v1GroupVersion = v1.SchemeGroupVersion.Version
137+
)
129138
return conversion.NewConversionController(ctx,
130139
// The path on which to serve the webhook
131140
"/resource-conversion",
132141

133142
// Specify the types of custom resource definitions that should be converted
134-
map[schema.GroupKind]conversion.GroupKindConversion{},
143+
// "HubVersion" is the stored version, and "Zygotes" are the supported versions
144+
map[schema.GroupKind]conversion.GroupKindConversion{
145+
v1.Kind("Task"): {
146+
DefinitionName: pipeline.TaskResource.String(),
147+
HubVersion: v1beta1GroupVersion,
148+
Zygotes: map[string]conversion.ConvertibleObject{
149+
v1beta1GroupVersion: &v1beta1.Task{},
150+
v1GroupVersion: &v1.Task{},
151+
},
152+
},
153+
},
135154

136155
// A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata
137156
func(ctx context.Context) context.Context {

config/300-task.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ spec:
4343
# starts to increment
4444
subresources:
4545
status: {}
46+
- name: v1
47+
served: false
48+
storage: false
49+
schema:
50+
openAPIV3Schema:
51+
type: object
52+
# TODO(#1461): Add OpenAPIV3 schema
53+
# OpenAPIV3 schema allows Kubernetes to perform validation on the schema fields
54+
# and use the schema in tooling such as `kubectl explain`.
55+
# Using "x-kubernetes-preserve-unknown-fields: true"
56+
# at the root of the schema (or within it) allows arbitrary fields.
57+
# We currently perform our own validation separately.
58+
# See https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#specifying-a-structural-schema
59+
# for more info.
60+
x-kubernetes-preserve-unknown-fields: true
61+
# Opt into the status subresource so metadata.generation
62+
# starts to increment
63+
subresources:
64+
status: {}
4665
names:
4766
kind: Task
4867
plural: tasks
@@ -54,7 +73,7 @@ spec:
5473
conversion:
5574
strategy: Webhook
5675
webhook:
57-
conversionReviewVersions: ["v1beta1"]
76+
conversionReviewVersions: ["v1beta1", "v1"]
5877
clientConfig:
5978
service:
6079
name: tekton-pipelines-webhook

0 commit comments

Comments
 (0)