diff --git a/config/300-pipeline.yaml b/config/300-pipeline.yaml index fe5d8574549..d230434b91a 100644 --- a/config/300-pipeline.yaml +++ b/config/300-pipeline.yaml @@ -22,25 +22,6 @@ spec: type: object spec: properties: - resources: - items: - properties: - name: - type: string - resourceRef: - properties: - apiVersion: - type: string - name: - type: string - required: - - name - type: object - required: - - name - - resourceRef - type: object - type: array tasks: items: properties: @@ -63,6 +44,15 @@ spec: type: string name: type: string + resourceRef: + properties: + apiVersion: + type: string + name: + type: string + required: + - name + type: object passedConstraints: items: type: string @@ -81,6 +71,15 @@ spec: type: string name: type: string + resourceRef: + properties: + apiVersion: + type: string + name: + type: string + required: + - name + type: object passedConstraints: items: type: string @@ -118,7 +117,6 @@ spec: type: array required: - tasks - - resources type: object status: type: object diff --git a/config/300-resource.yaml b/config/300-resource.yaml index 6b13e1b7ed0..9455b94f300 100644 --- a/config/300-resource.yaml +++ b/config/300-resource.yaml @@ -22,33 +22,25 @@ spec: type: object spec: properties: - resources: + name: + type: string + params: items: properties: name: type: string - params: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - type: + value: type: string required: - name - - type - - params + - value type: object type: array + type: + type: string required: - - resources + - type + - params type: object status: type: object diff --git a/config/300-task.yaml b/config/300-task.yaml index 6383066ddc2..c21ba2bf0b6 100644 --- a/config/300-task.yaml +++ b/config/300-task.yaml @@ -86,18 +86,11 @@ spec: properties: name: type: string - resourceRef: - properties: - apiVersion: - type: string - name: - type: string - required: - - name - type: object + type: + type: string required: - name - - resourceRef + - type type: object type: array type: object @@ -108,18 +101,8 @@ spec: properties: name: type: string - resourceRef: - properties: - apiVersion: - type: string - name: - type: string - required: - - name - type: object required: - name - - resourceRef type: object type: array results: diff --git a/examples/build_task.yaml b/examples/build_task.yaml index 8bf9549d357..c66b270912c 100644 --- a/examples/build_task.yaml +++ b/examples/build_task.yaml @@ -1,4 +1,4 @@ -apiVersion: pipeline.knative.dev/v1beta1 +apiVersion: pipeline.knative.dev/v1alpha1 kind: Task metadata: name: build-push @@ -6,17 +6,15 @@ metadata: spec: inputs: resources: - - resourceRef: - name: resource-name - name: workspace + - name: workspace + type: git params: - name: pathToDockerFile value: string outputs: resources: - - resourceRef: - name: registry - name: builtImage + - name: builtImage + type: image buildSpec: template: name: kaniko diff --git a/examples/deploy_tasks.yaml b/examples/deploy_tasks.yaml index 3e7e178a2f1..fe55a3cb947 100644 --- a/examples/deploy_tasks.yaml +++ b/examples/deploy_tasks.yaml @@ -6,9 +6,8 @@ metadata: spec: inputs: resources: - - resourceRef: - name: resource-name - name: workspace + - name: workspace + type: git params: - name: pathToHelmCharts value: string @@ -33,9 +32,8 @@ metadata: spec: inputs: resources: - - resourceRef: - name: resource-name - name: workspace + - name: workspace + type: git params: - name: kubectlArgs value: string diff --git a/examples/pipelines/guestbook-resources.yaml b/examples/pipelines/guestbook-resources.yaml index 7dc31898ec8..1673adb81bb 100644 --- a/examples/pipelines/guestbook-resources.yaml +++ b/examples/pipelines/guestbook-resources.yaml @@ -1,30 +1,51 @@ apiVersion: pipeline.knative.dev/v1alpha1 kind: Resource metadata: - name: guestbook-resources-sample + name: guestbook-resources-git namespace: default spec: - resources: - - name: guestbook - type: git - params: + type: git + params: + - name: url + value: github.com/kubernetes/examples + - name: revision + value: HEAD + - name: serviceAccount + value: githubServiceAccount +--- +apiVersion: pipeline.knative.dev/v1alpha1 +kind: Resource +metadata: + name: guestbook-resources-redis-docker + namespace: default +spec: + type: git + params: - name: url - value: github.com/kubernetes/examples - - name: revision - value: HEAD + value: github.com/GoogleCloudPlatform/redis-docker/ - name: serviceAccount value: githubServiceAccount - - name: redis-docker - type: git - params: - - name: url - value: github.com/GoogleCloudPlatform/redis-docker/blob/master/4/debian9/4.0/Dockerfile - - name: serviceAccount - value: githubServiceAccount - - name: revision - value: HEAD - - name: stagingRegistry - type: image - params: - - name: url - value: gcr.io/demo-staging \ No newline at end of file + - name: revision + value: HEAD +--- +apiVersion: pipeline.knative.dev/v1alpha1 +kind: Resource +metadata: + name: guestbookstagingimage + namespace: default +spec: + type: image + params: + - name: url + value: gcr.io/demo-staging +--- +apiVersion: pipeline.knative.dev/v1alpha1 +kind: Resource +metadata: + name: redisstagingimage + namespace: default +spec: + type: image + params: + - name: url + value: gcr.io/redis-demo-staging \ No newline at end of file diff --git a/examples/pipelines/guestbook.yaml b/examples/pipelines/guestbook.yaml index cc41a1651b3..5871d481ac2 100644 --- a/examples/pipelines/guestbook.yaml +++ b/examples/pipelines/guestbook.yaml @@ -9,11 +9,15 @@ spec: taskRef: name: build-push inputSourceBindings: - - name: workspace - key: guestbook + - name: guestbookSource + key: workspace # bind to the name in the task + resourceRef: + name: guestbook-resources-git outputSourceBindings: - - name: registry - key: stagingRegistry + - name: guestbookImage + key: builtImage # bind to the name in the task + resourceRef: + name: guestbookstagingimage params: - name: pathToDockerfile value: guestbook-go/Dockerfile @@ -21,11 +25,15 @@ spec: taskRef: name: build-push inputSourceBindings: - - name: workspace - key: redis-docker # TODO Add Commit SHA + - name: redis-ocker + key: workspace + resourceRef: + name: guestbook-resources-redis-docker outputSourceBindings: - - name: registry - key: stagingRegistry + - name: redisImage + key: builtImage + resourceRef: + name: redisstagingimage params: - name: pathToDockerfile value: 4/debian9/4.0/Dockerfile @@ -33,26 +41,33 @@ spec: taskRef: name: deploy-with-kubectl inputSourceBindings: - - name: workspace - key: guestbook + - name: guestbookSource + key: workspace + resourceRef: + name: guestbook-resources-git passedConstraint: - build-guestbook - build-redis - name: workspace key: redis-docker + resourceRef: + name: guestbook-resources-redis-docker passedConstraint: - build-push params: - name: pathToFiles value: guestbook/all-in-one/guestbook-all-in-one.yaml clusterBindings: - - clusterName: test + - inputName: test + key: test - name: int-test-osx # 3.a Run Integration tests for osx taskRef: name: integrationTestInDocker inputSourceBindings: - - name: workspace - key: guestbook + - name: guestbookSource + key: workspace + resourceRef: + name: guestbook-resources-git passedConstraint: - deploy-bundle-test params: @@ -62,8 +77,10 @@ spec: taskRef: name: integration-test-in-docker inputSourceBindings: - - name: workspace - key: guestbook + - name: guestbookSource + key: workspace + resourceRef: + name: guestbook-resources-git passedConstraint: - deploy-bundle-test params: @@ -73,8 +90,10 @@ spec: taskRef: name: deploy-with-kubectl inputSourceBindings: - - name: workspace - key: guestbook + - name: guestbookSource + key: workspace + resourceRef: + name: guestbook-resources-git passedConstraint: - int-test-osx - int-test-linux @@ -82,14 +101,5 @@ spec: - name: pathToFiles value: guestbook/all-in-one/guestbook-all-in-one.yaml clusterBindings: - - clusterName: staging - resources: - - name: guestbook - resourceRef: - name: guestbook - - name: redis-docker - resourceRef: - name: redis-docker - - name: stagingRegistry - resourceRef: - name: stagingRegistry \ No newline at end of file + - inputName: staging + key: staging \ No newline at end of file diff --git a/examples/pipelines/kritis-resources.yaml b/examples/pipelines/kritis-resources.yaml index 58dcbddb3c3..727bd6f12a9 100644 --- a/examples/pipelines/kritis-resources.yaml +++ b/examples/pipelines/kritis-resources.yaml @@ -1,26 +1,36 @@ apiVersion: pipeline.knative.dev/v1alpha1 kind: Resource metadata: - name: kritis-resources-sample + name: kritis-resources-git namespace: default spec: - resources: - - name: kritis-app-github-resource - type: git - params: - - name: url - value: https://github.com/grafeas/kritis - - name: revision - value: master - - name: kritis-test-github-resource - type: git - params: - - name: revision - value: master - - name: url - value: https://github.com/grafeas/kritis-test - - name: stagingRegistry-resource - type: image - params: - - name: url - value: gcr.io/staging-image \ No newline at end of file + type: git + params: + - name: url + value: https://github.com/grafeas/kritis + - name: revision + value: master +--- +apiVersion: pipeline.knative.dev/v1alpha1 +kind: Resource +metadata: + name: kritis-resources-test-git + namespace: default +spec: + type: git + params: + - name: revision + value: master + - name: url + value: https://github.com/grafeas/kritis-test +--- +apiVersion: pipeline.knative.dev/v1alpha1 +kind: Resource +metadata: + name: kritis-resources-image + namespace: default +spec: + type: image + params: + - name: url + value: gcr.io/staging-image \ No newline at end of file diff --git a/examples/pipelines/kritis.yaml b/examples/pipelines/kritis.yaml index 6b9212c587f..453c0f88424 100644 --- a/examples/pipelines/kritis.yaml +++ b/examples/pipelines/kritis.yaml @@ -9,8 +9,10 @@ spec: taskRef: name: make inputSourceBindings: - - name: workspace - key: kritis-app-github + - name: kritis-app-github + key: workspace # bind to the name in the task + resourceRef: + name: kritis-resources-git params: - name: makeTarget value: test @@ -18,13 +20,17 @@ spec: taskRef: name: build-push inputSourceBindings: - - name: workspace - key: kritis-app-github + - name: kritis-app-github + key: workspace # bind to the name in the task + resourceRef: + name: kritis-resources-git passedConstraint: - make outputSourceBindings: - - name: registry - key: stagingRegistry + - name: kritisImage + key: builtImage # bind to the name in the task + resourceRef: + name: kritis-resources-image params: - name: pathToDockerfile value: deploy/Dockerfile @@ -32,31 +38,26 @@ spec: taskRef: name: deploy-with-helm inputSourceBindings: - - name: registry - key: stagingRegistry + - name: guestbookImage + key: workspace + resourceRef: + name: kritis-resources-image passedConstraint: [build-push] params: - name: pathToHelmCharts value: kritis-charts clusterBindings: - - clusterName: test + - inputName: test + key: test - name: integration-test # 4. Run Integration Tests in test cluster taskRef: name: integration-test-in-docker inputSourceBindings: - - name: workspace - key: kritis-test-github + - name: kritis-test-github + key: workspace + resourceRef: + name: kritis-resources-test-git passedConstraint: [deploy-with-helm] params: - name: testArgs - value: "-e REMOTE_INTEGRATION=true" - resources: - - name: kritis-app-github - resourceRef: - name: kritis-app-github-resource - - name: kritis-test-github - resourceRef: - name: kritis-test-github-resource - - name: stagingRegistry - resourceRef: - name: stagingRegistry-resource + value: "-e REMOTE_INTEGRATION=true" diff --git a/examples/test_tasks.yaml b/examples/test_tasks.yaml index b3922ac3e5f..e8cc886ed4a 100644 --- a/examples/test_tasks.yaml +++ b/examples/test_tasks.yaml @@ -6,9 +6,8 @@ metadata: spec: inputs: resources: - - resourceRef: - name: resource-name - name: workspace + - name: workspace + type: git params: - name: makeTarget value: string @@ -32,9 +31,8 @@ metadata: spec: inputs: resources: - - resourceRef: - name: resource-name - name: workspace + - name: workspace + type: git params: - name: testImage value: string diff --git a/pkg/apis/pipeline/v1alpha1/git_source.go b/pkg/apis/pipeline/v1alpha1/git_resource.go similarity index 55% rename from pkg/apis/pipeline/v1alpha1/git_source.go rename to pkg/apis/pipeline/v1alpha1/git_resource.go index d6f98c0df4e..b0ff88047aa 100644 --- a/pkg/apis/pipeline/v1alpha1/git_source.go +++ b/pkg/apis/pipeline/v1alpha1/git_resource.go @@ -19,9 +19,9 @@ package v1alpha1 // GitResource is an endpoint from which to get data which is required // by a Build/Task for context (e.g. a repo from which to build an image). type GitResource struct { - Name string `json:"name"` - Type string `json:"type"` - URL string `json:"url"` + Name string `json:"name"` + Type PipelineResourceType `json:"type"` + URL string `json:"url"` // Git revision (branch, tag, commit SHA or ref) to clone. See // https://git-scm.com/docs/gitrevisions#_specifying_revisions for more // information. @@ -30,16 +30,27 @@ type GitResource struct { ServiceAccount string `json:"serviceAccount,omitempty"` } -func (s GitResource) getName() string { +// GetName returns the name of the resource +func (s GitResource) GetName() string { return s.Name } -func (s GitResource) getType() StandardResourceType { - return StandardResourceTypeGit +// GetType returns the type of the resource, in this case "Git" +func (s GitResource) GetType() PipelineResourceType { + return PipelineResourceTypeGit } -func (s GitResource) getVersion() string { +// GetVersion returns the revision of the resource, See +// https://git-scm.com/docs/gitrevisions#_specifying_revisions for +// more details what the revison in github is +func (s GitResource) GetVersion() string { return s.Revision } -func (s GitResource) getParams() []Param { return []Param{} } +// GetServiceAccountName returns the service account to be used with this resource +func (s *GitResource) GetServiceAccountName() string { + return s.ServiceAccount +} + +// GetParams returns the resoruce params +func (s GitResource) GetParams() []Param { return []Param{} } diff --git a/pkg/apis/pipeline/v1alpha1/image_resource.go b/pkg/apis/pipeline/v1alpha1/image_resource.go new file mode 100644 index 00000000000..076198a1f26 --- /dev/null +++ b/pkg/apis/pipeline/v1alpha1/image_resource.go @@ -0,0 +1,50 @@ +/* +Copyright 2018 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +// ImageResource defines an endpoint where artifacts can be stored, such as images. +type ImageResource struct { + Name string `json:"name"` + Type PipelineResourceType `json:"type"` + URL string `json:"url"` + Digest string `json:"digest"` + // +optional + ServiceAccount string `json:"serviceAccount,omitempty"` +} + +// GetName returns the name of the resource +func (s ImageResource) GetName() string { + return s.Name +} + +// GetType returns the type of the resource, in this case "image" +func (s ImageResource) GetType() PipelineResourceType { + return PipelineResourceTypeImage +} + +// GetVersion returns the version of the resource +func (s ImageResource) GetVersion() string { + return s.Digest +} + +// GetServiceAccountName returns the service account to be used with this resource +func (s *ImageResource) GetServiceAccountName() string { + return s.ServiceAccount +} + +// GetParams returns the resoruce params +func (s ImageResource) GetParams() []Param { return []Param{} } diff --git a/pkg/apis/pipeline/v1alpha1/image_source.go b/pkg/apis/pipeline/v1alpha1/image_source.go deleted file mode 100644 index 160b2a32d76..00000000000 --- a/pkg/apis/pipeline/v1alpha1/image_source.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2018 The Knative Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -// ImageResource defines an endpoint where artifacts can be stored, such as images. -type ImageResource struct { - Name string `json:"name"` - // TODO: maybe an enum, with values like 'registry', GCS bucket - Type string `json:"type"` - URL string `json:"url"` - Digest string `json:"digest"` -} - -func (s ImageResource) getName() string { - return s.Name -} - -func (s ImageResource) getType() StandardResourceType { - return StandardResourceTypeImage -} - -func (s ImageResource) getVersion() string { - return s.Digest -} - -func (s ImageResource) getParams() []Param { return []Param{} } diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_types.go b/pkg/apis/pipeline/v1alpha1/pipeline_types.go index 1433a771aa4..a7785d46ac7 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_types.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_types.go @@ -22,8 +22,7 @@ import ( // PipelineSpec defines the desired state of PipeLine. type PipelineSpec struct { - Tasks []PipelineTask `json:"tasks"` - Sources []PipelineResource `json:"resources"` + Tasks []PipelineTask `json:"tasks"` } // PipelineStatus defines the observed state of Pipeline @@ -84,10 +83,12 @@ type ClusterBinding struct { // 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 is the string the Task will use to identify this resource in its inputs. Name string `json:"name"` // Key is the string that the PipelineParams will use to identify this source. Key string `json:"key"` + // The Resource this binding is referring to + ResourceRef PipelineResourceRef `json:"resourceRef"` // TODO: validate the passedConstraints values match previous Task names // PassedConstraints is the list of Task names that the resource has to pass through. // +optional @@ -104,8 +105,8 @@ type TaskRef struct { APIVersion string `json:"apiVersion,omitempty"` } -// StandardResourceRef can be used to refer to a specific instance of a Resource -type StandardResourceRef struct { +// PipelineResourceRef can be used to refer to a specific instance of a Resource +type PipelineResourceRef struct { // Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names Name string `json:"name"` // API version of the referent @@ -113,12 +114,6 @@ type StandardResourceRef struct { APIVersion string `json:"apiVersion,omitempty"` } -// PipelineResource defines set of resources required by all Tasks in the pipeline. -type PipelineResource struct { - Name string `json:"name"` - ResourceRef StandardResourceRef `json:"resourceRef"` -} - // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // PipelineList contains a list of Pipeline diff --git a/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go b/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go index fe9fa4f36ae..96fd4a325d8 100644 --- a/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go +++ b/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go @@ -70,7 +70,7 @@ type PipelineRunStatus struct { TaskRuns []PipelineTaskRun `json:"taskRuns,omitempty"` // If there is no version, that means use latest // +optional - ResourceVersion []StandardResourceVersion `json:"resourceVersion,omitempty"` + ResourceVersion []PipelineResourceVersion `json:"resourceVersion,omitempty"` Conditions []PipelineRunCondition `json:"conditions"` } diff --git a/pkg/apis/pipeline/v1alpha1/register.go b/pkg/apis/pipeline/v1alpha1/register.go index 7a1d387af4d..27d02b721f1 100644 --- a/pkg/apis/pipeline/v1alpha1/register.go +++ b/pkg/apis/pipeline/v1alpha1/register.go @@ -56,8 +56,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &PipelineRunList{}, &PipelineParams{}, &PipelineParamsList{}, - &StandardResource{}, - &StandardResourceList{}, + &PipelineResource{}, + &PipelineResourceList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/apis/pipeline/v1alpha1/resource_types.go b/pkg/apis/pipeline/v1alpha1/resource_types.go new file mode 100644 index 00000000000..e049acc0065 --- /dev/null +++ b/pkg/apis/pipeline/v1alpha1/resource_types.go @@ -0,0 +1,92 @@ +/* +Copyright 2018 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// PipelineResourceType represents the type of endpoint the pipelineResource is, so that the +// controller will know this pipelineResource should be fetched and optionally what +// additional metatdata should be provided for it. +type PipelineResourceType string + +const ( + // PipelineResourceTypeGit indicates that this source is a GitHub repo. + PipelineResourceTypeGit PipelineResourceType = "git" + + // PipelineResourceTypeGCS indicates that this source is a GCS bucket. + PipelineResourceTypeGCS PipelineResourceType = "gcs" + + // PipelineResourceTypeImage indicates that this source is a docker Image. + PipelineResourceTypeImage PipelineResourceType = "image" +) + +// PipelineResourceInterface interface to be implemented by different PipelineResource types +type PipelineResourceInterface interface { + GetName() string + GetType() PipelineResourceType + GetParams() []Param + GetVersion() string + GetServiceAccountName() string +} + +// PipelineResourceStatus should implment status for PipelineResource +type PipelineResourceStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +// PipelineResourceSpec defines an individual resources used in the pipeline. +type PipelineResourceSpec struct { + Type PipelineResourceType `json:"type"` + Params []Param `json:"params"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PipelineResource is the Schema for the pipelineResources API +// +k8s:openapi-gen=true +type PipelineResource struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the PipelineResource from the client + // +optional + Spec PipelineResourceSpec `json:"spec,omitempty"` + // Status communicates the observed state of the PipelineResource from the controller + // +optional + Status PipelineResourceStatus `json:"status,omitempty"` +} + +// PipelineResourceVersion defines the desired state of version of the PipelineResource +type PipelineResourceVersion struct { + ResourceRef PipelineResourceRef `json:"resourceRef"` + Version string `json:"version"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PipelineResourceList contains a list of PipelineResources +type PipelineResourceList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []PipelineResource `json:"items"` +} diff --git a/pkg/apis/pipeline/v1alpha1/standardresource_types.go b/pkg/apis/pipeline/v1alpha1/standardresource_types.go deleted file mode 100644 index 49cf0441541..00000000000 --- a/pkg/apis/pipeline/v1alpha1/standardresource_types.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2018 The Knative Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// StandardResourceType represents the type of endpoint the standardresource is, so that the -// controller will know this standardresource should be fetched and optionally what -// additional metatdata should be provided for it. -type StandardResourceType string - -const ( - // StandardResourceTypeGit indicates that this source is a GitHub repo. - StandardResourceTypeGit StandardResourceType = "git" - - // StandardResourceTypeGCS indicates that this source is a GCS bucket. - StandardResourceTypeGCS StandardResourceType = "gcs" - - // StandardResourceTypeImage indicates that this source is a docker Image. - StandardResourceTypeImage StandardResourceType = "image" -) - -// StandardResourceSuper interface to be implemented by different standardresource types -type StandardResourceSuper interface { - getName() string - getType() StandardResourceType - getParams() []Param - getVersion() string -} - -// StandardResourceStatus should implment status for standardresource -type StandardResourceStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// StandardResourceSpec defines set of standardresources required by all Tasks in the pipeline. -type StandardResourceSpec struct { - StandardResources []StandardResourceItem `json:"standardResources"` -} - -// StandardResourceItem is an individual standardresource object definition -type StandardResourceItem struct { - Name string `json:"name"` - Type StandardResourceType `json:"type"` - Params []Param `json:"params"` -} - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// StandardStandardResource is the Schema for the standardresources API -// +k8s:openapi-gen=true -// TODO(aaron-prindle) StandardResource is used by register.go, changed name arbitrarily -type StandardResource struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Spec holds the desired state of the StandardResource from the client - // +optional - Spec StandardResourceSpec `json:"spec,omitempty"` - // Status communicates the observed state of the StandardResource from the controller - // +optional - Status StandardResourceStatus `json:"status,omitempty"` -} - -// StandardResourceVersion defines the desired state of version of the standardresource -type StandardResourceVersion struct { - StandardResourceRef StandardResourceRef `json:"standardresourceRef"` - Version string `json:"version"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// StandardResourceList contains a list of StandardResources -type StandardResourceList struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - Items []StandardResource `json:"items"` -} diff --git a/pkg/apis/pipeline/v1alpha1/task_types.go b/pkg/apis/pipeline/v1alpha1/task_types.go index 516f1f9153f..0302773c664 100644 --- a/pkg/apis/pipeline/v1alpha1/task_types.go +++ b/pkg/apis/pipeline/v1alpha1/task_types.go @@ -71,8 +71,9 @@ type Inputs struct { // into the container executed by the Build/Task, e.g. a Source with the // name "workspace" would be mounted into "/workspace". type Source struct { - Name string `json:"name"` - ResourceRef StandardResourceRef `json:"resourceRef"` + // name of the source should match the name of the SourceBinding in the pipeline + Name string `json:"name"` + Type PipelineResourceType `json:"type"` } // Param defines arbitrary parameters needed by a task beyond typed inputs diff --git a/pkg/apis/pipeline/v1alpha1/taskrun_types.go b/pkg/apis/pipeline/v1alpha1/taskrun_types.go index 5b781cd8433..0d7792b714f 100644 --- a/pkg/apis/pipeline/v1alpha1/taskrun_types.go +++ b/pkg/apis/pipeline/v1alpha1/taskrun_types.go @@ -36,7 +36,7 @@ type TaskRunSpec struct { // TaskRunInputs holds the input values that this task was invoked with. type TaskRunInputs struct { - Resources []StandardResourceVersion `json:"standardResourcesVersion"` + Resources []PipelineResourceVersion `json:"resourcesVersion"` // +optional Params []Param `json:"params,omitempty"` } diff --git a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go index 5f148473ce5..e60dac21d58 100644 --- a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go @@ -381,7 +381,10 @@ func (in *PipelineRef) DeepCopy() *PipelineRef { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PipelineResource) DeepCopyInto(out *PipelineResource) { *out = *in - out.ResourceRef = in.ResourceRef + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status return } @@ -395,6 +398,117 @@ func (in *PipelineResource) DeepCopy() *PipelineResource { return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PipelineResource) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineResourceList) DeepCopyInto(out *PipelineResourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PipelineResource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineResourceList. +func (in *PipelineResourceList) DeepCopy() *PipelineResourceList { + if in == nil { + return nil + } + out := new(PipelineResourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PipelineResourceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineResourceRef) DeepCopyInto(out *PipelineResourceRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineResourceRef. +func (in *PipelineResourceRef) DeepCopy() *PipelineResourceRef { + if in == nil { + return nil + } + out := new(PipelineResourceRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineResourceSpec) DeepCopyInto(out *PipelineResourceSpec) { + *out = *in + if in.Params != nil { + in, out := &in.Params, &out.Params + *out = make([]Param, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineResourceSpec. +func (in *PipelineResourceSpec) DeepCopy() *PipelineResourceSpec { + if in == nil { + return nil + } + out := new(PipelineResourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineResourceStatus) DeepCopyInto(out *PipelineResourceStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineResourceStatus. +func (in *PipelineResourceStatus) DeepCopy() *PipelineResourceStatus { + if in == nil { + return nil + } + out := new(PipelineResourceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineResourceVersion) DeepCopyInto(out *PipelineResourceVersion) { + *out = *in + out.ResourceRef = in.ResourceRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineResourceVersion. +func (in *PipelineResourceVersion) DeepCopy() *PipelineResourceVersion { + if in == nil { + return nil + } + out := new(PipelineResourceVersion) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PipelineRun) DeepCopyInto(out *PipelineRun) { *out = *in @@ -502,7 +616,7 @@ func (in *PipelineRunStatus) DeepCopyInto(out *PipelineRunStatus) { } if in.ResourceVersion != nil { in, out := &in.ResourceVersion, &out.ResourceVersion - *out = make([]StandardResourceVersion, len(*in)) + *out = make([]PipelineResourceVersion, len(*in)) copy(*out, *in) } if in.Conditions != nil { @@ -535,11 +649,6 @@ func (in *PipelineSpec) DeepCopyInto(out *PipelineSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.Sources != nil { - in, out := &in.Sources, &out.Sources - *out = make([]PipelineResource, len(*in)) - copy(*out, *in) - } return } @@ -699,7 +808,6 @@ func (in *Results) DeepCopy() *Results { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Source) DeepCopyInto(out *Source) { *out = *in - out.ResourceRef = in.ResourceRef return } @@ -716,6 +824,7 @@ func (in *Source) DeepCopy() *Source { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SourceBinding) DeepCopyInto(out *SourceBinding) { *out = *in + out.ResourceRef = in.ResourceRef if in.PassedConstraints != nil { in, out := &in.PassedConstraints, &out.PassedConstraints *out = make([]string, len(*in)) @@ -734,160 +843,6 @@ func (in *SourceBinding) DeepCopy() *SourceBinding { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StandardResource) DeepCopyInto(out *StandardResource) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StandardResource. -func (in *StandardResource) DeepCopy() *StandardResource { - if in == nil { - return nil - } - out := new(StandardResource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *StandardResource) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StandardResourceItem) DeepCopyInto(out *StandardResourceItem) { - *out = *in - if in.Params != nil { - in, out := &in.Params, &out.Params - *out = make([]Param, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StandardResourceItem. -func (in *StandardResourceItem) DeepCopy() *StandardResourceItem { - if in == nil { - return nil - } - out := new(StandardResourceItem) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StandardResourceList) DeepCopyInto(out *StandardResourceList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]StandardResource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StandardResourceList. -func (in *StandardResourceList) DeepCopy() *StandardResourceList { - if in == nil { - return nil - } - out := new(StandardResourceList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *StandardResourceList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StandardResourceRef) DeepCopyInto(out *StandardResourceRef) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StandardResourceRef. -func (in *StandardResourceRef) DeepCopy() *StandardResourceRef { - if in == nil { - return nil - } - out := new(StandardResourceRef) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StandardResourceSpec) DeepCopyInto(out *StandardResourceSpec) { - *out = *in - if in.StandardResources != nil { - in, out := &in.StandardResources, &out.StandardResources - *out = make([]StandardResourceItem, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StandardResourceSpec. -func (in *StandardResourceSpec) DeepCopy() *StandardResourceSpec { - if in == nil { - return nil - } - out := new(StandardResourceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StandardResourceStatus) DeepCopyInto(out *StandardResourceStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StandardResourceStatus. -func (in *StandardResourceStatus) DeepCopy() *StandardResourceStatus { - if in == nil { - return nil - } - out := new(StandardResourceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StandardResourceVersion) DeepCopyInto(out *StandardResourceVersion) { - *out = *in - out.StandardResourceRef = in.StandardResourceRef - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StandardResourceVersion. -func (in *StandardResourceVersion) DeepCopy() *StandardResourceVersion { - if in == nil { - return nil - } - out := new(StandardResourceVersion) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StepRun) DeepCopyInto(out *StepRun) { *out = *in @@ -1031,7 +986,7 @@ func (in *TaskRunInputs) DeepCopyInto(out *TaskRunInputs) { *out = *in if in.Resources != nil { in, out := &in.Resources, &out.Resources - *out = make([]StandardResourceVersion, len(*in)) + *out = make([]PipelineResourceVersion, len(*in)) copy(*out, *in) } if in.Params != nil { diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go index 86065d50292..c216a1e9af6 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go @@ -33,12 +33,12 @@ func (c *FakePipelineV1alpha1) PipelineParamses(namespace string) v1alpha1.Pipel return &FakePipelineParamses{c, namespace} } -func (c *FakePipelineV1alpha1) PipelineRuns(namespace string) v1alpha1.PipelineRunInterface { - return &FakePipelineRuns{c, namespace} +func (c *FakePipelineV1alpha1) PipelineResources(namespace string) v1alpha1.PipelineResourceInterface { + return &FakePipelineResources{c, namespace} } -func (c *FakePipelineV1alpha1) StandardResources(namespace string) v1alpha1.StandardResourceInterface { - return &FakeStandardResources{c, namespace} +func (c *FakePipelineV1alpha1) PipelineRuns(namespace string) v1alpha1.PipelineRunInterface { + return &FakePipelineRuns{c, namespace} } func (c *FakePipelineV1alpha1) Tasks(namespace string) v1alpha1.TaskInterface { diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipelineresource.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipelineresource.go new file mode 100644 index 00000000000..951a5227d53 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipelineresource.go @@ -0,0 +1,137 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package fake + +import ( + v1alpha1 "github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakePipelineResources implements PipelineResourceInterface +type FakePipelineResources struct { + Fake *FakePipelineV1alpha1 + ns string +} + +var pipelineresourcesResource = schema.GroupVersionResource{Group: "pipeline.knative.dev", Version: "v1alpha1", Resource: "pipelineresources"} + +var pipelineresourcesKind = schema.GroupVersionKind{Group: "pipeline.knative.dev", Version: "v1alpha1", Kind: "PipelineResource"} + +// Get takes name of the pipelineResource, and returns the corresponding pipelineResource object, and an error if there is any. +func (c *FakePipelineResources) Get(name string, options v1.GetOptions) (result *v1alpha1.PipelineResource, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(pipelineresourcesResource, c.ns, name), &v1alpha1.PipelineResource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PipelineResource), err +} + +// List takes label and field selectors, and returns the list of PipelineResources that match those selectors. +func (c *FakePipelineResources) List(opts v1.ListOptions) (result *v1alpha1.PipelineResourceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(pipelineresourcesResource, pipelineresourcesKind, c.ns, opts), &v1alpha1.PipelineResourceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PipelineResourceList{ListMeta: obj.(*v1alpha1.PipelineResourceList).ListMeta} + for _, item := range obj.(*v1alpha1.PipelineResourceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested pipelineResources. +func (c *FakePipelineResources) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(pipelineresourcesResource, c.ns, opts)) + +} + +// Create takes the representation of a pipelineResource and creates it. Returns the server's representation of the pipelineResource, and an error, if there is any. +func (c *FakePipelineResources) Create(pipelineResource *v1alpha1.PipelineResource) (result *v1alpha1.PipelineResource, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(pipelineresourcesResource, c.ns, pipelineResource), &v1alpha1.PipelineResource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PipelineResource), err +} + +// Update takes the representation of a pipelineResource and updates it. Returns the server's representation of the pipelineResource, and an error, if there is any. +func (c *FakePipelineResources) Update(pipelineResource *v1alpha1.PipelineResource) (result *v1alpha1.PipelineResource, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(pipelineresourcesResource, c.ns, pipelineResource), &v1alpha1.PipelineResource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PipelineResource), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakePipelineResources) UpdateStatus(pipelineResource *v1alpha1.PipelineResource) (*v1alpha1.PipelineResource, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(pipelineresourcesResource, "status", c.ns, pipelineResource), &v1alpha1.PipelineResource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PipelineResource), err +} + +// Delete takes name of the pipelineResource and deletes it. Returns an error if one occurs. +func (c *FakePipelineResources) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(pipelineresourcesResource, c.ns, name), &v1alpha1.PipelineResource{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePipelineResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(pipelineresourcesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.PipelineResourceList{}) + return err +} + +// Patch applies the patch and returns the patched pipelineResource. +func (c *FakePipelineResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PipelineResource, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(pipelineresourcesResource, c.ns, name, data, subresources...), &v1alpha1.PipelineResource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PipelineResource), err +} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_standardresource.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_standardresource.go deleted file mode 100644 index db923520e75..00000000000 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_standardresource.go +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright 2018 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package fake - -import ( - v1alpha1 "github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeStandardResources implements StandardResourceInterface -type FakeStandardResources struct { - Fake *FakePipelineV1alpha1 - ns string -} - -var standardresourcesResource = schema.GroupVersionResource{Group: "pipeline.knative.dev", Version: "v1alpha1", Resource: "standardresources"} - -var standardresourcesKind = schema.GroupVersionKind{Group: "pipeline.knative.dev", Version: "v1alpha1", Kind: "StandardResource"} - -// Get takes name of the standardResource, and returns the corresponding standardResource object, and an error if there is any. -func (c *FakeStandardResources) Get(name string, options v1.GetOptions) (result *v1alpha1.StandardResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(standardresourcesResource, c.ns, name), &v1alpha1.StandardResource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.StandardResource), err -} - -// List takes label and field selectors, and returns the list of StandardResources that match those selectors. -func (c *FakeStandardResources) List(opts v1.ListOptions) (result *v1alpha1.StandardResourceList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(standardresourcesResource, standardresourcesKind, c.ns, opts), &v1alpha1.StandardResourceList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.StandardResourceList{ListMeta: obj.(*v1alpha1.StandardResourceList).ListMeta} - for _, item := range obj.(*v1alpha1.StandardResourceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested standardResources. -func (c *FakeStandardResources) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(standardresourcesResource, c.ns, opts)) - -} - -// Create takes the representation of a standardResource and creates it. Returns the server's representation of the standardResource, and an error, if there is any. -func (c *FakeStandardResources) Create(standardResource *v1alpha1.StandardResource) (result *v1alpha1.StandardResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(standardresourcesResource, c.ns, standardResource), &v1alpha1.StandardResource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.StandardResource), err -} - -// Update takes the representation of a standardResource and updates it. Returns the server's representation of the standardResource, and an error, if there is any. -func (c *FakeStandardResources) Update(standardResource *v1alpha1.StandardResource) (result *v1alpha1.StandardResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(standardresourcesResource, c.ns, standardResource), &v1alpha1.StandardResource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.StandardResource), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeStandardResources) UpdateStatus(standardResource *v1alpha1.StandardResource) (*v1alpha1.StandardResource, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(standardresourcesResource, "status", c.ns, standardResource), &v1alpha1.StandardResource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.StandardResource), err -} - -// Delete takes name of the standardResource and deletes it. Returns an error if one occurs. -func (c *FakeStandardResources) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(standardresourcesResource, c.ns, name), &v1alpha1.StandardResource{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeStandardResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(standardresourcesResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v1alpha1.StandardResourceList{}) - return err -} - -// Patch applies the patch and returns the patched standardResource. -func (c *FakeStandardResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.StandardResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(standardresourcesResource, c.ns, name, data, subresources...), &v1alpha1.StandardResource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.StandardResource), err -} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go index a3b78ea2d46..a185d74c84b 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go @@ -19,9 +19,9 @@ type PipelineExpansion interface{} type PipelineParamsExpansion interface{} -type PipelineRunExpansion interface{} +type PipelineResourceExpansion interface{} -type StandardResourceExpansion interface{} +type PipelineRunExpansion interface{} type TaskExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go index c1fdd26bf8a..9d8b8c7451d 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go @@ -26,8 +26,8 @@ type PipelineV1alpha1Interface interface { RESTClient() rest.Interface PipelinesGetter PipelineParamsesGetter + PipelineResourcesGetter PipelineRunsGetter - StandardResourcesGetter TasksGetter TaskRunsGetter } @@ -45,12 +45,12 @@ func (c *PipelineV1alpha1Client) PipelineParamses(namespace string) PipelinePara return newPipelineParamses(c, namespace) } -func (c *PipelineV1alpha1Client) PipelineRuns(namespace string) PipelineRunInterface { - return newPipelineRuns(c, namespace) +func (c *PipelineV1alpha1Client) PipelineResources(namespace string) PipelineResourceInterface { + return newPipelineResources(c, namespace) } -func (c *PipelineV1alpha1Client) StandardResources(namespace string) StandardResourceInterface { - return newStandardResources(c, namespace) +func (c *PipelineV1alpha1Client) PipelineRuns(namespace string) PipelineRunInterface { + return newPipelineRuns(c, namespace) } func (c *PipelineV1alpha1Client) Tasks(namespace string) TaskInterface { diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipelineresource.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipelineresource.go new file mode 100644 index 00000000000..2a5443b63aa --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/pipelineresource.go @@ -0,0 +1,171 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1" + scheme "github.com/knative/build-pipeline/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// PipelineResourcesGetter has a method to return a PipelineResourceInterface. +// A group's client should implement this interface. +type PipelineResourcesGetter interface { + PipelineResources(namespace string) PipelineResourceInterface +} + +// PipelineResourceInterface has methods to work with PipelineResource resources. +type PipelineResourceInterface interface { + Create(*v1alpha1.PipelineResource) (*v1alpha1.PipelineResource, error) + Update(*v1alpha1.PipelineResource) (*v1alpha1.PipelineResource, error) + UpdateStatus(*v1alpha1.PipelineResource) (*v1alpha1.PipelineResource, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.PipelineResource, error) + List(opts v1.ListOptions) (*v1alpha1.PipelineResourceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PipelineResource, err error) + PipelineResourceExpansion +} + +// pipelineResources implements PipelineResourceInterface +type pipelineResources struct { + client rest.Interface + ns string +} + +// newPipelineResources returns a PipelineResources +func newPipelineResources(c *PipelineV1alpha1Client, namespace string) *pipelineResources { + return &pipelineResources{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the pipelineResource, and returns the corresponding pipelineResource object, and an error if there is any. +func (c *pipelineResources) Get(name string, options v1.GetOptions) (result *v1alpha1.PipelineResource, err error) { + result = &v1alpha1.PipelineResource{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pipelineresources"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PipelineResources that match those selectors. +func (c *pipelineResources) List(opts v1.ListOptions) (result *v1alpha1.PipelineResourceList, err error) { + result = &v1alpha1.PipelineResourceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pipelineresources"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested pipelineResources. +func (c *pipelineResources) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("pipelineresources"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a pipelineResource and creates it. Returns the server's representation of the pipelineResource, and an error, if there is any. +func (c *pipelineResources) Create(pipelineResource *v1alpha1.PipelineResource) (result *v1alpha1.PipelineResource, err error) { + result = &v1alpha1.PipelineResource{} + err = c.client.Post(). + Namespace(c.ns). + Resource("pipelineresources"). + Body(pipelineResource). + Do(). + Into(result) + return +} + +// Update takes the representation of a pipelineResource and updates it. Returns the server's representation of the pipelineResource, and an error, if there is any. +func (c *pipelineResources) Update(pipelineResource *v1alpha1.PipelineResource) (result *v1alpha1.PipelineResource, err error) { + result = &v1alpha1.PipelineResource{} + err = c.client.Put(). + Namespace(c.ns). + Resource("pipelineresources"). + Name(pipelineResource.Name). + Body(pipelineResource). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *pipelineResources) UpdateStatus(pipelineResource *v1alpha1.PipelineResource) (result *v1alpha1.PipelineResource, err error) { + result = &v1alpha1.PipelineResource{} + err = c.client.Put(). + Namespace(c.ns). + Resource("pipelineresources"). + Name(pipelineResource.Name). + SubResource("status"). + Body(pipelineResource). + Do(). + Into(result) + return +} + +// Delete takes name of the pipelineResource and deletes it. Returns an error if one occurs. +func (c *pipelineResources) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("pipelineresources"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *pipelineResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("pipelineresources"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched pipelineResource. +func (c *pipelineResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PipelineResource, err error) { + result = &v1alpha1.PipelineResource{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("pipelineresources"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/standardresource.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/standardresource.go deleted file mode 100644 index a6c556cf8b2..00000000000 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/standardresource.go +++ /dev/null @@ -1,171 +0,0 @@ -/* -Copyright 2018 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1alpha1 - -import ( - v1alpha1 "github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1" - scheme "github.com/knative/build-pipeline/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// StandardResourcesGetter has a method to return a StandardResourceInterface. -// A group's client should implement this interface. -type StandardResourcesGetter interface { - StandardResources(namespace string) StandardResourceInterface -} - -// StandardResourceInterface has methods to work with StandardResource resources. -type StandardResourceInterface interface { - Create(*v1alpha1.StandardResource) (*v1alpha1.StandardResource, error) - Update(*v1alpha1.StandardResource) (*v1alpha1.StandardResource, error) - UpdateStatus(*v1alpha1.StandardResource) (*v1alpha1.StandardResource, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.StandardResource, error) - List(opts v1.ListOptions) (*v1alpha1.StandardResourceList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.StandardResource, err error) - StandardResourceExpansion -} - -// standardResources implements StandardResourceInterface -type standardResources struct { - client rest.Interface - ns string -} - -// newStandardResources returns a StandardResources -func newStandardResources(c *PipelineV1alpha1Client, namespace string) *standardResources { - return &standardResources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the standardResource, and returns the corresponding standardResource object, and an error if there is any. -func (c *standardResources) Get(name string, options v1.GetOptions) (result *v1alpha1.StandardResource, err error) { - result = &v1alpha1.StandardResource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("standardresources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of StandardResources that match those selectors. -func (c *standardResources) List(opts v1.ListOptions) (result *v1alpha1.StandardResourceList, err error) { - result = &v1alpha1.StandardResourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("standardresources"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested standardResources. -func (c *standardResources) Watch(opts v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("standardresources"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a standardResource and creates it. Returns the server's representation of the standardResource, and an error, if there is any. -func (c *standardResources) Create(standardResource *v1alpha1.StandardResource) (result *v1alpha1.StandardResource, err error) { - result = &v1alpha1.StandardResource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("standardresources"). - Body(standardResource). - Do(). - Into(result) - return -} - -// Update takes the representation of a standardResource and updates it. Returns the server's representation of the standardResource, and an error, if there is any. -func (c *standardResources) Update(standardResource *v1alpha1.StandardResource) (result *v1alpha1.StandardResource, err error) { - result = &v1alpha1.StandardResource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("standardresources"). - Name(standardResource.Name). - Body(standardResource). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *standardResources) UpdateStatus(standardResource *v1alpha1.StandardResource) (result *v1alpha1.StandardResource, err error) { - result = &v1alpha1.StandardResource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("standardresources"). - Name(standardResource.Name). - SubResource("status"). - Body(standardResource). - Do(). - Into(result) - return -} - -// Delete takes name of the standardResource and deletes it. Returns an error if one occurs. -func (c *standardResources) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("standardresources"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *standardResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("standardresources"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched standardResource. -func (c *standardResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.StandardResource, err error) { - result = &v1alpha1.StandardResource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("standardresources"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index a1148dfb090..7ac4ed18dc0 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -54,10 +54,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Pipeline().V1alpha1().Pipelines().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("pipelineparamses"): return &genericInformer{resource: resource.GroupResource(), informer: f.Pipeline().V1alpha1().PipelineParamses().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("pipelineresources"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Pipeline().V1alpha1().PipelineResources().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("pipelineruns"): return &genericInformer{resource: resource.GroupResource(), informer: f.Pipeline().V1alpha1().PipelineRuns().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("standardresources"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Pipeline().V1alpha1().StandardResources().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("tasks"): return &genericInformer{resource: resource.GroupResource(), informer: f.Pipeline().V1alpha1().Tasks().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("taskruns"): diff --git a/pkg/client/informers/externalversions/pipeline/v1alpha1/interface.go b/pkg/client/informers/externalversions/pipeline/v1alpha1/interface.go index f3df117da05..bd91c7a14d8 100644 --- a/pkg/client/informers/externalversions/pipeline/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/pipeline/v1alpha1/interface.go @@ -25,10 +25,10 @@ type Interface interface { Pipelines() PipelineInformer // PipelineParamses returns a PipelineParamsInformer. PipelineParamses() PipelineParamsInformer + // PipelineResources returns a PipelineResourceInformer. + PipelineResources() PipelineResourceInformer // PipelineRuns returns a PipelineRunInformer. PipelineRuns() PipelineRunInformer - // StandardResources returns a StandardResourceInformer. - StandardResources() StandardResourceInformer // Tasks returns a TaskInformer. Tasks() TaskInformer // TaskRuns returns a TaskRunInformer. @@ -56,16 +56,16 @@ func (v *version) PipelineParamses() PipelineParamsInformer { return &pipelineParamsInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// PipelineResources returns a PipelineResourceInformer. +func (v *version) PipelineResources() PipelineResourceInformer { + return &pipelineResourceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // PipelineRuns returns a PipelineRunInformer. func (v *version) PipelineRuns() PipelineRunInformer { return &pipelineRunInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } -// StandardResources returns a StandardResourceInformer. -func (v *version) StandardResources() StandardResourceInformer { - return &standardResourceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - // Tasks returns a TaskInformer. func (v *version) Tasks() TaskInformer { return &taskInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/pipeline/v1alpha1/standardresource.go b/pkg/client/informers/externalversions/pipeline/v1alpha1/pipelineresource.go similarity index 70% rename from pkg/client/informers/externalversions/pipeline/v1alpha1/standardresource.go rename to pkg/client/informers/externalversions/pipeline/v1alpha1/pipelineresource.go index 5dc7cc7af68..4e19f4c2096 100644 --- a/pkg/client/informers/externalversions/pipeline/v1alpha1/standardresource.go +++ b/pkg/client/informers/externalversions/pipeline/v1alpha1/pipelineresource.go @@ -28,59 +28,59 @@ import ( cache "k8s.io/client-go/tools/cache" ) -// StandardResourceInformer provides access to a shared informer and lister for -// StandardResources. -type StandardResourceInformer interface { +// PipelineResourceInformer provides access to a shared informer and lister for +// PipelineResources. +type PipelineResourceInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.StandardResourceLister + Lister() v1alpha1.PipelineResourceLister } -type standardResourceInformer struct { +type pipelineResourceInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc namespace string } -// NewStandardResourceInformer constructs a new informer for StandardResource type. +// NewPipelineResourceInformer constructs a new informer for PipelineResource type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewStandardResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredStandardResourceInformer(client, namespace, resyncPeriod, indexers, nil) +func NewPipelineResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPipelineResourceInformer(client, namespace, resyncPeriod, indexers, nil) } -// NewFilteredStandardResourceInformer constructs a new informer for StandardResource type. +// NewFilteredPipelineResourceInformer constructs a new informer for PipelineResource type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredStandardResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredPipelineResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.PipelineV1alpha1().StandardResources(namespace).List(options) + return client.PipelineV1alpha1().PipelineResources(namespace).List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.PipelineV1alpha1().StandardResources(namespace).Watch(options) + return client.PipelineV1alpha1().PipelineResources(namespace).Watch(options) }, }, - &pipeline_v1alpha1.StandardResource{}, + &pipeline_v1alpha1.PipelineResource{}, resyncPeriod, indexers, ) } -func (f *standardResourceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredStandardResourceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +func (f *pipelineResourceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPipelineResourceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } -func (f *standardResourceInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&pipeline_v1alpha1.StandardResource{}, f.defaultInformer) +func (f *pipelineResourceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&pipeline_v1alpha1.PipelineResource{}, f.defaultInformer) } -func (f *standardResourceInformer) Lister() v1alpha1.StandardResourceLister { - return v1alpha1.NewStandardResourceLister(f.Informer().GetIndexer()) +func (f *pipelineResourceInformer) Lister() v1alpha1.PipelineResourceLister { + return v1alpha1.NewPipelineResourceLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/listers/pipeline/v1alpha1/expansion_generated.go b/pkg/client/listers/pipeline/v1alpha1/expansion_generated.go index ce6476d6075..3a3b2903d9c 100644 --- a/pkg/client/listers/pipeline/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/pipeline/v1alpha1/expansion_generated.go @@ -31,6 +31,14 @@ type PipelineParamsListerExpansion interface{} // PipelineParamsNamespaceLister. type PipelineParamsNamespaceListerExpansion interface{} +// PipelineResourceListerExpansion allows custom methods to be added to +// PipelineResourceLister. +type PipelineResourceListerExpansion interface{} + +// PipelineResourceNamespaceListerExpansion allows custom methods to be added to +// PipelineResourceNamespaceLister. +type PipelineResourceNamespaceListerExpansion interface{} + // PipelineRunListerExpansion allows custom methods to be added to // PipelineRunLister. type PipelineRunListerExpansion interface{} @@ -39,14 +47,6 @@ type PipelineRunListerExpansion interface{} // PipelineRunNamespaceLister. type PipelineRunNamespaceListerExpansion interface{} -// StandardResourceListerExpansion allows custom methods to be added to -// StandardResourceLister. -type StandardResourceListerExpansion interface{} - -// StandardResourceNamespaceListerExpansion allows custom methods to be added to -// StandardResourceNamespaceLister. -type StandardResourceNamespaceListerExpansion interface{} - // TaskListerExpansion allows custom methods to be added to // TaskLister. type TaskListerExpansion interface{} diff --git a/pkg/client/listers/pipeline/v1alpha1/pipelineresource.go b/pkg/client/listers/pipeline/v1alpha1/pipelineresource.go new file mode 100644 index 00000000000..287898fc1ce --- /dev/null +++ b/pkg/client/listers/pipeline/v1alpha1/pipelineresource.go @@ -0,0 +1,91 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package v1alpha1 + +import ( + v1alpha1 "github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PipelineResourceLister helps list PipelineResources. +type PipelineResourceLister interface { + // List lists all PipelineResources in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.PipelineResource, err error) + // PipelineResources returns an object that can list and get PipelineResources. + PipelineResources(namespace string) PipelineResourceNamespaceLister + PipelineResourceListerExpansion +} + +// pipelineResourceLister implements the PipelineResourceLister interface. +type pipelineResourceLister struct { + indexer cache.Indexer +} + +// NewPipelineResourceLister returns a new PipelineResourceLister. +func NewPipelineResourceLister(indexer cache.Indexer) PipelineResourceLister { + return &pipelineResourceLister{indexer: indexer} +} + +// List lists all PipelineResources in the indexer. +func (s *pipelineResourceLister) List(selector labels.Selector) (ret []*v1alpha1.PipelineResource, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PipelineResource)) + }) + return ret, err +} + +// PipelineResources returns an object that can list and get PipelineResources. +func (s *pipelineResourceLister) PipelineResources(namespace string) PipelineResourceNamespaceLister { + return pipelineResourceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PipelineResourceNamespaceLister helps list and get PipelineResources. +type PipelineResourceNamespaceLister interface { + // List lists all PipelineResources in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.PipelineResource, err error) + // Get retrieves the PipelineResource from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.PipelineResource, error) + PipelineResourceNamespaceListerExpansion +} + +// pipelineResourceNamespaceLister implements the PipelineResourceNamespaceLister +// interface. +type pipelineResourceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PipelineResources in the indexer for a given namespace. +func (s pipelineResourceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PipelineResource, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PipelineResource)) + }) + return ret, err +} + +// Get retrieves the PipelineResource from the indexer for a given namespace and name. +func (s pipelineResourceNamespaceLister) Get(name string) (*v1alpha1.PipelineResource, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("pipelineresource"), name) + } + return obj.(*v1alpha1.PipelineResource), nil +} diff --git a/pkg/client/listers/pipeline/v1alpha1/standardresource.go b/pkg/client/listers/pipeline/v1alpha1/standardresource.go deleted file mode 100644 index a5c2bdc1d17..00000000000 --- a/pkg/client/listers/pipeline/v1alpha1/standardresource.go +++ /dev/null @@ -1,91 +0,0 @@ -/* -Copyright 2018 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1alpha1 - -import ( - v1alpha1 "github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// StandardResourceLister helps list StandardResources. -type StandardResourceLister interface { - // List lists all StandardResources in the indexer. - List(selector labels.Selector) (ret []*v1alpha1.StandardResource, err error) - // StandardResources returns an object that can list and get StandardResources. - StandardResources(namespace string) StandardResourceNamespaceLister - StandardResourceListerExpansion -} - -// standardResourceLister implements the StandardResourceLister interface. -type standardResourceLister struct { - indexer cache.Indexer -} - -// NewStandardResourceLister returns a new StandardResourceLister. -func NewStandardResourceLister(indexer cache.Indexer) StandardResourceLister { - return &standardResourceLister{indexer: indexer} -} - -// List lists all StandardResources in the indexer. -func (s *standardResourceLister) List(selector labels.Selector) (ret []*v1alpha1.StandardResource, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.StandardResource)) - }) - return ret, err -} - -// StandardResources returns an object that can list and get StandardResources. -func (s *standardResourceLister) StandardResources(namespace string) StandardResourceNamespaceLister { - return standardResourceNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// StandardResourceNamespaceLister helps list and get StandardResources. -type StandardResourceNamespaceLister interface { - // List lists all StandardResources in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1alpha1.StandardResource, err error) - // Get retrieves the StandardResource from the indexer for a given namespace and name. - Get(name string) (*v1alpha1.StandardResource, error) - StandardResourceNamespaceListerExpansion -} - -// standardResourceNamespaceLister implements the StandardResourceNamespaceLister -// interface. -type standardResourceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all StandardResources in the indexer for a given namespace. -func (s standardResourceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.StandardResource, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.StandardResource)) - }) - return ret, err -} - -// Get retrieves the StandardResource from the indexer for a given namespace and name. -func (s standardResourceNamespaceLister) Get(name string) (*v1alpha1.StandardResource, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("standardresource"), name) - } - return obj.(*v1alpha1.StandardResource), nil -} diff --git a/samples/pipeline_v1alpha1_pipeline.yaml b/samples/pipeline_v1alpha1_pipeline.yaml index a82c19f1f1d..0a105ce1f72 100644 --- a/samples/pipeline_v1alpha1_pipeline.yaml +++ b/samples/pipeline_v1alpha1_pipeline.yaml @@ -5,48 +5,64 @@ metadata: namespace: default spec: tasks: - - name: 'test' - taskRef: - name: test-wizzbang-task - sourceBindings: - - inputName: 'repoUnderTest' - sourceKey: 'wizzbang' - nextTasks: ['buildPush'] - - name: 'buildPush' - taskRef: - name: build-push-task - sourceBindings: - - inputName: 'workspace' - sourceKey: 'wizzbang' - artifactStoreBindings: - - storeName: 'registry' - storeKey: 'stagingRegistry' - params: - - name: 'pathToDockerfile' - value: 'build/Dockerfile' - - name: 'integrationTest' - taskRef: - name: integration-test-wizzbang-task - sourceBindings: - - inputName: 'repoUnderTest' - sourceKey: 'wizzbang' - paramBindings: - - inputName: testImage - taskName: buildPush - taskOutputName: builtImage - - name: 'deploy' - taskRef: - name: deploy-with-helm - params: - - name: pathToHelmCharts - value: deploy/helm - sourceBindings: - - inputName: 'repoToDeploy' - sourceKey: 'wizzbang' - clusterBindings: - - clusterName: prod - paramBindings: - - inputName: image - taskName: buildPush - taskOutputName: builtImage - prevTasks: ['integrationTest'] + - name: test + taskRef: + name: test-wizzbang-task + inputsourceBindings: + - name: repoUnderTest + key: workspace + resourceRef: + name: wizzbang-git + - name: buildPush + taskRef: + name: build-push-task + inputSourceBindings: + - name: wizzbangSrc + key: workspace + resourceRef: + name: wizzbang-git + passedConstraint: [test-wizzbang-task] + outputSourceBindings: + - name: wizzbangImage + key: builtImage + resourceRef: + name: wizzbang-image + params: + - name: pathToDockerfile + value: build/Dockerfile + - name: integrationTest + taskRef: + name: integration-test-wizzbang-task + inputSourceBindings: + - name: repoUnderTest + key: wizzbang + resourceRef: + name: wizzbang-git + passedConstraint: [test] + outputSourceBindings: + - name: wizzbangImage + key: builtImage + resourceRef: + name: wizzbang-image + passedConstraint: [build-push-task] + - name: deploy + taskRef: + name: deploy-with-helm + params: + - name: pathToHelmCharts + value: deploy/helm + inputSourceBindings: + - name: wizzbangSrc + key: wizzbang + resourceRef: + name: wizzbang-git + passedConstraint: [integration-test-wizzbang-task] + clusterBindings: + - inputName: prod + key: prod + outputSourceBindings: + - name: wizzbangImage + key: builtImage + resourceRef: + name: wizzbang-image + passedConstraint: [build-push-task] \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_pipelineparams.yaml b/samples/pipeline_v1alpha1_pipelineparams.yaml index 27d4e49e6c7..c6c9b4336d6 100644 --- a/samples/pipeline_v1alpha1_pipelineparams.yaml +++ b/samples/pipeline_v1alpha1_pipelineparams.yaml @@ -5,19 +5,6 @@ metadata: namespace: default spec: serviceAccount: 'wizzbangPipelineServiceAccount' - sources: - - name: 'wizzbang' - type: 'github' - url: 'github.com/wizzbangcorp/wizzbang' - branch: 'master' - commit: 'HEAD' - artifactStores: - - name: 'prodRegistry' - type: 'imageRegistry' - url: 'gcr.io/wizzbang' - - name: 'stagingRegistry' - type: 'imageRegistry' - url: 'gcr.io/wizzbang-staging' results: runs: name: 'runsBucket' @@ -37,4 +24,4 @@ spec: clusters: - name: 'prod' type: 'gke' - endpoint: 'https://prod.gke.corp.com' + endpoint: 'https://prod.gke.corp.com' \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_pipelinerun.yaml b/samples/pipeline_v1alpha1_pipelinerun.yaml index fea5a495050..73a6c21abd1 100644 --- a/samples/pipeline_v1alpha1_pipelinerun.yaml +++ b/samples/pipeline_v1alpha1_pipelinerun.yaml @@ -14,16 +14,8 @@ status: taskRuns: - taskRef: name: test-wizzbang-task-run-sd8f8dfasdfasdfas - nextTasks: - - taskRef: - name: build-push-task-run-sd8f8dfasdfasdfas - prevTasks: [] - taskRef: name: build-push-task-run-sd8f8dfasdfasdfas - nextTasks: [] - prevTasks: - - taskRef: - name: test-wizzbang-task-run-sd8f8dfasdfasdfas conditions: - type: Started status: "True" diff --git a/samples/pipeline_v1alpha1_resources.yaml b/samples/pipeline_v1alpha1_resources.yaml new file mode 100644 index 00000000000..6837fc6c562 --- /dev/null +++ b/samples/pipeline_v1alpha1_resources.yaml @@ -0,0 +1,23 @@ +apiVersion: pipeline.knative.dev/v1alpha1 +kind: Resource +metadata: + name: wizzbang-git + namespace: default +spec: + type: git + params: + - name: url + value: github.com/wizzbangcorp/wizzbang + - name: revision + value: HEAD +--- +apiVersion: pipeline.knative.dev/v1alpha1 +kind: Resource +metadata: + name: wizzbang-image + namespace: default +spec: + type: image + params: + - name: url + value: gcr.io/wizzbang-staging \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_task.yaml b/samples/pipeline_v1alpha1_task.yaml index ae060d13481..23d00311882 100644 --- a/samples/pipeline_v1alpha1_task.yaml +++ b/samples/pipeline_v1alpha1_task.yaml @@ -5,16 +5,15 @@ metadata: namespace: default spec: inputs: - sources: - - name: workspace + resources: + - name: workspace + type: git params: - - name: PATH_TO_DOCKERFILE - type: string + - name: PATH_TO_DOCKERFILE + value: string outputs: - artifacts: - - name: builtImage - type: image - storeKey: registry # registy is the name of the ArtifactStore + resources: + - name: builtImage buildSpec: template: name: kaniko diff --git a/samples/pipeline_v1alpha1_taskrun.yaml b/samples/pipeline_v1alpha1_taskrun.yaml index e6226f136e4..80367da56fc 100644 --- a/samples/pipeline_v1alpha1_taskrun.yaml +++ b/samples/pipeline_v1alpha1_taskrun.yaml @@ -10,24 +10,19 @@ spec: triggerRef: type: PipelineRun name: wizzbangPipeline-sd8f8dfasdfasdfas - prevTasks: [""] - nextTasks: ["build-push-sd8f8dfasdfasdfas"] inputs: - sources: - - name: 'wizzbang' - type: 'github' - url: 'github.com/wizzbangcorp/wizzbang' - branch: 'master' - commit: 'HEAD' + resourcesVersion: + - resourceRef: + name: wizzbang + version: HEAD params: - - name: 'image' - type: 'string' - value: 'gcr.io/wizzbang-staging/wizzbang@234324k32j432k32l4k2a' + - name: 'image' + type: 'string' + value: 'gcr.io/wizzbang-staging/wizzbang@234324k32j432k32l4k2a' outputs: artifacts: - - name: builtImage - type: image - storeKey: registry # registy is the name of the ArtifactStore + - name: builtImage + type: image results: runs: name: 'runsBucket' @@ -61,4 +56,4 @@ status: status: "True" lastTransitionTime: "2018-10-04T13:25:39Z" reason: zeroExitCode - message: "All steps completed with an exit code of 0" + message: "All steps completed with an exit code of 0" \ No newline at end of file