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

Add cluster and cluster bindings #60

Merged
merged 6 commits into from
Sep 24, 2018
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
24 changes: 18 additions & 6 deletions config/crds/pipeline_v1beta1_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,50 @@ 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:
type: string
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:
Expand Down
15 changes: 15 additions & 0 deletions config/crds/pipeline_v1beta1_pipelineparams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ spec:
type: object
spec:
properties:
clusters:
items:
properties:
endpoint:
type: string
name:
type: string
type:
type: string
required:
imjasonh marked this conversation as resolved.
Show resolved Hide resolved
- name
- type
- endpoint
type: object
type: array
results:
properties:
logs:
Expand Down
15 changes: 15 additions & 0 deletions config/crds/pipeline_v1beta1_task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions config/samples/pipeline_v1beta1_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions examples/pipelines/guestbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -52,7 +52,7 @@ spec:
name: integrationTestInDocker
inputSourceBindings:
- name: workspace
sourceKey: guestbook
key: guestbook
passedConstraint:
- deploy-bundle-test
params:
Expand All @@ -63,7 +63,7 @@ spec:
name: integration-test-in-docker
inputSourceBindings:
- name: workspace
sourceKey: guestbook
key: guestbook
passedConstraint:
- deploy-bundle-test
params:
Expand All @@ -74,7 +74,7 @@ spec:
name: deploy-with-kubectl
inputSourceBindings:
- name: workspace
sourceKey: guestbook
key: guestbook
passedConstraint:
- int-test-osx
- int-test-linux
Expand All @@ -89,7 +89,7 @@ spec:
name: guestbook
- name: redis-docker
resourceRef:
name: redis-docker
name: redis-docker
- name: stagingRegistry
resourceRef:
name: stagingRegistry
10 changes: 5 additions & 5 deletions examples/pipelines/kritis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
name: make
inputSourceBindings:
- name: workspace
sourceKey: kritis-app-github
key: kritis-app-github
params:
- name: makeTarget
value: test
Expand All @@ -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
Expand All @@ -33,7 +33,7 @@ spec:
name: deploy-with-helm
inputSourceBindings:
- name: registry
sourceKey: stagingRegistry
key: stagingRegistry
passedConstraint: [build-push]
params:
- name: pathToHelmCharts
Expand All @@ -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
Expand Down
13 changes: 11 additions & 2 deletions pkg/apis/pipeline/v1beta1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipelineparams_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1beta1/task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading