diff --git a/config/crds/pipeline_v1beta1_pipeline.yaml b/config/crds/pipeline_v1beta1_pipeline.yaml index d1dab89896a..b9d3cfbb8da 100644 --- a/config/crds/pipeline_v1beta1_pipeline.yaml +++ b/config/crds/pipeline_v1beta1_pipeline.yaml @@ -44,20 +44,32 @@ spec: tasks: items: properties: + clusterBindings: + items: + properties: + inputName: + type: string + key: + type: string + required: + - 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: @@ -65,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/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/config/crds/pipeline_v1beta1_task.yaml b/config/crds/pipeline_v1beta1_task.yaml index c95b7063b03..0247ce50224 100644 --- a/config/crds/pipeline_v1beta1_task.yaml +++ b/config/crds/pipeline_v1beta1_task.yaml @@ -54,6 +54,21 @@ spec: type: object inputs: properties: + clusters: + 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/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 574d8611b47..a18ff693faf 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types.go @@ -72,13 +72,22 @@ type PipelineTaskParam struct { Value string `json:"value"` } +// ClusterBinding is used to bind a cluster from a PipelineParams to a cluster required +// as an input for a task. +type ClusterBinding struct { + // 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"` +} + // SourceBinding is used to bind a Source from a PipelineParams to a source required // as an input for a task. 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 diff --git a/pkg/apis/pipeline/v1beta1/pipelineparams_types.go b/pkg/apis/pipeline/v1beta1/pipelineparams_types.go index 5a917961ab5..ae2d4b7d9d5 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineparams_types.go +++ b/pkg/apis/pipeline/v1beta1/pipelineparams_types.go @@ -24,6 +24,8 @@ import ( type PipelineParamsSpec struct { ServiceAccount string `json:"serviceAccount"` Results Results `json:"results"` + // +optional + Clusters []Cluster `json:"clusters,omitempty"` } // PipelineParamsStatus defines the observed state of PipelineParams @@ -50,6 +52,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. diff --git a/pkg/apis/pipeline/v1beta1/task_types.go b/pkg/apis/pipeline/v1beta1/task_types.go index 8e1407b7e10..00afff6f028 100644 --- a/pkg/apis/pipeline/v1beta1/task_types.go +++ b/pkg/apis/pipeline/v1beta1/task_types.go @@ -61,6 +61,8 @@ type Inputs struct { Sources []Source `json:"resources,omitempty"` // +optional Params []Param `json:"params,omitempty"` + // +optional + Clusters []Cluster `json:"clusters,omitempty"` } // 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 3744a4f569c..35af91f3719 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.Clusters != nil { + in, out := &in.Clusters, &out.Clusters + *out = make([]Cluster, len(*in)) + copy(*out, *in) + } return } @@ -290,6 +327,11 @@ func (in *PipelineParamsRef) DeepCopy() *PipelineParamsRef { func (in *PipelineParamsSpec) DeepCopyInto(out *PipelineParamsSpec) { *out = *in in.Results.DeepCopyInto(&out.Results) + if in.Clusters != nil { + in, out := &in.Clusters, &out.Clusters + *out = make([]Cluster, len(*in)) + copy(*out, *in) + } return }