Skip to content

Commit

Permalink
Expose v1alpha2 through the webhook ⛈
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
  • Loading branch information
vdemeester committed Feb 17, 2020
1 parent 7cdd923 commit ef66574
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

defaultconfig "github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2"
"github.com/tektoncd/pipeline/pkg/contexts"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/configmap"
Expand All @@ -38,13 +39,20 @@ import (
)

var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{
// v1alpha1
v1alpha1.SchemeGroupVersion.WithKind("Pipeline"): &v1alpha1.Pipeline{},
v1alpha1.SchemeGroupVersion.WithKind("Task"): &v1alpha1.Task{},
v1alpha1.SchemeGroupVersion.WithKind("ClusterTask"): &v1alpha1.ClusterTask{},
v1alpha1.SchemeGroupVersion.WithKind("TaskRun"): &v1alpha1.TaskRun{},
v1alpha1.SchemeGroupVersion.WithKind("PipelineRun"): &v1alpha1.PipelineRun{},
v1alpha1.SchemeGroupVersion.WithKind("Condition"): &v1alpha1.Condition{},
v1alpha1.SchemeGroupVersion.WithKind("PipelineResource"): &v1alpha1.PipelineResource{},
// v1alpha2
v1alpha2.SchemeGroupVersion.WithKind("Pipeline"): &v1alpha2.Pipeline{},
v1alpha2.SchemeGroupVersion.WithKind("Task"): &v1alpha2.Task{},
v1alpha2.SchemeGroupVersion.WithKind("ClusterTask"): &v1alpha2.ClusterTask{},
v1alpha2.SchemeGroupVersion.WithKind("TaskRun"): &v1alpha2.TaskRun{},
v1alpha2.SchemeGroupVersion.WithKind("PipelineRun"): &v1alpha2.PipelineRun{},
}

func NewDefaultingAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
Expand All @@ -65,9 +73,7 @@ func NewDefaultingAdmissionController(ctx context.Context, cmw configmap.Watcher

// A function that infuses the context passed to Validate/SetDefaults with custom metadata.
func(ctx context.Context) context.Context {
// FIXME(vdemeester) uncomment that for auto-conversion
// return v1alpha2.WithUpgradeViaDefaulting(store.ToContext(ctx))
return contexts.WithDefaultConfigurationName(store.ToContext(ctx))
return contexts.WithUpgradeViaDefaulting(store.ToContext(ctx))
},

// Whether to disallow unknown fields.
Expand Down
7 changes: 7 additions & 0 deletions config/300-clustertask.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ metadata:
name: clustertasks.tekton.dev
spec:
group: tekton.dev
versions:
- name: v1alpha1
served: true
storage: true
- name: v1alpha2
served: true
storage: false
names:
kind: ClusterTask
plural: clustertasks
Expand Down
7 changes: 7 additions & 0 deletions config/300-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ metadata:
name: pipelines.tekton.dev
spec:
group: tekton.dev
versions:
- name: v1alpha1
served: true
storage: true
- name: v1alpha2
served: true
storage: false
names:
kind: Pipeline
plural: pipelines
Expand Down
7 changes: 7 additions & 0 deletions config/300-pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ metadata:
name: pipelineruns.tekton.dev
spec:
group: tekton.dev
versions:
- name: v1alpha1
served: true
storage: true
- name: v1alpha2
served: true
storage: false
names:
kind: PipelineRun
plural: pipelineruns
Expand Down
7 changes: 7 additions & 0 deletions config/300-task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ metadata:
name: tasks.tekton.dev
spec:
group: tekton.dev
versions:
- name: v1alpha1
served: true
storage: true
- name: v1alpha2
served: true
storage: false
names:
kind: Task
plural: tasks
Expand Down
7 changes: 7 additions & 0 deletions config/300-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ metadata:
name: taskruns.tekton.dev
spec:
group: tekton.dev
versions:
- name: v1alpha1
served: true
storage: true
- name: v1alpha2
served: true
storage: false
names:
kind: TaskRun
plural: taskruns
Expand Down

0 comments on commit ef66574

Please sign in to comment.