From 3d6f1d3e6d5b56adfff13d1c76f0dd92b96931d3 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Mon, 27 Jan 2020 15:30:53 +0100 Subject: [PATCH] =?UTF-8?q?Add=20ClusterTask=20to=20v1alpha2=20?= =?UTF-8?q?=F0=9F=8E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This port ClusterTask spec to v1alpha2, using v1alpha2.TaskSpec too. Signed-off-by: Vincent Demeester --- .../v1alpha2/cluster_task_defaults.go | 29 ++++ .../pipeline/v1alpha2/cluster_task_types.go | 61 +++++++ .../v1alpha2/cluster_task_validation.go | 33 ++++ pkg/apis/pipeline/v1alpha2/register.go | 4 +- .../v1alpha2/zz_generated.deepcopy.go | 60 +++++++ .../typed/pipeline/v1alpha2/clustertask.go | 164 ++++++++++++++++++ .../v1alpha2/fake/fake_clustertask.go | 120 +++++++++++++ .../v1alpha2/fake/fake_pipeline_client.go | 4 + .../pipeline/v1alpha2/generated_expansion.go | 2 + .../pipeline/v1alpha2/pipeline_client.go | 5 + .../informers/externalversions/generic.go | 2 + .../pipeline/v1alpha2/clustertask.go | 88 ++++++++++ .../pipeline/v1alpha2/interface.go | 7 + .../v1alpha2/clustertask/clustertask.go | 52 ++++++ .../v1alpha2/clustertask/fake/fake.go | 40 +++++ .../listers/pipeline/v1alpha2/clustertask.go | 65 +++++++ .../pipeline/v1alpha2/expansion_generated.go | 4 + 17 files changed, 738 insertions(+), 2 deletions(-) create mode 100644 pkg/apis/pipeline/v1alpha2/cluster_task_defaults.go create mode 100644 pkg/apis/pipeline/v1alpha2/cluster_task_types.go create mode 100644 pkg/apis/pipeline/v1alpha2/cluster_task_validation.go create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1alpha2/clustertask.go create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1alpha2/fake/fake_clustertask.go create mode 100644 pkg/client/informers/externalversions/pipeline/v1alpha2/clustertask.go create mode 100644 pkg/client/injection/informers/pipeline/v1alpha2/clustertask/clustertask.go create mode 100644 pkg/client/injection/informers/pipeline/v1alpha2/clustertask/fake/fake.go create mode 100644 pkg/client/listers/pipeline/v1alpha2/clustertask.go diff --git a/pkg/apis/pipeline/v1alpha2/cluster_task_defaults.go b/pkg/apis/pipeline/v1alpha2/cluster_task_defaults.go new file mode 100644 index 00000000000..0b4f7856660 --- /dev/null +++ b/pkg/apis/pipeline/v1alpha2/cluster_task_defaults.go @@ -0,0 +1,29 @@ +/* +Copyright 2020 The Tekton 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 v1alpha2 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +var _ apis.Defaultable = (*ClusterTask)(nil) + +func (t *ClusterTask) SetDefaults(ctx context.Context) { + t.Spec.SetDefaults(ctx) +} diff --git a/pkg/apis/pipeline/v1alpha2/cluster_task_types.go b/pkg/apis/pipeline/v1alpha2/cluster_task_types.go new file mode 100644 index 00000000000..6ca9d93eb78 --- /dev/null +++ b/pkg/apis/pipeline/v1alpha2/cluster_task_types.go @@ -0,0 +1,61 @@ +/* +Copyright 2020 The Tekton 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:noStatus +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterTask is a Task with a cluster scope. ClusterTasks are used to +// represent Tasks that should be publicly addressable from any namespace in the +// cluster. +type ClusterTask struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Task from the client + // +optional + Spec TaskSpec `json:"spec,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterTaskList contains a list of ClusterTask +type ClusterTaskList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []ClusterTask `json:"items"` +} + +func (t *ClusterTask) TaskSpec() TaskSpec { + return t.Spec +} + +func (t *ClusterTask) TaskMetadata() metav1.ObjectMeta { + return t.ObjectMeta +} + +func (t *ClusterTask) Copy() TaskInterface { + return t.DeepCopy() +} diff --git a/pkg/apis/pipeline/v1alpha2/cluster_task_validation.go b/pkg/apis/pipeline/v1alpha2/cluster_task_validation.go new file mode 100644 index 00000000000..db2ce3630d6 --- /dev/null +++ b/pkg/apis/pipeline/v1alpha2/cluster_task_validation.go @@ -0,0 +1,33 @@ +/* +Copyright 2020 The Tekton 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 v1alpha2 + +import ( + "context" + + "github.com/tektoncd/pipeline/pkg/apis/validate" + "knative.dev/pkg/apis" +) + +var _ apis.Validatable = (*ClusterTask)(nil) + +func (t *ClusterTask) Validate(ctx context.Context) *apis.FieldError { + if err := validate.ObjectMetadata(t.GetObjectMeta()); err != nil { + return err.ViaField("metadata") + } + return t.Spec.Validate(ctx) +} diff --git a/pkg/apis/pipeline/v1alpha2/register.go b/pkg/apis/pipeline/v1alpha2/register.go index 317252b5c39..206119cad74 100644 --- a/pkg/apis/pipeline/v1alpha2/register.go +++ b/pkg/apis/pipeline/v1alpha2/register.go @@ -50,13 +50,13 @@ func addKnownTypes(scheme *runtime.Scheme) error { &TaskList{}, &Pipeline{}, &PipelineList{}, + &ClusterTask{}, + &ClusterTaskList{}, &TaskRun{}, &TaskRunList{}, ) // &Condition{}, // &ConditionList{}, - // &ClusterTask{}, - // &ClusterTaskList{}, // &PipelineRun{}, // &PipelineRunList{}, diff --git a/pkg/apis/pipeline/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1alpha2/zz_generated.deepcopy.go index b944a8cd68d..e436a317dd9 100644 --- a/pkg/apis/pipeline/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1alpha2/zz_generated.deepcopy.go @@ -85,6 +85,66 @@ func (in *CloudEventDeliveryState) DeepCopy() *CloudEventDeliveryState { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterTask) DeepCopyInto(out *ClusterTask) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterTask. +func (in *ClusterTask) DeepCopy() *ClusterTask { + if in == nil { + return nil + } + out := new(ClusterTask) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterTask) 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 *ClusterTaskList) DeepCopyInto(out *ClusterTaskList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterTask, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterTaskList. +func (in *ClusterTaskList) DeepCopy() *ClusterTaskList { + if in == nil { + return nil + } + out := new(ClusterTaskList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterTaskList) 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 *InternalTaskModifier) DeepCopyInto(out *InternalTaskModifier) { *out = *in diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/clustertask.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/clustertask.go new file mode 100644 index 00000000000..2dfffff4c89 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/clustertask.go @@ -0,0 +1,164 @@ +/* +Copyright 2019 The Tekton 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "time" + + v1alpha2 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2" + scheme "github.com/tektoncd/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" +) + +// ClusterTasksGetter has a method to return a ClusterTaskInterface. +// A group's client should implement this interface. +type ClusterTasksGetter interface { + ClusterTasks() ClusterTaskInterface +} + +// ClusterTaskInterface has methods to work with ClusterTask resources. +type ClusterTaskInterface interface { + Create(*v1alpha2.ClusterTask) (*v1alpha2.ClusterTask, error) + Update(*v1alpha2.ClusterTask) (*v1alpha2.ClusterTask, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha2.ClusterTask, error) + List(opts v1.ListOptions) (*v1alpha2.ClusterTaskList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ClusterTask, err error) + ClusterTaskExpansion +} + +// clusterTasks implements ClusterTaskInterface +type clusterTasks struct { + client rest.Interface +} + +// newClusterTasks returns a ClusterTasks +func newClusterTasks(c *TektonV1alpha2Client) *clusterTasks { + return &clusterTasks{ + client: c.RESTClient(), + } +} + +// Get takes name of the clusterTask, and returns the corresponding clusterTask object, and an error if there is any. +func (c *clusterTasks) Get(name string, options v1.GetOptions) (result *v1alpha2.ClusterTask, err error) { + result = &v1alpha2.ClusterTask{} + err = c.client.Get(). + Resource("clustertasks"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterTasks that match those selectors. +func (c *clusterTasks) List(opts v1.ListOptions) (result *v1alpha2.ClusterTaskList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.ClusterTaskList{} + err = c.client.Get(). + Resource("clustertasks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterTasks. +func (c *clusterTasks) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("clustertasks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a clusterTask and creates it. Returns the server's representation of the clusterTask, and an error, if there is any. +func (c *clusterTasks) Create(clusterTask *v1alpha2.ClusterTask) (result *v1alpha2.ClusterTask, err error) { + result = &v1alpha2.ClusterTask{} + err = c.client.Post(). + Resource("clustertasks"). + Body(clusterTask). + Do(). + Into(result) + return +} + +// Update takes the representation of a clusterTask and updates it. Returns the server's representation of the clusterTask, and an error, if there is any. +func (c *clusterTasks) Update(clusterTask *v1alpha2.ClusterTask) (result *v1alpha2.ClusterTask, err error) { + result = &v1alpha2.ClusterTask{} + err = c.client.Put(). + Resource("clustertasks"). + Name(clusterTask.Name). + Body(clusterTask). + Do(). + Into(result) + return +} + +// Delete takes name of the clusterTask and deletes it. Returns an error if one occurs. +func (c *clusterTasks) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Resource("clustertasks"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterTasks) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("clustertasks"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched clusterTask. +func (c *clusterTasks) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ClusterTask, err error) { + result = &v1alpha2.ClusterTask{} + err = c.client.Patch(pt). + Resource("clustertasks"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/fake/fake_clustertask.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/fake/fake_clustertask.go new file mode 100644 index 00000000000..0500b54e877 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/fake/fake_clustertask.go @@ -0,0 +1,120 @@ +/* +Copyright 2019 The Tekton 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha2 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2" + 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" +) + +// FakeClusterTasks implements ClusterTaskInterface +type FakeClusterTasks struct { + Fake *FakeTektonV1alpha2 +} + +var clustertasksResource = schema.GroupVersionResource{Group: "tekton.dev", Version: "v1alpha2", Resource: "clustertasks"} + +var clustertasksKind = schema.GroupVersionKind{Group: "tekton.dev", Version: "v1alpha2", Kind: "ClusterTask"} + +// Get takes name of the clusterTask, and returns the corresponding clusterTask object, and an error if there is any. +func (c *FakeClusterTasks) Get(name string, options v1.GetOptions) (result *v1alpha2.ClusterTask, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(clustertasksResource, name), &v1alpha2.ClusterTask{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ClusterTask), err +} + +// List takes label and field selectors, and returns the list of ClusterTasks that match those selectors. +func (c *FakeClusterTasks) List(opts v1.ListOptions) (result *v1alpha2.ClusterTaskList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(clustertasksResource, clustertasksKind, opts), &v1alpha2.ClusterTaskList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.ClusterTaskList{ListMeta: obj.(*v1alpha2.ClusterTaskList).ListMeta} + for _, item := range obj.(*v1alpha2.ClusterTaskList).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 clusterTasks. +func (c *FakeClusterTasks) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(clustertasksResource, opts)) +} + +// Create takes the representation of a clusterTask and creates it. Returns the server's representation of the clusterTask, and an error, if there is any. +func (c *FakeClusterTasks) Create(clusterTask *v1alpha2.ClusterTask) (result *v1alpha2.ClusterTask, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(clustertasksResource, clusterTask), &v1alpha2.ClusterTask{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ClusterTask), err +} + +// Update takes the representation of a clusterTask and updates it. Returns the server's representation of the clusterTask, and an error, if there is any. +func (c *FakeClusterTasks) Update(clusterTask *v1alpha2.ClusterTask) (result *v1alpha2.ClusterTask, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(clustertasksResource, clusterTask), &v1alpha2.ClusterTask{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ClusterTask), err +} + +// Delete takes name of the clusterTask and deletes it. Returns an error if one occurs. +func (c *FakeClusterTasks) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(clustertasksResource, name), &v1alpha2.ClusterTask{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterTasks) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(clustertasksResource, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha2.ClusterTaskList{}) + return err +} + +// Patch applies the patch and returns the patched clusterTask. +func (c *FakeClusterTasks) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ClusterTask, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(clustertasksResource, name, pt, data, subresources...), &v1alpha2.ClusterTask{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ClusterTask), err +} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/fake/fake_pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/fake/fake_pipeline_client.go index 1a8b2481d89..19336757e5c 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/fake/fake_pipeline_client.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/fake/fake_pipeline_client.go @@ -28,6 +28,10 @@ type FakeTektonV1alpha2 struct { *testing.Fake } +func (c *FakeTektonV1alpha2) ClusterTasks() v1alpha2.ClusterTaskInterface { + return &FakeClusterTasks{c} +} + func (c *FakeTektonV1alpha2) Pipelines(namespace string) v1alpha2.PipelineInterface { return &FakePipelines{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/generated_expansion.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/generated_expansion.go index 464bba8d968..2ea6f84e7c9 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/generated_expansion.go @@ -18,6 +18,8 @@ limitations under the License. package v1alpha2 +type ClusterTaskExpansion interface{} + type PipelineExpansion interface{} type TaskExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/pipeline_client.go index 4312f3c94df..2e5f5e22bb9 100644 --- a/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/pipeline_client.go +++ b/pkg/client/clientset/versioned/typed/pipeline/v1alpha2/pipeline_client.go @@ -27,6 +27,7 @@ import ( type TektonV1alpha2Interface interface { RESTClient() rest.Interface + ClusterTasksGetter PipelinesGetter TasksGetter TaskRunsGetter @@ -37,6 +38,10 @@ type TektonV1alpha2Client struct { restClient rest.Interface } +func (c *TektonV1alpha2Client) ClusterTasks() ClusterTaskInterface { + return newClusterTasks(c) +} + func (c *TektonV1alpha2Client) Pipelines(namespace string) PipelineInterface { return newPipelines(c, namespace) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index ddc8554c6ab..f91ff2b5df2 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -68,6 +68,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1alpha1().TaskRuns().Informer()}, nil // Group=tekton.dev, Version=v1alpha2 + case v1alpha2.SchemeGroupVersion.WithResource("clustertasks"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1alpha2().ClusterTasks().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("pipelines"): return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1alpha2().Pipelines().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("tasks"): diff --git a/pkg/client/informers/externalversions/pipeline/v1alpha2/clustertask.go b/pkg/client/informers/externalversions/pipeline/v1alpha2/clustertask.go new file mode 100644 index 00000000000..5fed5cc58fc --- /dev/null +++ b/pkg/client/informers/externalversions/pipeline/v1alpha2/clustertask.go @@ -0,0 +1,88 @@ +/* +Copyright 2019 The Tekton 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + time "time" + + pipelinev1alpha2 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2" + versioned "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" + internalinterfaces "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/internalinterfaces" + v1alpha2 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterTaskInformer provides access to a shared informer and lister for +// ClusterTasks. +type ClusterTaskInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.ClusterTaskLister +} + +type clusterTaskInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewClusterTaskInformer constructs a new informer for ClusterTask 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 NewClusterTaskInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterTaskInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterTaskInformer constructs a new informer for ClusterTask 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 NewFilteredClusterTaskInformer(client versioned.Interface, 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.TektonV1alpha2().ClusterTasks().List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TektonV1alpha2().ClusterTasks().Watch(options) + }, + }, + &pipelinev1alpha2.ClusterTask{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterTaskInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterTaskInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterTaskInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&pipelinev1alpha2.ClusterTask{}, f.defaultInformer) +} + +func (f *clusterTaskInformer) Lister() v1alpha2.ClusterTaskLister { + return v1alpha2.NewClusterTaskLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/pipeline/v1alpha2/interface.go b/pkg/client/informers/externalversions/pipeline/v1alpha2/interface.go index 6a9a5d24343..4a89c984ea9 100644 --- a/pkg/client/informers/externalversions/pipeline/v1alpha2/interface.go +++ b/pkg/client/informers/externalversions/pipeline/v1alpha2/interface.go @@ -24,6 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // ClusterTasks returns a ClusterTaskInformer. + ClusterTasks() ClusterTaskInformer // Pipelines returns a PipelineInformer. Pipelines() PipelineInformer // Tasks returns a TaskInformer. @@ -43,6 +45,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// ClusterTasks returns a ClusterTaskInformer. +func (v *version) ClusterTasks() ClusterTaskInformer { + return &clusterTaskInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // Pipelines returns a PipelineInformer. func (v *version) Pipelines() PipelineInformer { return &pipelineInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/injection/informers/pipeline/v1alpha2/clustertask/clustertask.go b/pkg/client/injection/informers/pipeline/v1alpha2/clustertask/clustertask.go new file mode 100644 index 00000000000..f99f39a8fde --- /dev/null +++ b/pkg/client/injection/informers/pipeline/v1alpha2/clustertask/clustertask.go @@ -0,0 +1,52 @@ +/* +Copyright 2019 The Tekton 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package clustertask + +import ( + "context" + + v1alpha2 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha2" + factory "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Tekton().V1alpha2().ClusterTasks() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1alpha2.ClusterTaskInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha2.ClusterTaskInformer from context.") + } + return untyped.(v1alpha2.ClusterTaskInformer) +} diff --git a/pkg/client/injection/informers/pipeline/v1alpha2/clustertask/fake/fake.go b/pkg/client/injection/informers/pipeline/v1alpha2/clustertask/fake/fake.go new file mode 100644 index 00000000000..241415d5657 --- /dev/null +++ b/pkg/client/injection/informers/pipeline/v1alpha2/clustertask/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2019 The Tekton 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + fake "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory/fake" + clustertask "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha2/clustertask" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = clustertask.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Tekton().V1alpha2().ClusterTasks() + return context.WithValue(ctx, clustertask.Key{}, inf), inf.Informer() +} diff --git a/pkg/client/listers/pipeline/v1alpha2/clustertask.go b/pkg/client/listers/pipeline/v1alpha2/clustertask.go new file mode 100644 index 00000000000..e71fbe7492a --- /dev/null +++ b/pkg/client/listers/pipeline/v1alpha2/clustertask.go @@ -0,0 +1,65 @@ +/* +Copyright 2019 The Tekton 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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha2 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterTaskLister helps list ClusterTasks. +type ClusterTaskLister interface { + // List lists all ClusterTasks in the indexer. + List(selector labels.Selector) (ret []*v1alpha2.ClusterTask, err error) + // Get retrieves the ClusterTask from the index for a given name. + Get(name string) (*v1alpha2.ClusterTask, error) + ClusterTaskListerExpansion +} + +// clusterTaskLister implements the ClusterTaskLister interface. +type clusterTaskLister struct { + indexer cache.Indexer +} + +// NewClusterTaskLister returns a new ClusterTaskLister. +func NewClusterTaskLister(indexer cache.Indexer) ClusterTaskLister { + return &clusterTaskLister{indexer: indexer} +} + +// List lists all ClusterTasks in the indexer. +func (s *clusterTaskLister) List(selector labels.Selector) (ret []*v1alpha2.ClusterTask, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.ClusterTask)) + }) + return ret, err +} + +// Get retrieves the ClusterTask from the index for a given name. +func (s *clusterTaskLister) Get(name string) (*v1alpha2.ClusterTask, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha2.Resource("clustertask"), name) + } + return obj.(*v1alpha2.ClusterTask), nil +} diff --git a/pkg/client/listers/pipeline/v1alpha2/expansion_generated.go b/pkg/client/listers/pipeline/v1alpha2/expansion_generated.go index 4ea8eb3e8d4..2357190f007 100644 --- a/pkg/client/listers/pipeline/v1alpha2/expansion_generated.go +++ b/pkg/client/listers/pipeline/v1alpha2/expansion_generated.go @@ -18,6 +18,10 @@ limitations under the License. package v1alpha2 +// ClusterTaskListerExpansion allows custom methods to be added to +// ClusterTaskLister. +type ClusterTaskListerExpansion interface{} + // PipelineListerExpansion allows custom methods to be added to // PipelineLister. type PipelineListerExpansion interface{}