From 43218d390dd0a275001341bcf441700a020144a5 Mon Sep 17 00:00:00 2001 From: Shash Reddy Date: Fri, 21 Sep 2018 12:07:04 -0400 Subject: [PATCH 1/6] Add cluster and clusterBindings to types - Add clusters to pipelineparams - Add cluster inputs for tasks - Add clusterBindings for Pipelines --- .../crds/pipeline_v1beta1_pipelineparams.yaml | 15 +++++++++++++ pkg/apis/pipeline/v1beta1/pipeline_types.go | 9 ++++++++ .../pipeline/v1beta1/pipelineparams_types.go | 21 +++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/config/crds/pipeline_v1beta1_pipelineparams.yaml b/config/crds/pipeline_v1beta1_pipelineparams.yaml index ff3917e74d5..732ad4d81a9 100644 --- a/config/crds/pipeline_v1beta1_pipelineparams.yaml +++ b/config/crds/pipeline_v1beta1_pipelineparams.yaml @@ -22,6 +22,21 @@ spec: type: object spec: properties: + clusters: + items: + properties: + endpoint: + type: string + name: + type: string + type: + type: string + required: + - name + - type + - endpoint + type: object + type: array results: properties: logs: diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types.go b/pkg/apis/pipeline/v1beta1/pipeline_types.go index 574d8611b47..d20f99b9d9c 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types.go @@ -72,6 +72,15 @@ type PipelineTaskParam struct { Value string `json:"value"` } +// ClusterBinding is used to bind a clister from a PipelineParams to a cluster required +// as an input for a task. +type ClusterBinding struct { + // ClusterName is the string that the PipelineParams will use to identify this source. + ClusterName string `json:"clusterName"` + // InputName is the string the Task will use to identify this cluster in its inputs. + InputName string `json:"inputName"` +} + // SourceBinding is used to bind a Source from a PipelineParams to a source required // as an input for a task. type SourceBinding struct { diff --git a/pkg/apis/pipeline/v1beta1/pipelineparams_types.go b/pkg/apis/pipeline/v1beta1/pipelineparams_types.go index 5a917961ab5..21e011afe47 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineparams_types.go +++ b/pkg/apis/pipeline/v1beta1/pipelineparams_types.go @@ -22,8 +22,9 @@ import ( // PipelineParamsSpec is the spec for a Pipeline resource type PipelineParamsSpec struct { - ServiceAccount string `json:"serviceAccount"` - Results Results `json:"results"` + ServiceAccount string `json:"serviceAccount"` + Results Results `json:"results"` + Cluster []Cluster `json:"clusters,omitempty"` } // PipelineParamsStatus defines the observed state of PipelineParams @@ -50,6 +51,22 @@ type PipelineParams struct { Status PipelineParamsStatus `json:"status,omitempty"` } +// ClusterType represents the type of cluster, +// so that the controller will know how to deploy to it. +type ClusterType string + +const ( + // ClusterTypeGKE indicates that the URL endpoint is a GKE cluster. + ClusterTypeGKE = "gke" +) + +// Cluster contains information about the cluster on which task is being deployed +type Cluster struct { + Name string `json:"name"` + Type ClusterType `json:"type"` + Endpoint string `json:"endpoint"` +} + // Results tells a pipeline where to persist the results of runnign the pipeline. type Results struct { // Runs is used to store the yaml/json of TaskRuns and PipelineRuns. From 654ae930c2b5468e7f5f6a99aa138199d080599b Mon Sep 17 00:00:00 2001 From: Shash Reddy Date: Fri, 21 Sep 2018 12:34:15 -0400 Subject: [PATCH 2/6] Add generated code --- config/crds/pipeline_v1beta1_pipeline.yaml | 12 ++++++ config/crds/pipeline_v1beta1_task.yaml | 15 +++++++ .../pipeline/v1beta1/zz_generated.deepcopy.go | 42 +++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/config/crds/pipeline_v1beta1_pipeline.yaml b/config/crds/pipeline_v1beta1_pipeline.yaml index d1dab89896a..fadd8df190e 100644 --- a/config/crds/pipeline_v1beta1_pipeline.yaml +++ b/config/crds/pipeline_v1beta1_pipeline.yaml @@ -44,6 +44,18 @@ spec: tasks: items: properties: + clusterBindings: + items: + properties: + clusterName: + type: string + inputName: + type: string + required: + - clusterName + - inputName + type: object + type: array inputSourceBindings: items: properties: diff --git a/config/crds/pipeline_v1beta1_task.yaml b/config/crds/pipeline_v1beta1_task.yaml index c95b7063b03..8306aab9744 100644 --- a/config/crds/pipeline_v1beta1_task.yaml +++ b/config/crds/pipeline_v1beta1_task.yaml @@ -54,6 +54,21 @@ spec: type: object inputs: properties: + cluster: + items: + properties: + endpoint: + type: string + name: + type: string + type: + type: string + required: + - name + - type + - endpoint + type: object + type: array params: items: properties: diff --git a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go index 3744a4f569c..56cb9c53887 100644 --- a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go @@ -48,6 +48,38 @@ func (in *BuildSpec) DeepCopy() *BuildSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Cluster) DeepCopyInto(out *Cluster) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cluster. +func (in *Cluster) DeepCopy() *Cluster { + if in == nil { + return nil + } + out := new(Cluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterBinding) DeepCopyInto(out *ClusterBinding) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterBinding. +func (in *ClusterBinding) DeepCopy() *ClusterBinding { + if in == nil { + return nil + } + out := new(ClusterBinding) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitResource) DeepCopyInto(out *GitResource) { *out = *in @@ -93,6 +125,11 @@ func (in *Inputs) DeepCopyInto(out *Inputs) { *out = make([]Param, len(*in)) copy(*out, *in) } + if in.Cluster != nil { + in, out := &in.Cluster, &out.Cluster + *out = make([]Cluster, len(*in)) + copy(*out, *in) + } return } @@ -549,6 +586,11 @@ func (in *PipelineTask) DeepCopyInto(out *PipelineTask) { *out = make([]Param, len(*in)) copy(*out, *in) } + if in.ClusterBindings != nil { + in, out := &in.ClusterBindings, &out.ClusterBindings + *out = make([]ClusterBinding, len(*in)) + copy(*out, *in) + } return } From db74bbb944ce2cdea097700d63e816cd4712dde4 Mon Sep 17 00:00:00 2001 From: Shash Reddy Date: Fri, 21 Sep 2018 12:40:17 -0400 Subject: [PATCH 3/6] Fixed typos --- config/crds/pipeline_v1beta1_task.yaml | 2 +- pkg/apis/pipeline/v1beta1/pipelineparams_types.go | 2 +- pkg/apis/pipeline/v1beta1/task_types.go | 6 ++++++ pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | 13 +++++++++++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/config/crds/pipeline_v1beta1_task.yaml b/config/crds/pipeline_v1beta1_task.yaml index 8306aab9744..0247ce50224 100644 --- a/config/crds/pipeline_v1beta1_task.yaml +++ b/config/crds/pipeline_v1beta1_task.yaml @@ -54,7 +54,7 @@ spec: type: object inputs: properties: - cluster: + clusters: items: properties: endpoint: diff --git a/pkg/apis/pipeline/v1beta1/pipelineparams_types.go b/pkg/apis/pipeline/v1beta1/pipelineparams_types.go index 21e011afe47..d90f03c6d6e 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineparams_types.go +++ b/pkg/apis/pipeline/v1beta1/pipelineparams_types.go @@ -24,7 +24,7 @@ import ( type PipelineParamsSpec struct { ServiceAccount string `json:"serviceAccount"` Results Results `json:"results"` - Cluster []Cluster `json:"clusters,omitempty"` + Clusters []Cluster `json:"clusters,omitempty"` } // PipelineParamsStatus defines the observed state of PipelineParams diff --git a/pkg/apis/pipeline/v1beta1/task_types.go b/pkg/apis/pipeline/v1beta1/task_types.go index 8e1407b7e10..6174598ca8b 100644 --- a/pkg/apis/pipeline/v1beta1/task_types.go +++ b/pkg/apis/pipeline/v1beta1/task_types.go @@ -57,10 +57,16 @@ type Task struct { // Inputs are the requirements that a task needs to run a Build. type Inputs struct { +<<<<<<< HEAD // +optional Sources []Source `json:"resources,omitempty"` // +optional Params []Param `json:"params,omitempty"` +======= + Sources []Source `json:"resources,omitempty"` + Params []Param `json:"params,omitempty"` + Clusters []Cluster `json:"clusters,omitempty"` +>>>>>>> Fixed typos } // Source is data which is required by a Build/Task for context diff --git a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go index 56cb9c53887..92a438dfb39 100644 --- a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go @@ -125,8 +125,8 @@ func (in *Inputs) DeepCopyInto(out *Inputs) { *out = make([]Param, len(*in)) copy(*out, *in) } - if in.Cluster != nil { - in, out := &in.Cluster, &out.Cluster + if in.Clusters != nil { + in, out := &in.Clusters, &out.Clusters *out = make([]Cluster, len(*in)) copy(*out, *in) } @@ -326,7 +326,16 @@ func (in *PipelineParamsRef) DeepCopy() *PipelineParamsRef { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PipelineParamsSpec) DeepCopyInto(out *PipelineParamsSpec) { *out = *in +<<<<<<< HEAD in.Results.DeepCopyInto(&out.Results) +======= + out.Results = in.Results + if in.Clusters != nil { + in, out := &in.Clusters, &out.Clusters + *out = make([]Cluster, len(*in)) + copy(*out, *in) + } +>>>>>>> Fixed typos return } From baf41677efcf8404bf523b37d897955fcbfd42c7 Mon Sep 17 00:00:00 2001 From: Shash Reddy Date: Fri, 21 Sep 2018 13:59:48 -0400 Subject: [PATCH 4/6] Add optional tag --- pkg/apis/pipeline/v1beta1/pipeline_types.go | 2 +- pkg/apis/pipeline/v1beta1/pipelineparams_types.go | 7 ++++--- pkg/apis/pipeline/v1beta1/task_types.go | 6 +----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types.go b/pkg/apis/pipeline/v1beta1/pipeline_types.go index d20f99b9d9c..f58d45e8717 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types.go @@ -72,7 +72,7 @@ type PipelineTaskParam struct { Value string `json:"value"` } -// ClusterBinding is used to bind a clister from a PipelineParams to a cluster required +// ClusterBinding is used to bind a cluster from a PipelineParams to a cluster required // as an input for a task. type ClusterBinding struct { // ClusterName is the string that the PipelineParams will use to identify this source. diff --git a/pkg/apis/pipeline/v1beta1/pipelineparams_types.go b/pkg/apis/pipeline/v1beta1/pipelineparams_types.go index d90f03c6d6e..ae2d4b7d9d5 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineparams_types.go +++ b/pkg/apis/pipeline/v1beta1/pipelineparams_types.go @@ -22,9 +22,10 @@ import ( // PipelineParamsSpec is the spec for a Pipeline resource type PipelineParamsSpec struct { - ServiceAccount string `json:"serviceAccount"` - Results Results `json:"results"` - Clusters []Cluster `json:"clusters,omitempty"` + ServiceAccount string `json:"serviceAccount"` + Results Results `json:"results"` + // +optional + Clusters []Cluster `json:"clusters,omitempty"` } // PipelineParamsStatus defines the observed state of PipelineParams diff --git a/pkg/apis/pipeline/v1beta1/task_types.go b/pkg/apis/pipeline/v1beta1/task_types.go index 6174598ca8b..00afff6f028 100644 --- a/pkg/apis/pipeline/v1beta1/task_types.go +++ b/pkg/apis/pipeline/v1beta1/task_types.go @@ -57,16 +57,12 @@ type Task struct { // Inputs are the requirements that a task needs to run a Build. type Inputs struct { -<<<<<<< HEAD // +optional Sources []Source `json:"resources,omitempty"` // +optional Params []Param `json:"params,omitempty"` -======= - Sources []Source `json:"resources,omitempty"` - Params []Param `json:"params,omitempty"` + // +optional Clusters []Cluster `json:"clusters,omitempty"` ->>>>>>> Fixed typos } // Source is data which is required by a Build/Task for context From 37b18b2194d09605b08a366edc28709758fa4418 Mon Sep 17 00:00:00 2001 From: Shash Reddy Date: Mon, 24 Sep 2018 10:15:57 -0400 Subject: [PATCH 5/6] Rename sourceKey t0 key --- config/crds/pipeline_v1beta1_pipeline.yaml | 18 ++++++++--------- config/samples/pipeline_v1beta1_pipeline.yaml | 14 ++++++------- examples/pipelines/guestbook.yaml | 20 +++++++++---------- examples/pipelines/kritis.yaml | 10 +++++----- pkg/apis/pipeline/v1beta1/pipeline_types.go | 8 ++++---- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/config/crds/pipeline_v1beta1_pipeline.yaml b/config/crds/pipeline_v1beta1_pipeline.yaml index fadd8df190e..b9d3cfbb8da 100644 --- a/config/crds/pipeline_v1beta1_pipeline.yaml +++ b/config/crds/pipeline_v1beta1_pipeline.yaml @@ -47,29 +47,29 @@ spec: clusterBindings: items: properties: - clusterName: - type: string inputName: type: string + key: + type: string required: - - clusterName + - key - inputName type: object type: array inputSourceBindings: items: properties: + key: + type: string name: type: string passedConstraints: items: type: string type: array - sourceKey: - type: string required: - name - - sourceKey + - key type: object type: array name: @@ -77,17 +77,17 @@ spec: outputSourceBindings: items: properties: + key: + type: string name: type: string passedConstraints: items: type: string type: array - sourceKey: - type: string required: - name - - sourceKey + - key type: object type: array params: diff --git a/config/samples/pipeline_v1beta1_pipeline.yaml b/config/samples/pipeline_v1beta1_pipeline.yaml index 7936d8f83e4..6e0d26d85ea 100644 --- a/config/samples/pipeline_v1beta1_pipeline.yaml +++ b/config/samples/pipeline_v1beta1_pipeline.yaml @@ -10,17 +10,17 @@ spec: name: test-wizzbang-task inputsourceBindings: - name: repoUnderTest - sourceKey: wizzbang + key: wizzbang - name: 'buildPush' taskRef: name: build-push-task inputSourceBindings: - name: 'workspace' - sourceKey: 'wizzbang' + key: 'wizzbang' passedConstraint: [test-wizzbang-task] outputSourceBindings: - name: registry - sourceKey: wizzbangStagingImage + key: wizzbangStagingImage params: - name: pathToDockerfile value: build/Dockerfile @@ -29,11 +29,11 @@ spec: name: integration-test-wizzbang-task inputSourceBindings: - name: repoUnderTest - sourceKey: wizzbang + key: wizzbang passedConstraint: [test] outputSourceBindings: - name: registry - sourceKey: wizzbangStagingImage + key: wizzbangStagingImage passedConstraint: [build-push-task] - name: deploy taskRef: @@ -43,13 +43,13 @@ spec: value: deploy/helm inputSourceBindings: - name: repoToDeploy - sourceKey: wizzbang + key: wizzbang passedConstraint: [integration-test-wizzbang-task] clusterBindings: - clusterName: prod outputSourceBindings: - name: registry - sourceKey: wizzbangStagingImage + key: wizzbangStagingImage passedConstraint: [build-push-task] resources: - name: wizzbang diff --git a/examples/pipelines/guestbook.yaml b/examples/pipelines/guestbook.yaml index 087b311b2e2..eda044f3f2f 100644 --- a/examples/pipelines/guestbook.yaml +++ b/examples/pipelines/guestbook.yaml @@ -10,10 +10,10 @@ spec: name: build-push inputSourceBindings: - name: workspace - sourceKey: guestbook + key: guestbook outputSourceBindings: - name: registry - sourceKey: stagingRegistry + key: stagingRegistry params: - name: pathToDockerfile value: guestbook-go/Dockerfile @@ -22,10 +22,10 @@ spec: name: build-push inputSourceBindings: - name: workspace - sourceKey: redis-docker # TODO Add Commit SHA + key: redis-docker # TODO Add Commit SHA outputSourceBindings: - name: registry - sourceKey: stagingRegistry + key: stagingRegistry params: - name: pathToDockerfile value: 4/debian9/4.0/Dockerfile @@ -34,12 +34,12 @@ spec: name: deploy-with-kubectl inputSourceBindings: - name: workspace - sourceKey: guestbook + key: guestbook passedConstraint: - build-guestbook - build-redis - name: workspace - sourceKey: redis-docker + key: redis-docker passedConstraint: - build-push params: @@ -52,7 +52,7 @@ spec: name: integrationTestInDocker inputSourceBindings: - name: workspace - sourceKey: guestbook + key: guestbook passedConstraint: - deploy-bundle-test params: @@ -63,7 +63,7 @@ spec: name: integration-test-in-docker inputSourceBindings: - name: workspace - sourceKey: guestbook + key: guestbook passedConstraint: - deploy-bundle-test params: @@ -74,7 +74,7 @@ spec: name: deploy-with-kubectl inputSourceBindings: - name: workspace - sourceKey: guestbook + key: guestbook passedConstraint: - int-test-osx - int-test-linux @@ -89,7 +89,7 @@ spec: name: guestbook - name: redis-docker resourceRef: - name: redis-docker + name: redis-docker - name: stagingRegistry resourceRef: name: stagingRegistry \ No newline at end of file diff --git a/examples/pipelines/kritis.yaml b/examples/pipelines/kritis.yaml index 84804076619..5d97fb31de6 100644 --- a/examples/pipelines/kritis.yaml +++ b/examples/pipelines/kritis.yaml @@ -10,7 +10,7 @@ spec: name: make inputSourceBindings: - name: workspace - sourceKey: kritis-app-github + key: kritis-app-github params: - name: makeTarget value: test @@ -19,12 +19,12 @@ spec: name: build-push inputSourceBindings: - name: workspace - sourceKey: kritis-app-github + key: kritis-app-github passedConstraint: - make outputSourceBindings: - name: registry - sourceKey: stagingRegistry + key: stagingRegistry params: - name: pathToDockerfile value: deploy/Dockerfile @@ -33,7 +33,7 @@ spec: name: deploy-with-helm inputSourceBindings: - name: registry - sourceKey: stagingRegistry + key: stagingRegistry passedConstraint: [build-push] params: - name: pathToHelmCharts @@ -45,7 +45,7 @@ spec: name: integration-test-in-docker inputSourceBindings: - name: workspace - sourceKey: kritis-test-github + key: kritis-test-github passedConstraint: [deploy-with-helm] params: - name: testArgs diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types.go b/pkg/apis/pipeline/v1beta1/pipeline_types.go index f58d45e8717..a18ff693faf 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types.go @@ -75,8 +75,8 @@ type PipelineTaskParam struct { // ClusterBinding is used to bind a cluster from a PipelineParams to a cluster required // as an input for a task. type ClusterBinding struct { - // ClusterName is the string that the PipelineParams will use to identify this source. - ClusterName string `json:"clusterName"` + // Key is the string that the PipelineParams will use to identify this source. + Key string `json:"key"` // InputName is the string the Task will use to identify this cluster in its inputs. InputName string `json:"inputName"` } @@ -86,8 +86,8 @@ type ClusterBinding struct { type SourceBinding struct { // InputName is the string the Task will use to identify this resource in its inputs. Name string `json:"name"` - // SourceKey is the string that the PipelineParams will use to identify this source. - SourceKey string `json:"sourceKey"` + // Key is the string that the PipelineParams will use to identify this source. + Key string `json:"key"` // TODO: validate the passedConstraints values match previous Task names // PassedConstraints is the list of Task names that the resource has to pass through. // +optional From c35f3766af85fbf287cd0b42f71230a1890ec639 Mon Sep 17 00:00:00 2001 From: Shash Reddy Date: Mon, 24 Sep 2018 14:41:11 -0400 Subject: [PATCH 6/6] Resolve conflicts --- pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go index 92a438dfb39..35af91f3719 100644 --- a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go @@ -326,16 +326,12 @@ func (in *PipelineParamsRef) DeepCopy() *PipelineParamsRef { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PipelineParamsSpec) DeepCopyInto(out *PipelineParamsSpec) { *out = *in -<<<<<<< HEAD in.Results.DeepCopyInto(&out.Results) -======= - out.Results = in.Results if in.Clusters != nil { in, out := &in.Clusters, &out.Clusters *out = make([]Cluster, len(*in)) copy(*out, *in) } ->>>>>>> Fixed typos return } @@ -595,11 +591,6 @@ func (in *PipelineTask) DeepCopyInto(out *PipelineTask) { *out = make([]Param, len(*in)) copy(*out, *in) } - if in.ClusterBindings != nil { - in, out := &in.ClusterBindings, &out.ClusterBindings - *out = make([]ClusterBinding, len(*in)) - copy(*out, *in) - } return }