From 43cb1fd905460b6797e68684c96754cdf3dbcf36 Mon Sep 17 00:00:00 2001 From: Tapas Sharma Date: Wed, 17 Apr 2019 13:03:52 -0700 Subject: [PATCH] Define CRD for application cloning 0. This checkin defines the first level CRD for cloning applications 1. Added replace policy to the spec 2. Added ApplicationClone and ApplicationCloneList to register.go 3. Added ResourceInfo and VolumeInfo to the status of clone 4. Removed Namespace from the volumeInfo and resourceInfo Signed-off-by: Tapas Sharma --- pkg/apis/stork/v1alpha1/applicationclone.go | 127 +++++++++++++ pkg/apis/stork/v1alpha1/register.go | 2 + .../stork/v1alpha1/zz_generated.deepcopy.go | 156 ++++++++++++++++ .../typed/stork/v1alpha1/applicationclone.go | 174 ++++++++++++++++++ .../v1alpha1/fake/fake_applicationclone.go | 140 ++++++++++++++ .../stork/v1alpha1/fake/fake_stork_client.go | 4 + .../stork/v1alpha1/generated_expansion.go | 2 + .../typed/stork/v1alpha1/stork_client.go | 5 + .../informers/externalversions/generic.go | 2 + .../stork/v1alpha1/applicationclone.go | 89 +++++++++ .../stork/v1alpha1/interface.go | 7 + .../stork/v1alpha1/applicationclone.go | 94 ++++++++++ .../stork/v1alpha1/expansion_generated.go | 8 + 13 files changed, 810 insertions(+) create mode 100644 pkg/apis/stork/v1alpha1/applicationclone.go create mode 100644 pkg/client/clientset/versioned/typed/stork/v1alpha1/applicationclone.go create mode 100644 pkg/client/clientset/versioned/typed/stork/v1alpha1/fake/fake_applicationclone.go create mode 100644 pkg/client/informers/externalversions/stork/v1alpha1/applicationclone.go create mode 100644 pkg/client/listers/stork/v1alpha1/applicationclone.go diff --git a/pkg/apis/stork/v1alpha1/applicationclone.go b/pkg/apis/stork/v1alpha1/applicationclone.go new file mode 100644 index 0000000000..d2eeb255e8 --- /dev/null +++ b/pkg/apis/stork/v1alpha1/applicationclone.go @@ -0,0 +1,127 @@ +package v1alpha1 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // ApplicationCloneResourceName is the name for the application clone resource + ApplicationCloneResourceName = "applicationclone" + // ApplicationCloneResourcePlural is the name in plural for the application clone resources + ApplicationCloneResourcePlural = "applicationclones" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ApplicationClone represents the cloning of application in different namespaces +type ApplicationClone struct { + meta.TypeMeta `json:",inline"` + meta.ObjectMeta `json:"metadata,omitempty"` + Spec ApplicationCloneSpec `json:"spec"` + Status ApplicationCloneStatus `json:"status,omitempty"` +} + +// ApplicationCloneSpec defines the spec to create an application clone +type ApplicationCloneSpec struct { + // SourceNamespace can be optional, and we can check in the code that we are using + // the same namespace in which we are creating the cloning object + // +optional + SourceNamespace string `json:"sourceNamespace,omitempty"` + // DestinationNamespace is a must parameter to tell the cloning object + // where to place the application objects + DestinationNamespace string `json:"destinationNamespace"` + // Selectors for label on objects + Selectors map[string]string `json:"selectors"` + PreExecRule string `json:"preExecRule"` + PostExecRule string `json:"postExecRule"` + // ReplacePolicy to decide how to react when a object conflict occurs in the cloning process + ReplacePolicy ApplicationCloneReplacePolicyType `json:"replacePolicy"` +} + +// ApplicationCloneStatus defines the status of the clone +type ApplicationCloneStatus struct { + // Status of the cloning process + Status ApplicationCloneStatusType `json:"status"` + // Stage of the cloning process + Stage ApplicationCloneStageType `json:"stage"` + Resources []*ApplicationCloneResourceInfo `json:"resources"` + Volumes []*ApplicationCloneVolumeInfo `json:"volumes"` + FinishTimestamp meta.Time `json:"finishTimestamp"` +} + +// ApplicationCloneResourceInfo is the info for the cloning of a resource +type ApplicationCloneResourceInfo struct { + Name string `json:"name"` + Reason string `json:"reason"` + Status ApplicationCloneStatusType `json:"status"` + meta.GroupVersionKind `json:",inline"` +} + +// ApplicationCloneVolumeInfo is the info for the cloning of a volume +type ApplicationCloneVolumeInfo struct { + PersistentVolumeClaim string `json:"persistentVolumeClaim"` + Volume string `json:"volume"` + ClonedVolume string `json:"clonedVolume"` + Status ApplicationCloneStatusType `json:"status"` + Reason string `json:"reason"` +} + +// ApplicationCloneStatusType defines status of the application being cloned +type ApplicationCloneStatusType string + +const ( + // ApplicationCloneStatusInitial initial state when the cloning will start + ApplicationCloneStatusInitial ApplicationCloneStatusType = "" + // ApplicationCloneStatusPending when cloning is still pending + ApplicationCloneStatusPending ApplicationCloneStatusType = "Pending" + // ApplicationCloneStatusInProgress cloning in progress + ApplicationCloneStatusInProgress ApplicationCloneStatusType = "InProgress" + // ApplicationCloneStatusFailed when cloning has failed + ApplicationCloneStatusFailed ApplicationCloneStatusType = "Failed" + // ApplicationCloneStatusSuccess when cloning was a success + ApplicationCloneStatusSuccess ApplicationCloneStatusType = "Success" + // ApplicationCloneStatusPartialSuccess when cloning was only partially successful + ApplicationCloneStatusPartialSuccess ApplicationCloneStatusType = "PartialSuccess" +) + +// ApplicationCloneStageType defines the stage of the cloning process +type ApplicationCloneStageType string + +const ( + // ApplicationCloneStageInitial when the cloning was started + ApplicationCloneStageInitial ApplicationCloneStageType = "" + // ApplicationCloneStagePreExecRule stage when pre-exec rules are being executed + ApplicationCloneStagePreExecRule ApplicationCloneStageType = "PreExecRule" + // ApplicationCloneStagePostExecRule stage when post-exec rules are being executed + ApplicationCloneStagePostExecRule ApplicationCloneStageType = "PostExecRule" + // ApplicationCloneStageVolumeClone stage where the volumes are being cloned + ApplicationCloneStageVolumeClone ApplicationCloneStageType = "VolumeClone" + // ApplicationCloneStageApplicationClone stage when applications are being cloned + ApplicationCloneStageApplicationClone ApplicationCloneStageType = "ApplicationClone" + // ApplicationCloneStageDone stage when the cloning is done + ApplicationCloneStageDone ApplicationCloneStageType = "Done" +) + +// ApplicationCloneReplacePolicyType defines the policy for objects that might already exist in +// the destination namespace, should they be replaced, deleted, retained or overwritten +type ApplicationCloneReplacePolicyType string + +const ( + // ApplicationCloneReplacePolicyDelete will delete any conflicts in objects in the + // destination namespace + ApplicationCloneReplacePolicyDelete ApplicationCloneReplacePolicyType = "Delete" + // ApplicationCloneReplacePolicyRetain will retain any conflicts and not change/clone + ApplicationCloneReplacePolicyRetain ApplicationCloneReplacePolicyType = "Retain" + // ApplicationCloneReplacePolicyFail will trigger a clone failure on conflicts + ApplicationCloneReplacePolicyFail ApplicationCloneReplacePolicyType = "Fail" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ApplicationCloneList is a list of ApplicationClones +type ApplicationCloneList struct { + meta.TypeMeta `json:",inline"` + meta.ListMeta `json:"metadata,omitempty"` + Items []ApplicationClone `json:"items"` +} diff --git a/pkg/apis/stork/v1alpha1/register.go b/pkg/apis/stork/v1alpha1/register.go index 5bc6b71ed3..c2adfe263b 100644 --- a/pkg/apis/stork/v1alpha1/register.go +++ b/pkg/apis/stork/v1alpha1/register.go @@ -51,6 +51,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ClusterDomainsStatusList{}, &ClusterDomainUpdate{}, &ClusterDomainUpdateList{}, + &ApplicationClone{}, + &ApplicationCloneList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/pkg/apis/stork/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/stork/v1alpha1/zz_generated.deepcopy.go index 9cbb10aff2..38c7ed607b 100644 --- a/pkg/apis/stork/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/stork/v1alpha1/zz_generated.deepcopy.go @@ -27,6 +27,162 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationClone) DeepCopyInto(out *ApplicationClone) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationClone. +func (in *ApplicationClone) DeepCopy() *ApplicationClone { + if in == nil { + return nil + } + out := new(ApplicationClone) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ApplicationClone) 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 *ApplicationCloneList) DeepCopyInto(out *ApplicationCloneList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ApplicationClone, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationCloneList. +func (in *ApplicationCloneList) DeepCopy() *ApplicationCloneList { + if in == nil { + return nil + } + out := new(ApplicationCloneList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ApplicationCloneList) 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 *ApplicationCloneResourceInfo) DeepCopyInto(out *ApplicationCloneResourceInfo) { + *out = *in + out.GroupVersionKind = in.GroupVersionKind + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationCloneResourceInfo. +func (in *ApplicationCloneResourceInfo) DeepCopy() *ApplicationCloneResourceInfo { + if in == nil { + return nil + } + out := new(ApplicationCloneResourceInfo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationCloneSpec) DeepCopyInto(out *ApplicationCloneSpec) { + *out = *in + if in.Selectors != nil { + in, out := &in.Selectors, &out.Selectors + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationCloneSpec. +func (in *ApplicationCloneSpec) DeepCopy() *ApplicationCloneSpec { + if in == nil { + return nil + } + out := new(ApplicationCloneSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationCloneStatus) DeepCopyInto(out *ApplicationCloneStatus) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]*ApplicationCloneResourceInfo, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(ApplicationCloneResourceInfo) + **out = **in + } + } + } + if in.Volumes != nil { + in, out := &in.Volumes, &out.Volumes + *out = make([]*ApplicationCloneVolumeInfo, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(ApplicationCloneVolumeInfo) + **out = **in + } + } + } + in.FinishTimestamp.DeepCopyInto(&out.FinishTimestamp) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationCloneStatus. +func (in *ApplicationCloneStatus) DeepCopy() *ApplicationCloneStatus { + if in == nil { + return nil + } + out := new(ApplicationCloneStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationCloneVolumeInfo) DeepCopyInto(out *ApplicationCloneVolumeInfo) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationCloneVolumeInfo. +func (in *ApplicationCloneVolumeInfo) DeepCopy() *ApplicationCloneVolumeInfo { + if in == nil { + return nil + } + out := new(ApplicationCloneVolumeInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CloudStorageSpec) DeepCopyInto(out *CloudStorageSpec) { *out = *in diff --git a/pkg/client/clientset/versioned/typed/stork/v1alpha1/applicationclone.go b/pkg/client/clientset/versioned/typed/stork/v1alpha1/applicationclone.go new file mode 100644 index 0000000000..9a7c0ab6c6 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/stork/v1alpha1/applicationclone.go @@ -0,0 +1,174 @@ +/* +Copyright 2018 Openstorage.org + +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 v1alpha1 + +import ( + v1alpha1 "github.com/libopenstorage/stork/pkg/apis/stork/v1alpha1" + scheme "github.com/libopenstorage/stork/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" +) + +// ApplicationClonesGetter has a method to return a ApplicationCloneInterface. +// A group's client should implement this interface. +type ApplicationClonesGetter interface { + ApplicationClones(namespace string) ApplicationCloneInterface +} + +// ApplicationCloneInterface has methods to work with ApplicationClone resources. +type ApplicationCloneInterface interface { + Create(*v1alpha1.ApplicationClone) (*v1alpha1.ApplicationClone, error) + Update(*v1alpha1.ApplicationClone) (*v1alpha1.ApplicationClone, error) + UpdateStatus(*v1alpha1.ApplicationClone) (*v1alpha1.ApplicationClone, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.ApplicationClone, error) + List(opts v1.ListOptions) (*v1alpha1.ApplicationCloneList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApplicationClone, err error) + ApplicationCloneExpansion +} + +// applicationClones implements ApplicationCloneInterface +type applicationClones struct { + client rest.Interface + ns string +} + +// newApplicationClones returns a ApplicationClones +func newApplicationClones(c *StorkV1alpha1Client, namespace string) *applicationClones { + return &applicationClones{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the applicationClone, and returns the corresponding applicationClone object, and an error if there is any. +func (c *applicationClones) Get(name string, options v1.GetOptions) (result *v1alpha1.ApplicationClone, err error) { + result = &v1alpha1.ApplicationClone{} + err = c.client.Get(). + Namespace(c.ns). + Resource("applicationclones"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ApplicationClones that match those selectors. +func (c *applicationClones) List(opts v1.ListOptions) (result *v1alpha1.ApplicationCloneList, err error) { + result = &v1alpha1.ApplicationCloneList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("applicationclones"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested applicationClones. +func (c *applicationClones) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("applicationclones"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a applicationClone and creates it. Returns the server's representation of the applicationClone, and an error, if there is any. +func (c *applicationClones) Create(applicationClone *v1alpha1.ApplicationClone) (result *v1alpha1.ApplicationClone, err error) { + result = &v1alpha1.ApplicationClone{} + err = c.client.Post(). + Namespace(c.ns). + Resource("applicationclones"). + Body(applicationClone). + Do(). + Into(result) + return +} + +// Update takes the representation of a applicationClone and updates it. Returns the server's representation of the applicationClone, and an error, if there is any. +func (c *applicationClones) Update(applicationClone *v1alpha1.ApplicationClone) (result *v1alpha1.ApplicationClone, err error) { + result = &v1alpha1.ApplicationClone{} + err = c.client.Put(). + Namespace(c.ns). + Resource("applicationclones"). + Name(applicationClone.Name). + Body(applicationClone). + 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 *applicationClones) UpdateStatus(applicationClone *v1alpha1.ApplicationClone) (result *v1alpha1.ApplicationClone, err error) { + result = &v1alpha1.ApplicationClone{} + err = c.client.Put(). + Namespace(c.ns). + Resource("applicationclones"). + Name(applicationClone.Name). + SubResource("status"). + Body(applicationClone). + Do(). + Into(result) + return +} + +// Delete takes name of the applicationClone and deletes it. Returns an error if one occurs. +func (c *applicationClones) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("applicationclones"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *applicationClones) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("applicationclones"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched applicationClone. +func (c *applicationClones) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApplicationClone, err error) { + result = &v1alpha1.ApplicationClone{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("applicationclones"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/stork/v1alpha1/fake/fake_applicationclone.go b/pkg/client/clientset/versioned/typed/stork/v1alpha1/fake/fake_applicationclone.go new file mode 100644 index 0000000000..001ada22ba --- /dev/null +++ b/pkg/client/clientset/versioned/typed/stork/v1alpha1/fake/fake_applicationclone.go @@ -0,0 +1,140 @@ +/* +Copyright 2018 Openstorage.org + +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 ( + v1alpha1 "github.com/libopenstorage/stork/pkg/apis/stork/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" +) + +// FakeApplicationClones implements ApplicationCloneInterface +type FakeApplicationClones struct { + Fake *FakeStorkV1alpha1 + ns string +} + +var applicationclonesResource = schema.GroupVersionResource{Group: "stork.libopenstorage.org", Version: "v1alpha1", Resource: "applicationclones"} + +var applicationclonesKind = schema.GroupVersionKind{Group: "stork.libopenstorage.org", Version: "v1alpha1", Kind: "ApplicationClone"} + +// Get takes name of the applicationClone, and returns the corresponding applicationClone object, and an error if there is any. +func (c *FakeApplicationClones) Get(name string, options v1.GetOptions) (result *v1alpha1.ApplicationClone, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(applicationclonesResource, c.ns, name), &v1alpha1.ApplicationClone{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ApplicationClone), err +} + +// List takes label and field selectors, and returns the list of ApplicationClones that match those selectors. +func (c *FakeApplicationClones) List(opts v1.ListOptions) (result *v1alpha1.ApplicationCloneList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(applicationclonesResource, applicationclonesKind, c.ns, opts), &v1alpha1.ApplicationCloneList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ApplicationCloneList{ListMeta: obj.(*v1alpha1.ApplicationCloneList).ListMeta} + for _, item := range obj.(*v1alpha1.ApplicationCloneList).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 applicationClones. +func (c *FakeApplicationClones) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(applicationclonesResource, c.ns, opts)) + +} + +// Create takes the representation of a applicationClone and creates it. Returns the server's representation of the applicationClone, and an error, if there is any. +func (c *FakeApplicationClones) Create(applicationClone *v1alpha1.ApplicationClone) (result *v1alpha1.ApplicationClone, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(applicationclonesResource, c.ns, applicationClone), &v1alpha1.ApplicationClone{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ApplicationClone), err +} + +// Update takes the representation of a applicationClone and updates it. Returns the server's representation of the applicationClone, and an error, if there is any. +func (c *FakeApplicationClones) Update(applicationClone *v1alpha1.ApplicationClone) (result *v1alpha1.ApplicationClone, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(applicationclonesResource, c.ns, applicationClone), &v1alpha1.ApplicationClone{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ApplicationClone), 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 *FakeApplicationClones) UpdateStatus(applicationClone *v1alpha1.ApplicationClone) (*v1alpha1.ApplicationClone, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(applicationclonesResource, "status", c.ns, applicationClone), &v1alpha1.ApplicationClone{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ApplicationClone), err +} + +// Delete takes name of the applicationClone and deletes it. Returns an error if one occurs. +func (c *FakeApplicationClones) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(applicationclonesResource, c.ns, name), &v1alpha1.ApplicationClone{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeApplicationClones) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(applicationclonesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ApplicationCloneList{}) + return err +} + +// Patch applies the patch and returns the patched applicationClone. +func (c *FakeApplicationClones) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApplicationClone, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(applicationclonesResource, c.ns, name, data, subresources...), &v1alpha1.ApplicationClone{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ApplicationClone), err +} diff --git a/pkg/client/clientset/versioned/typed/stork/v1alpha1/fake/fake_stork_client.go b/pkg/client/clientset/versioned/typed/stork/v1alpha1/fake/fake_stork_client.go index a2a5ec4291..cd11b4c778 100644 --- a/pkg/client/clientset/versioned/typed/stork/v1alpha1/fake/fake_stork_client.go +++ b/pkg/client/clientset/versioned/typed/stork/v1alpha1/fake/fake_stork_client.go @@ -28,6 +28,10 @@ type FakeStorkV1alpha1 struct { *testing.Fake } +func (c *FakeStorkV1alpha1) ApplicationClones(namespace string) v1alpha1.ApplicationCloneInterface { + return &FakeApplicationClones{c, namespace} +} + func (c *FakeStorkV1alpha1) ClusterDomainUpdates() v1alpha1.ClusterDomainUpdateInterface { return &FakeClusterDomainUpdates{c} } diff --git a/pkg/client/clientset/versioned/typed/stork/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/stork/v1alpha1/generated_expansion.go index cef0a4f54e..2c18a7dbe8 100644 --- a/pkg/client/clientset/versioned/typed/stork/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/stork/v1alpha1/generated_expansion.go @@ -18,6 +18,8 @@ limitations under the License. package v1alpha1 +type ApplicationCloneExpansion interface{} + type ClusterDomainUpdateExpansion interface{} type ClusterDomainsStatusExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/stork/v1alpha1/stork_client.go b/pkg/client/clientset/versioned/typed/stork/v1alpha1/stork_client.go index e8b2b31462..44608314b8 100644 --- a/pkg/client/clientset/versioned/typed/stork/v1alpha1/stork_client.go +++ b/pkg/client/clientset/versioned/typed/stork/v1alpha1/stork_client.go @@ -27,6 +27,7 @@ import ( type StorkV1alpha1Interface interface { RESTClient() rest.Interface + ApplicationClonesGetter ClusterDomainUpdatesGetter ClusterDomainsStatusesGetter ClusterPairsGetter @@ -44,6 +45,10 @@ type StorkV1alpha1Client struct { restClient rest.Interface } +func (c *StorkV1alpha1Client) ApplicationClones(namespace string) ApplicationCloneInterface { + return newApplicationClones(c, namespace) +} + func (c *StorkV1alpha1Client) ClusterDomainUpdates() ClusterDomainUpdateInterface { return newClusterDomainUpdates(c) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 69c100c1f1..28fc5532ef 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -53,6 +53,8 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=stork.libopenstorage.org, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("applicationclones"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Stork().V1alpha1().ApplicationClones().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clusterdomainupdates"): return &genericInformer{resource: resource.GroupResource(), informer: f.Stork().V1alpha1().ClusterDomainUpdates().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clusterdomainsstatuses"): diff --git a/pkg/client/informers/externalversions/stork/v1alpha1/applicationclone.go b/pkg/client/informers/externalversions/stork/v1alpha1/applicationclone.go new file mode 100644 index 0000000000..847d593ede --- /dev/null +++ b/pkg/client/informers/externalversions/stork/v1alpha1/applicationclone.go @@ -0,0 +1,89 @@ +/* +Copyright 2018 Openstorage.org + +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 v1alpha1 + +import ( + time "time" + + storkv1alpha1 "github.com/libopenstorage/stork/pkg/apis/stork/v1alpha1" + versioned "github.com/libopenstorage/stork/pkg/client/clientset/versioned" + internalinterfaces "github.com/libopenstorage/stork/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/libopenstorage/stork/pkg/client/listers/stork/v1alpha1" + 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" +) + +// ApplicationCloneInformer provides access to a shared informer and lister for +// ApplicationClones. +type ApplicationCloneInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ApplicationCloneLister +} + +type applicationCloneInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewApplicationCloneInformer constructs a new informer for ApplicationClone 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 NewApplicationCloneInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredApplicationCloneInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredApplicationCloneInformer constructs a new informer for ApplicationClone 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 NewFilteredApplicationCloneInformer(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.StorkV1alpha1().ApplicationClones(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.StorkV1alpha1().ApplicationClones(namespace).Watch(options) + }, + }, + &storkv1alpha1.ApplicationClone{}, + resyncPeriod, + indexers, + ) +} + +func (f *applicationCloneInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredApplicationCloneInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *applicationCloneInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&storkv1alpha1.ApplicationClone{}, f.defaultInformer) +} + +func (f *applicationCloneInformer) Lister() v1alpha1.ApplicationCloneLister { + return v1alpha1.NewApplicationCloneLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/stork/v1alpha1/interface.go b/pkg/client/informers/externalversions/stork/v1alpha1/interface.go index ab64381e5f..ae9f8fcf5f 100644 --- a/pkg/client/informers/externalversions/stork/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/stork/v1alpha1/interface.go @@ -24,6 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // ApplicationClones returns a ApplicationCloneInformer. + ApplicationClones() ApplicationCloneInformer // ClusterDomainUpdates returns a ClusterDomainUpdateInformer. ClusterDomainUpdates() ClusterDomainUpdateInformer // ClusterDomainsStatuses returns a ClusterDomainsStatusInformer. @@ -57,6 +59,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// ApplicationClones returns a ApplicationCloneInformer. +func (v *version) ApplicationClones() ApplicationCloneInformer { + return &applicationCloneInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // ClusterDomainUpdates returns a ClusterDomainUpdateInformer. func (v *version) ClusterDomainUpdates() ClusterDomainUpdateInformer { return &clusterDomainUpdateInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/listers/stork/v1alpha1/applicationclone.go b/pkg/client/listers/stork/v1alpha1/applicationclone.go new file mode 100644 index 0000000000..3f2ea5c83f --- /dev/null +++ b/pkg/client/listers/stork/v1alpha1/applicationclone.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 Openstorage.org + +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 v1alpha1 + +import ( + v1alpha1 "github.com/libopenstorage/stork/pkg/apis/stork/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ApplicationCloneLister helps list ApplicationClones. +type ApplicationCloneLister interface { + // List lists all ApplicationClones in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.ApplicationClone, err error) + // ApplicationClones returns an object that can list and get ApplicationClones. + ApplicationClones(namespace string) ApplicationCloneNamespaceLister + ApplicationCloneListerExpansion +} + +// applicationCloneLister implements the ApplicationCloneLister interface. +type applicationCloneLister struct { + indexer cache.Indexer +} + +// NewApplicationCloneLister returns a new ApplicationCloneLister. +func NewApplicationCloneLister(indexer cache.Indexer) ApplicationCloneLister { + return &applicationCloneLister{indexer: indexer} +} + +// List lists all ApplicationClones in the indexer. +func (s *applicationCloneLister) List(selector labels.Selector) (ret []*v1alpha1.ApplicationClone, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ApplicationClone)) + }) + return ret, err +} + +// ApplicationClones returns an object that can list and get ApplicationClones. +func (s *applicationCloneLister) ApplicationClones(namespace string) ApplicationCloneNamespaceLister { + return applicationCloneNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ApplicationCloneNamespaceLister helps list and get ApplicationClones. +type ApplicationCloneNamespaceLister interface { + // List lists all ApplicationClones in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.ApplicationClone, err error) + // Get retrieves the ApplicationClone from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.ApplicationClone, error) + ApplicationCloneNamespaceListerExpansion +} + +// applicationCloneNamespaceLister implements the ApplicationCloneNamespaceLister +// interface. +type applicationCloneNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ApplicationClones in the indexer for a given namespace. +func (s applicationCloneNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ApplicationClone, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ApplicationClone)) + }) + return ret, err +} + +// Get retrieves the ApplicationClone from the indexer for a given namespace and name. +func (s applicationCloneNamespaceLister) Get(name string) (*v1alpha1.ApplicationClone, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("applicationclone"), name) + } + return obj.(*v1alpha1.ApplicationClone), nil +} diff --git a/pkg/client/listers/stork/v1alpha1/expansion_generated.go b/pkg/client/listers/stork/v1alpha1/expansion_generated.go index 2c310bbf89..697b21cfcd 100644 --- a/pkg/client/listers/stork/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/stork/v1alpha1/expansion_generated.go @@ -18,6 +18,14 @@ limitations under the License. package v1alpha1 +// ApplicationCloneListerExpansion allows custom methods to be added to +// ApplicationCloneLister. +type ApplicationCloneListerExpansion interface{} + +// ApplicationCloneNamespaceListerExpansion allows custom methods to be added to +// ApplicationCloneNamespaceLister. +type ApplicationCloneNamespaceListerExpansion interface{} + // ClusterDomainUpdateListerExpansion allows custom methods to be added to // ClusterDomainUpdateLister. type ClusterDomainUpdateListerExpansion interface{}