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

introduce v1alpha2 api with auto conversion #1529

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 10 additions & 1 deletion cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

apiconfig "github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2"
tklogging "github.com/tektoncd/pipeline/pkg/logging"
"github.com/tektoncd/pipeline/pkg/system"
"go.uber.org/zap"
Expand Down Expand Up @@ -95,6 +96,14 @@ func main() {
v1alpha1.SchemeGroupVersion.WithKind("TaskRun"): &v1alpha1.TaskRun{},
v1alpha1.SchemeGroupVersion.WithKind("PipelineRun"): &v1alpha1.PipelineRun{},
v1alpha1.SchemeGroupVersion.WithKind("Condition"): &v1alpha1.Condition{},

v1alpha2.SchemeGroupVersion.WithKind("Pipeline"): &v1alpha2.Pipeline{},
v1alpha2.SchemeGroupVersion.WithKind("PipelineResource"): &v1alpha2.PipelineResource{},
v1alpha2.SchemeGroupVersion.WithKind("Task"): &v1alpha2.Task{},
v1alpha2.SchemeGroupVersion.WithKind("ClusterTask"): &v1alpha2.ClusterTask{},
v1alpha2.SchemeGroupVersion.WithKind("TaskRun"): &v1alpha2.TaskRun{},
v1alpha2.SchemeGroupVersion.WithKind("PipelineRun"): &v1alpha2.PipelineRun{},
v1alpha2.SchemeGroupVersion.WithKind("Condition"): &v1alpha2.Condition{},
}

resourceAdmissionController := webhook.NewResourceAdmissionController(resourceHandlers, options, true)
Expand All @@ -104,7 +113,7 @@ func main() {

// Decorate contexts with the current state of the config.
ctxFunc := func(ctx context.Context) context.Context {
return v1alpha1.WithDefaultConfigurationName(store.ToContext(ctx))
return v1alpha2.WithUpgradeViaDefaulting(store.ToContext(ctx))
Copy link
Member Author

Choose a reason for hiding this comment

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

This tells the webhook to do the conversion 👼

}

controller, err := webhook.New(kubeClient, options, admissionControllers, logger, ctxFunc)
Expand Down
8 changes: 7 additions & 1 deletion 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
Comment on lines +20 to +26
Copy link
Member Author

Choose a reason for hiding this comment

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

v1alpha1 is the stored version, but both are served

names:
kind: ClusterTask
plural: clustertasks
Expand All @@ -28,4 +35,3 @@ spec:
# starts to increment
subresources:
status: {}
version: v1alpha1
8 changes: 7 additions & 1 deletion config/300-condition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ metadata:
name: conditions.tekton.dev
spec:
group: tekton.dev
versions:
- name: v1alpha1
served: true
storage: true
- name: v1alpha2
served: true
storage: false
names:
kind: Condition
plural: conditions
Expand All @@ -28,4 +35,3 @@ spec:
# starts to increment
subresources:
status: {}
version: v1alpha1
8 changes: 7 additions & 1 deletion 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 All @@ -28,4 +35,3 @@ spec:
# starts to increment
subresources:
status: {}
version: v1alpha1
8 changes: 7 additions & 1 deletion 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 Expand Up @@ -44,4 +51,3 @@ spec:
# starts to increment
subresources:
status: {}
version: v1alpha1
8 changes: 7 additions & 1 deletion config/300-resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ metadata:
name: pipelineresources.tekton.dev
spec:
group: tekton.dev
versions:
- name: v1alpha1
served: true
storage: true
- name: v1alpha2
served: true
storage: false
names:
kind: PipelineResource
plural: pipelineresources
Expand All @@ -28,4 +35,3 @@ spec:
# starts to increment
subresources:
status: {}
version: v1alpha1
8 changes: 7 additions & 1 deletion 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 All @@ -28,4 +35,3 @@ spec:
# starts to increment
subresources:
status: {}
version: v1alpha1
9 changes: 8 additions & 1 deletion 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 Expand Up @@ -44,4 +51,4 @@ spec:
# starts to increment
subresources:
status: {}
version: v1alpha1

34 changes: 17 additions & 17 deletions examples/pipelineruns/pipelinerun.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Copy link
Member Author

Choose a reason for hiding this comment

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

This files contains v1alpha2 and v1alpha1 Tasks

apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1alpha2
kind: PipelineResource
metadata:
name: skaffold-image-leeroy-app
Expand All @@ -26,7 +26,7 @@ roleRef:
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1alpha2
kind: PipelineResource
metadata:
name: skaffold-image-leeroy-web-pipelinerun
Expand All @@ -36,7 +36,7 @@ spec:
- name: url
value: gcr.io/christiewilson-catfactory/leeroy-web
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1alpha2
kind: PipelineResource
metadata:
name: skaffold-git-pipelinerun
Expand All @@ -48,7 +48,7 @@ spec:
- name: url
value: https://github.com/GoogleContainerTools/skaffold
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1alpha2
kind: Task
metadata:
name: unit-tests
Expand All @@ -70,7 +70,7 @@ spec:
args:
- "pass"
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1alpha2
kind: Task
metadata:
name: build-push
Expand All @@ -79,13 +79,13 @@ spec:
resources:
- name: workspace
type: git
params:
- name: pathToDockerFile
description: The path to the dockerfile to build
default: /workspace/workspace/Dockerfile
- name: pathToContext
description: The build context used by Kaniko (https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts)
default: /workspace/workspace
params:
- name: pathToDockerFile
description: The path to the dockerfile to build
default: /workspace/workspace/Dockerfile
- name: pathToContext
description: The build context used by Kaniko (https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts)
default: /workspace/workspace
outputs:
resources:
- name: builtImage
Expand All @@ -100,9 +100,9 @@ spec:
command:
- /kaniko/executor
args:
- --dockerfile=$(inputs.params.pathToDockerFile)
- --dockerfile=$(params.pathToDockerFile)
- --destination=$(outputs.resources.builtImage.url)
- --context=$(inputs.params.pathToContext)
- --context=$(params.pathToContext)
---
#This task deploys with kubectl apply -f <filename>
apiVersion: tekton.dev/v1alpha1
Expand Down Expand Up @@ -131,7 +131,7 @@ spec:
- "w"
- "-i"
- "$(inputs.params.yqArg)"
- "$(inputs.params.path)"
- "$kube(inputs.params.path)"
Copy link
Contributor

@cccfeng cccfeng Nov 16, 2019

Choose a reason for hiding this comment

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

Hi, it looks like this line of code has one more word “kube” .

- "$(inputs.params.yamlPathToImage)"
- "$(inputs.resources.image.url)"
- name: run-kubectl
Expand All @@ -150,7 +150,7 @@ spec:
# pushed are the ones that are deployed (that would require using the digest of
# the built image, see https://github.com/tektoncd/pipeline/issues/216).

apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1alpha2
kind: Pipeline
metadata:
name: demo-pipeline
Expand Down Expand Up @@ -239,7 +239,7 @@ spec:
- name: yamlPathToImage
value: "spec.template.spec.containers[0].image"
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1alpha2
kind: PipelineRun
metadata:
name: demo-pipeline-run-1
Expand Down
51 changes: 29 additions & 22 deletions examples/taskruns/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,36 @@ metadata:
data:
test.data: tasks are my jam
---
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1alpha2
kind: Task
metadata:
name: foo
spec:
steps:
- name: secret
image: ubuntu
command: ['bash']
args:
- '-c'
- '[[ $(cat /config/test.data) == $TEST_DATA ]]'
env:
- name: TEST_DATA
valueFrom:
configMapKeyRef:
name: config-for-testing-configmaps
key: test.data
volumeMounts:
- name: config-volume
mountPath: /config
volumes:
- name: config-volume
configMap:
name: config-for-testing-configmaps
---
apiVersion: tekton.dev/v1alpha2
kind: TaskRun
metadata:
generateName: configmap-
spec:
taskSpec:
steps:
- name: secret
image: ubuntu
command: ['bash']
args:
- '-c'
- '[[ $(cat /config/test.data) == $TEST_DATA ]]'
env:
- name: TEST_DATA
valueFrom:
configMapKeyRef:
name: config-for-testing-configmaps
key: test.data
volumeMounts:
- name: config-volume
mountPath: /config
volumes:
- name: config-volume
configMap:
name: config-for-testing-configmaps
taskRef:
name: foo
4 changes: 2 additions & 2 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 ./ven
# instead of the $GOPATH directly. For normal projects this can be dropped.
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/tektoncd/pipeline/pkg/client github.com/tektoncd/pipeline/pkg/apis \
pipeline:v1alpha1 \
pipeline:v1alpha1,v1alpha2 \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt

# Depends on generate-groups.sh to install bin/deepcopy-gen
Expand All @@ -42,7 +42,7 @@ ${GOPATH}/bin/deepcopy-gen \
# Knative Injection
${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \
github.com/tektoncd/pipeline/pkg/client github.com/tektoncd/pipeline/pkg/apis \
"pipeline:v1alpha1" \
"pipeline:v1alpha1,v1alpha2" \
Copy link
Member Author

Choose a reason for hiding this comment

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

This updates codegen to generate v1alpha1 and v1alpha2 clientset, informers, …

--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt

# Make sure our dependencies are up-to-date
Expand Down
Loading