Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose v1beta1 to the world ⛈ #2035

Merged
merged 4 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/v1beta1"
"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{},
// v1beta1
v1beta1.SchemeGroupVersion.WithKind("Pipeline"): &v1beta1.Pipeline{},
v1beta1.SchemeGroupVersion.WithKind("Task"): &v1beta1.Task{},
v1beta1.SchemeGroupVersion.WithKind("ClusterTask"): &v1beta1.ClusterTask{},
v1beta1.SchemeGroupVersion.WithKind("TaskRun"): &v1beta1.TaskRun{},
v1beta1.SchemeGroupVersion.WithKind("PipelineRun"): &v1beta1.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
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ignore:
- "pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go"
- "pkg/apis/pipeline/v1alpha2/zz_generated.deepcopy.go"
- "pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go"
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: v1beta1
served: true
storage: false
This conversation was marked as resolved.
Show resolved Hide resolved
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: v1beta1
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: v1beta1
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: v1beta1
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: v1beta1
served: true
storage: false
names:
kind: TaskRun
plural: taskruns
Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions examples/v1beta1/pipelineruns/clustertask-pipelinerun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: tekton.dev/v1beta1
kind: ClusterTask
metadata:
name: cluster-task-pipeline-4
spec:
steps:
- name: task-two-step-one
image: ubuntu
command: ["/bin/bash"]
args: ['-c', 'echo success']
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: sample-pipeline-cluster-task-4
spec:
tasks:
- name: cluster-task-pipeline-4
taskRef:
name: cluster-task-pipeline-4
kind: ClusterTask
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: demo-pipeline-run-4
spec:
pipelineRef:
name: sample-pipeline-cluster-task-4
serviceAccountName: 'default'
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
name: verify-no-file-exists-without-resource
spec:
params:
- name: "path"
resources:
- name: optional-workspace
type: git
optional: true
check:
image: alpine
script: 'test ! -f $(resources.optional-workspace.path)/$(params.path)'
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: pipeline-git-repo
spec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/tektoncd/pipeline
---
apiVersion: tekton.dev/v1beta1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

kind: Task
metadata:
name: list-pipeline-repo-files
spec:
resources:
inputs:
- name: optional-workspace
type: git
optional: true
steps:
- name: run-ls
image: ubuntu
script: 'ls -al $(inputs.resources.optional-workspace.path)'
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: pipeline-list-pipeline-repo-files
spec:
resources:
- name: pipeline-source-repo
type: git
params:
- name: "path"
default: "README.md"
tasks:
- name: list-pipeline-repo-files-1
taskRef:
name: list-pipeline-repo-files
conditions:
- conditionRef: "verify-no-file-exists-without-resource"
params:
- name: "path"
value: "$(params.path)"
# NOTE: Resource "optional-workspace" is declared as optional in Condition
# No resource specified for the condition here since its optional
# "DO NOT UNCOMMENT THE FOLLOWING RESOURCE"
# resources:
# - name: optional-workspace
# resource: pipeline-source-repo
resources:
inputs:
- name: optional-workspace
resource: pipeline-source-repo
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: demo-condtional-pr-without-condition-resource
spec:
pipelineRef:
name: pipeline-list-pipeline-repo-files
serviceAccountName: 'default'
resources:
- name: pipeline-source-repo
resourceRef:
name: pipeline-git-repo
94 changes: 94 additions & 0 deletions examples/v1beta1/pipelineruns/conditional-pipelinerun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
name: file-exists
spec:
params:
- name: "path"
resources:
- name: workspace
type: git
check:
image: alpine
script: 'test -f $(resources.workspace.path)/$(params.path)'
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: pipeline-git
spec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/tektoncd/pipeline
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: create-readme-file
spec:
resources:
outputs:
- name: workspace
type: git
steps:
- name: write-new-stuff
image: ubuntu
script: 'touch $(resources.outputs.workspace.path)/README.md'
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: echo-hello
spec:
steps:
- name: echo
image: ubuntu
script: 'echo hello'
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: conditional-pipeline
spec:
resources:
- name: source-repo
type: git
params:
- name: "path"
default: "README.md"
tasks:
- name: first-create-file
taskRef:
name: create-readme-file
resources:
outputs:
- name: workspace
resource: source-repo
- name: then-check
conditions:
- conditionRef: "file-exists"
params:
- name: "path"
value: "$(params.path)"
resources:
- name: workspace
resource: source-repo
from: [first-create-file]
taskRef:
name: echo-hello
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: condtional-pr
spec:
pipelineRef:
name: conditional-pipeline
serviceAccountName: 'default'
resources:
- name: source-repo
resourceRef:
name: pipeline-git
Loading