From 146be56408427bc8a8be8afe1c3f446ddc90518c Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Tue, 12 Jun 2018 17:21:50 +0100 Subject: [PATCH 01/14] Apis --- pkg/apis/wing/types.go | 82 ++++++--- pkg/apis/wing/v1alpha1/types.go | 82 ++++++--- .../wing/v1alpha1/fake/fake_puppettarget.go | 111 +++++++++++++ .../wing/v1alpha1/fake/fake_wing_client.go | 8 + .../typed/wing/v1alpha1/fake/fake_wingjob.go | 123 ++++++++++++++ .../wing/v1alpha1/generated_expansion.go | 4 + .../typed/wing/v1alpha1/puppettarget.go | 140 ++++++++++++++++ .../client/typed/wing/v1alpha1/wing_client.go | 10 ++ .../client/typed/wing/v1alpha1/wingjob.go | 157 ++++++++++++++++++ .../internalversion/fake/fake_puppettarget.go | 111 +++++++++++++ .../internalversion/fake/fake_wing_client.go | 8 + .../wing/internalversion/fake/fake_wingjob.go | 123 ++++++++++++++ .../internalversion/generated_expansion.go | 4 + .../wing/internalversion/puppettarget.go | 140 ++++++++++++++++ .../typed/wing/internalversion/wing_client.go | 10 ++ .../typed/wing/internalversion/wingjob.go | 157 ++++++++++++++++++ .../informers/externalversions/generic.go | 4 + .../wing/v1alpha1/interface.go | 14 ++ .../wing/v1alpha1/puppettarget.go | 74 +++++++++ .../externalversions/wing/v1alpha1/wingjob.go | 74 +++++++++ pkg/wing/informers/internalversion/generic.go | 4 + .../wing/internalversion/interface.go | 14 ++ .../wing/internalversion/puppettarget.go | 74 +++++++++ .../wing/internalversion/wingjob.go | 74 +++++++++ .../internalversion/expansion_generated.go | 16 ++ .../wing/internalversion/puppettarget.go | 80 +++++++++ .../listers/wing/internalversion/wingjob.go | 80 +++++++++ .../wing/v1alpha1/expansion_generated.go | 16 ++ .../listers/wing/v1alpha1/puppettarget.go | 80 +++++++++ pkg/wing/listers/wing/v1alpha1/wingjob.go | 80 +++++++++ 30 files changed, 1913 insertions(+), 41 deletions(-) create mode 100644 pkg/wing/client/typed/wing/v1alpha1/fake/fake_puppettarget.go create mode 100644 pkg/wing/client/typed/wing/v1alpha1/fake/fake_wingjob.go create mode 100644 pkg/wing/client/typed/wing/v1alpha1/puppettarget.go create mode 100644 pkg/wing/client/typed/wing/v1alpha1/wingjob.go create mode 100644 pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_puppettarget.go create mode 100644 pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wingjob.go create mode 100644 pkg/wing/clients/internalclientset/typed/wing/internalversion/puppettarget.go create mode 100644 pkg/wing/clients/internalclientset/typed/wing/internalversion/wingjob.go create mode 100644 pkg/wing/informers/externalversions/wing/v1alpha1/puppettarget.go create mode 100644 pkg/wing/informers/externalversions/wing/v1alpha1/wingjob.go create mode 100644 pkg/wing/informers/internalversion/wing/internalversion/puppettarget.go create mode 100644 pkg/wing/informers/internalversion/wing/internalversion/wingjob.go create mode 100644 pkg/wing/listers/wing/internalversion/puppettarget.go create mode 100644 pkg/wing/listers/wing/internalversion/wingjob.go create mode 100644 pkg/wing/listers/wing/v1alpha1/puppettarget.go create mode 100644 pkg/wing/listers/wing/v1alpha1/wingjob.go diff --git a/pkg/apis/wing/types.go b/pkg/apis/wing/types.go index 4f2db40f55..eeba56429f 100644 --- a/pkg/apis/wing/types.go +++ b/pkg/apis/wing/types.go @@ -12,7 +12,7 @@ type Instance struct { metav1.TypeMeta metav1.ObjectMeta - InstanceID string + InstanceID string `json:"instanceID,omitempty"` InstancePool string Spec *InstanceSpec @@ -21,39 +21,79 @@ type Instance struct { // InstanceSpec defines the desired state of Instance type InstanceSpec struct { - Converge *InstanceSpecManifest - DryRun *InstanceSpecManifest + PuppetManifestRef string } -// InstaceSpecManifest defines location and hash for a specific manifest -type InstanceSpecManifest struct { - Path string +// InstanceStatus defines the observed state of Instance +type InstanceStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type InstanceList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []Instance +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type PuppetTarget struct { + metav1.TypeMeta + metav1.ObjectMeta + + Source ManifestSource Hash string RequestTimestamp metav1.Time } -// InstanceStatus defines the observed state of Instance -type InstanceStatus struct { - Converge *InstanceStatusManifest - DryRun *InstanceStatusManifest +type ManifestSource struct { + S3 *S3ManifestSource } -// InstaceSpecManifest defines the state and hash of a run manifest -type InstanceManifestState string -type InstanceStatusManifest struct { - State InstanceManifestState - Hash string - LastUpdateTimestamp metav1.Time - Messages []string - ExitCodes []int +type S3ManifestSource struct { + BucketName string } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type InstanceList struct { +type PuppetTargetList struct { metav1.TypeMeta - // +optional metav1.ListMeta - Items []Instance + Items []PuppetTarget `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type WingJob struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec *WingJobSpec + Status *WingJobStatus +} + +type WingJobSpec struct { + InstanceID string + Source ManifestSource + Operation string + RequestTimestamp metav1.Time +} + +type WingJobStatus struct { + Messages string + ExitCode int +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type WingJobList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []WingJob } diff --git a/pkg/apis/wing/v1alpha1/types.go b/pkg/apis/wing/v1alpha1/types.go index 94bab71419..93aa3e9db3 100644 --- a/pkg/apis/wing/v1alpha1/types.go +++ b/pkg/apis/wing/v1alpha1/types.go @@ -21,30 +21,11 @@ type Instance struct { // InstanceSpec defines the desired state of Instance type InstanceSpec struct { - Converge *InstanceSpecManifest `json:"converge,omitempty"` - DryRun *InstanceSpecManifest `json:"dryRun,omitempty"` -} - -// InstaceSpecManifest defines location and hash for a specific manifest -type InstanceSpecManifest struct { - Path string `json:"path,omitempty"` // PATH to manifests (tar.gz) - Hash string `json:"hash,omitempty"` // hash of manifests, prefixed with type (eg: sha256:xyz) - RequestTimestamp metav1.Time `json:"requestTimestamp,omitempty"` // timestamp when a converge was requested + PuppetManifestRef string `json:"puppetManifestRef"` } // InstanceStatus defines the observed state of Instance type InstanceStatus struct { - Converge *InstanceStatusManifest `json:"converge,omitempty"` - DryRun *InstanceStatusManifest `json:"dryRun,omitempty"` -} - -// InstaceSpecManifest defines the state and hash of a run manifest -type InstanceStatusManifest struct { - State InstanceManifestState `json:"state,omitempty"` - Hash string `json:"hash,omitempty"` // hash of manifests, prefixed with type (eg: sha256:xyz) - LastUpdateTimestamp metav1.Time `json:"lastUpdateTimestamp,omitempty"` // timestamp when a converge was requested - Messages []string `json:"messages,omitempty"` // contains output of the retries - ExitCodes []int `json:"exitCodes,omitempty"` // return code of the retries } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -55,3 +36,64 @@ type InstanceList struct { Items []Instance `json:"items"` } + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type PuppetTarget struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Source ManifestSource `json:"source"` + Hash string `json:"hash,omitempty"` // hash of manifests, prefixed with type (eg: sha256:xyz) + RequestTimestamp metav1.Time `json:"requestTimestamp,omitempty"` // timestamp when a converge was requested +} + +type ManifestSource struct { + S3 *S3ManifestSource `json:"s3"` +} + +type S3ManifestSource struct { + BucketName string `json:"bucketName"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type PuppetTargetList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []PuppetTarget `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type WingJob struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec *WingJobSpec `json:"spec,omitempty"` + Status *WingJobStatus `json:"status,omitempty"` +} + +type WingJobSpec struct { + InstanceID string `json:"instanceID,omitempty"` + Source ManifestSource `json:"source"` + Operation string `json:"operation"` + RequestTimestamp metav1.Time `json:"requestTimestamp,omitempty"` +} + +type WingJobStatus struct { + Messages string `json:"messages,omitempty"` + ExitCode int `json:"exitCode,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type WingJobList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []WingJob `json:"items"` +} diff --git a/pkg/wing/client/typed/wing/v1alpha1/fake/fake_puppettarget.go b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_puppettarget.go new file mode 100644 index 0000000000..7e46f30ae9 --- /dev/null +++ b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_puppettarget.go @@ -0,0 +1,111 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package fake + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/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" +) + +// FakePuppetTargets implements PuppetTargetInterface +type FakePuppetTargets struct { + Fake *FakeWingV1alpha1 + ns string +} + +var puppettargetsResource = schema.GroupVersionResource{Group: "wing.tarmak.io", Version: "v1alpha1", Resource: "puppettargets"} + +var puppettargetsKind = schema.GroupVersionKind{Group: "wing.tarmak.io", Version: "v1alpha1", Kind: "PuppetTarget"} + +// Get takes name of the puppetTarget, and returns the corresponding puppetTarget object, and an error if there is any. +func (c *FakePuppetTargets) Get(name string, options v1.GetOptions) (result *v1alpha1.PuppetTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(puppettargetsResource, c.ns, name), &v1alpha1.PuppetTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PuppetTarget), err +} + +// List takes label and field selectors, and returns the list of PuppetTargets that match those selectors. +func (c *FakePuppetTargets) List(opts v1.ListOptions) (result *v1alpha1.PuppetTargetList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(puppettargetsResource, puppettargetsKind, c.ns, opts), &v1alpha1.PuppetTargetList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PuppetTargetList{} + for _, item := range obj.(*v1alpha1.PuppetTargetList).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 puppetTargets. +func (c *FakePuppetTargets) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(puppettargetsResource, c.ns, opts)) + +} + +// Create takes the representation of a puppetTarget and creates it. Returns the server's representation of the puppetTarget, and an error, if there is any. +func (c *FakePuppetTargets) Create(puppetTarget *v1alpha1.PuppetTarget) (result *v1alpha1.PuppetTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(puppettargetsResource, c.ns, puppetTarget), &v1alpha1.PuppetTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PuppetTarget), err +} + +// Update takes the representation of a puppetTarget and updates it. Returns the server's representation of the puppetTarget, and an error, if there is any. +func (c *FakePuppetTargets) Update(puppetTarget *v1alpha1.PuppetTarget) (result *v1alpha1.PuppetTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(puppettargetsResource, c.ns, puppetTarget), &v1alpha1.PuppetTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PuppetTarget), err +} + +// Delete takes name of the puppetTarget and deletes it. Returns an error if one occurs. +func (c *FakePuppetTargets) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(puppettargetsResource, c.ns, name), &v1alpha1.PuppetTarget{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePuppetTargets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(puppettargetsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.PuppetTargetList{}) + return err +} + +// Patch applies the patch and returns the patched puppetTarget. +func (c *FakePuppetTargets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PuppetTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(puppettargetsResource, c.ns, name, data, subresources...), &v1alpha1.PuppetTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PuppetTarget), err +} diff --git a/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wing_client.go b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wing_client.go index fb5e35924e..46d5b7ee24 100644 --- a/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wing_client.go +++ b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wing_client.go @@ -15,6 +15,14 @@ func (c *FakeWingV1alpha1) Instances(namespace string) v1alpha1.InstanceInterfac return &FakeInstances{c, namespace} } +func (c *FakeWingV1alpha1) PuppetTargets(namespace string) v1alpha1.PuppetTargetInterface { + return &FakePuppetTargets{c, namespace} +} + +func (c *FakeWingV1alpha1) WingJobs(namespace string) v1alpha1.WingJobInterface { + return &FakeWingJobs{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeWingV1alpha1) RESTClient() rest.Interface { diff --git a/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wingjob.go b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wingjob.go new file mode 100644 index 0000000000..37226b76b0 --- /dev/null +++ b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wingjob.go @@ -0,0 +1,123 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package fake + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/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" +) + +// FakeWingJobs implements WingJobInterface +type FakeWingJobs struct { + Fake *FakeWingV1alpha1 + ns string +} + +var wingjobsResource = schema.GroupVersionResource{Group: "wing.tarmak.io", Version: "v1alpha1", Resource: "wingjobs"} + +var wingjobsKind = schema.GroupVersionKind{Group: "wing.tarmak.io", Version: "v1alpha1", Kind: "WingJob"} + +// Get takes name of the wingJob, and returns the corresponding wingJob object, and an error if there is any. +func (c *FakeWingJobs) Get(name string, options v1.GetOptions) (result *v1alpha1.WingJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(wingjobsResource, c.ns, name), &v1alpha1.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WingJob), err +} + +// List takes label and field selectors, and returns the list of WingJobs that match those selectors. +func (c *FakeWingJobs) List(opts v1.ListOptions) (result *v1alpha1.WingJobList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(wingjobsResource, wingjobsKind, c.ns, opts), &v1alpha1.WingJobList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.WingJobList{} + for _, item := range obj.(*v1alpha1.WingJobList).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 wingJobs. +func (c *FakeWingJobs) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(wingjobsResource, c.ns, opts)) + +} + +// Create takes the representation of a wingJob and creates it. Returns the server's representation of the wingJob, and an error, if there is any. +func (c *FakeWingJobs) Create(wingJob *v1alpha1.WingJob) (result *v1alpha1.WingJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(wingjobsResource, c.ns, wingJob), &v1alpha1.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WingJob), err +} + +// Update takes the representation of a wingJob and updates it. Returns the server's representation of the wingJob, and an error, if there is any. +func (c *FakeWingJobs) Update(wingJob *v1alpha1.WingJob) (result *v1alpha1.WingJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(wingjobsResource, c.ns, wingJob), &v1alpha1.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WingJob), 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 *FakeWingJobs) UpdateStatus(wingJob *v1alpha1.WingJob) (*v1alpha1.WingJob, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(wingjobsResource, "status", c.ns, wingJob), &v1alpha1.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WingJob), err +} + +// Delete takes name of the wingJob and deletes it. Returns an error if one occurs. +func (c *FakeWingJobs) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(wingjobsResource, c.ns, name), &v1alpha1.WingJob{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeWingJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(wingjobsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.WingJobList{}) + return err +} + +// Patch applies the patch and returns the patched wingJob. +func (c *FakeWingJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.WingJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(wingjobsResource, c.ns, name, data, subresources...), &v1alpha1.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WingJob), err +} diff --git a/pkg/wing/client/typed/wing/v1alpha1/generated_expansion.go b/pkg/wing/client/typed/wing/v1alpha1/generated_expansion.go index 74e0c14501..e928046b23 100644 --- a/pkg/wing/client/typed/wing/v1alpha1/generated_expansion.go +++ b/pkg/wing/client/typed/wing/v1alpha1/generated_expansion.go @@ -2,3 +2,7 @@ package v1alpha1 type InstanceExpansion interface{} + +type PuppetTargetExpansion interface{} + +type WingJobExpansion interface{} diff --git a/pkg/wing/client/typed/wing/v1alpha1/puppettarget.go b/pkg/wing/client/typed/wing/v1alpha1/puppettarget.go new file mode 100644 index 0000000000..0e52a368bb --- /dev/null +++ b/pkg/wing/client/typed/wing/v1alpha1/puppettarget.go @@ -0,0 +1,140 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package v1alpha1 + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + scheme "github.com/jetstack/tarmak/pkg/wing/client/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" +) + +// PuppetTargetsGetter has a method to return a PuppetTargetInterface. +// A group's client should implement this interface. +type PuppetTargetsGetter interface { + PuppetTargets(namespace string) PuppetTargetInterface +} + +// PuppetTargetInterface has methods to work with PuppetTarget resources. +type PuppetTargetInterface interface { + Create(*v1alpha1.PuppetTarget) (*v1alpha1.PuppetTarget, error) + Update(*v1alpha1.PuppetTarget) (*v1alpha1.PuppetTarget, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.PuppetTarget, error) + List(opts v1.ListOptions) (*v1alpha1.PuppetTargetList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PuppetTarget, err error) + PuppetTargetExpansion +} + +// puppetTargets implements PuppetTargetInterface +type puppetTargets struct { + client rest.Interface + ns string +} + +// newPuppetTargets returns a PuppetTargets +func newPuppetTargets(c *WingV1alpha1Client, namespace string) *puppetTargets { + return &puppetTargets{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the puppetTarget, and returns the corresponding puppetTarget object, and an error if there is any. +func (c *puppetTargets) Get(name string, options v1.GetOptions) (result *v1alpha1.PuppetTarget, err error) { + result = &v1alpha1.PuppetTarget{} + err = c.client.Get(). + Namespace(c.ns). + Resource("puppettargets"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PuppetTargets that match those selectors. +func (c *puppetTargets) List(opts v1.ListOptions) (result *v1alpha1.PuppetTargetList, err error) { + result = &v1alpha1.PuppetTargetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("puppettargets"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested puppetTargets. +func (c *puppetTargets) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("puppettargets"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a puppetTarget and creates it. Returns the server's representation of the puppetTarget, and an error, if there is any. +func (c *puppetTargets) Create(puppetTarget *v1alpha1.PuppetTarget) (result *v1alpha1.PuppetTarget, err error) { + result = &v1alpha1.PuppetTarget{} + err = c.client.Post(). + Namespace(c.ns). + Resource("puppettargets"). + Body(puppetTarget). + Do(). + Into(result) + return +} + +// Update takes the representation of a puppetTarget and updates it. Returns the server's representation of the puppetTarget, and an error, if there is any. +func (c *puppetTargets) Update(puppetTarget *v1alpha1.PuppetTarget) (result *v1alpha1.PuppetTarget, err error) { + result = &v1alpha1.PuppetTarget{} + err = c.client.Put(). + Namespace(c.ns). + Resource("puppettargets"). + Name(puppetTarget.Name). + Body(puppetTarget). + Do(). + Into(result) + return +} + +// Delete takes name of the puppetTarget and deletes it. Returns an error if one occurs. +func (c *puppetTargets) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("puppettargets"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *puppetTargets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("puppettargets"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched puppetTarget. +func (c *puppetTargets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PuppetTarget, err error) { + result = &v1alpha1.PuppetTarget{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("puppettargets"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/wing/client/typed/wing/v1alpha1/wing_client.go b/pkg/wing/client/typed/wing/v1alpha1/wing_client.go index 685a61914c..4bb319c657 100644 --- a/pkg/wing/client/typed/wing/v1alpha1/wing_client.go +++ b/pkg/wing/client/typed/wing/v1alpha1/wing_client.go @@ -11,6 +11,8 @@ import ( type WingV1alpha1Interface interface { RESTClient() rest.Interface InstancesGetter + PuppetTargetsGetter + WingJobsGetter } // WingV1alpha1Client is used to interact with features provided by the wing.tarmak.io group. @@ -22,6 +24,14 @@ func (c *WingV1alpha1Client) Instances(namespace string) InstanceInterface { return newInstances(c, namespace) } +func (c *WingV1alpha1Client) PuppetTargets(namespace string) PuppetTargetInterface { + return newPuppetTargets(c, namespace) +} + +func (c *WingV1alpha1Client) WingJobs(namespace string) WingJobInterface { + return newWingJobs(c, namespace) +} + // NewForConfig creates a new WingV1alpha1Client for the given config. func NewForConfig(c *rest.Config) (*WingV1alpha1Client, error) { config := *c diff --git a/pkg/wing/client/typed/wing/v1alpha1/wingjob.go b/pkg/wing/client/typed/wing/v1alpha1/wingjob.go new file mode 100644 index 0000000000..4d5829c610 --- /dev/null +++ b/pkg/wing/client/typed/wing/v1alpha1/wingjob.go @@ -0,0 +1,157 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package v1alpha1 + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + scheme "github.com/jetstack/tarmak/pkg/wing/client/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" +) + +// WingJobsGetter has a method to return a WingJobInterface. +// A group's client should implement this interface. +type WingJobsGetter interface { + WingJobs(namespace string) WingJobInterface +} + +// WingJobInterface has methods to work with WingJob resources. +type WingJobInterface interface { + Create(*v1alpha1.WingJob) (*v1alpha1.WingJob, error) + Update(*v1alpha1.WingJob) (*v1alpha1.WingJob, error) + UpdateStatus(*v1alpha1.WingJob) (*v1alpha1.WingJob, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.WingJob, error) + List(opts v1.ListOptions) (*v1alpha1.WingJobList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.WingJob, err error) + WingJobExpansion +} + +// wingJobs implements WingJobInterface +type wingJobs struct { + client rest.Interface + ns string +} + +// newWingJobs returns a WingJobs +func newWingJobs(c *WingV1alpha1Client, namespace string) *wingJobs { + return &wingJobs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the wingJob, and returns the corresponding wingJob object, and an error if there is any. +func (c *wingJobs) Get(name string, options v1.GetOptions) (result *v1alpha1.WingJob, err error) { + result = &v1alpha1.WingJob{} + err = c.client.Get(). + Namespace(c.ns). + Resource("wingjobs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of WingJobs that match those selectors. +func (c *wingJobs) List(opts v1.ListOptions) (result *v1alpha1.WingJobList, err error) { + result = &v1alpha1.WingJobList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("wingjobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested wingJobs. +func (c *wingJobs) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("wingjobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a wingJob and creates it. Returns the server's representation of the wingJob, and an error, if there is any. +func (c *wingJobs) Create(wingJob *v1alpha1.WingJob) (result *v1alpha1.WingJob, err error) { + result = &v1alpha1.WingJob{} + err = c.client.Post(). + Namespace(c.ns). + Resource("wingjobs"). + Body(wingJob). + Do(). + Into(result) + return +} + +// Update takes the representation of a wingJob and updates it. Returns the server's representation of the wingJob, and an error, if there is any. +func (c *wingJobs) Update(wingJob *v1alpha1.WingJob) (result *v1alpha1.WingJob, err error) { + result = &v1alpha1.WingJob{} + err = c.client.Put(). + Namespace(c.ns). + Resource("wingjobs"). + Name(wingJob.Name). + Body(wingJob). + 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 *wingJobs) UpdateStatus(wingJob *v1alpha1.WingJob) (result *v1alpha1.WingJob, err error) { + result = &v1alpha1.WingJob{} + err = c.client.Put(). + Namespace(c.ns). + Resource("wingjobs"). + Name(wingJob.Name). + SubResource("status"). + Body(wingJob). + Do(). + Into(result) + return +} + +// Delete takes name of the wingJob and deletes it. Returns an error if one occurs. +func (c *wingJobs) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("wingjobs"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *wingJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("wingjobs"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched wingJob. +func (c *wingJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.WingJob, err error) { + result = &v1alpha1.WingJob{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("wingjobs"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_puppettarget.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_puppettarget.go new file mode 100644 index 0000000000..5d8c19945e --- /dev/null +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_puppettarget.go @@ -0,0 +1,111 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package fake + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + 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" +) + +// FakePuppetTargets implements PuppetTargetInterface +type FakePuppetTargets struct { + Fake *FakeWing + ns string +} + +var puppettargetsResource = schema.GroupVersionResource{Group: "wing.tarmak.io", Version: "", Resource: "puppettargets"} + +var puppettargetsKind = schema.GroupVersionKind{Group: "wing.tarmak.io", Version: "", Kind: "PuppetTarget"} + +// Get takes name of the puppetTarget, and returns the corresponding puppetTarget object, and an error if there is any. +func (c *FakePuppetTargets) Get(name string, options v1.GetOptions) (result *wing.PuppetTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(puppettargetsResource, c.ns, name), &wing.PuppetTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.PuppetTarget), err +} + +// List takes label and field selectors, and returns the list of PuppetTargets that match those selectors. +func (c *FakePuppetTargets) List(opts v1.ListOptions) (result *wing.PuppetTargetList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(puppettargetsResource, puppettargetsKind, c.ns, opts), &wing.PuppetTargetList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &wing.PuppetTargetList{} + for _, item := range obj.(*wing.PuppetTargetList).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 puppetTargets. +func (c *FakePuppetTargets) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(puppettargetsResource, c.ns, opts)) + +} + +// Create takes the representation of a puppetTarget and creates it. Returns the server's representation of the puppetTarget, and an error, if there is any. +func (c *FakePuppetTargets) Create(puppetTarget *wing.PuppetTarget) (result *wing.PuppetTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(puppettargetsResource, c.ns, puppetTarget), &wing.PuppetTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.PuppetTarget), err +} + +// Update takes the representation of a puppetTarget and updates it. Returns the server's representation of the puppetTarget, and an error, if there is any. +func (c *FakePuppetTargets) Update(puppetTarget *wing.PuppetTarget) (result *wing.PuppetTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(puppettargetsResource, c.ns, puppetTarget), &wing.PuppetTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.PuppetTarget), err +} + +// Delete takes name of the puppetTarget and deletes it. Returns an error if one occurs. +func (c *FakePuppetTargets) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(puppettargetsResource, c.ns, name), &wing.PuppetTarget{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePuppetTargets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(puppettargetsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &wing.PuppetTargetList{}) + return err +} + +// Patch applies the patch and returns the patched puppetTarget. +func (c *FakePuppetTargets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.PuppetTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(puppettargetsResource, c.ns, name, data, subresources...), &wing.PuppetTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.PuppetTarget), err +} diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wing_client.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wing_client.go index 790af780af..7680d27f60 100644 --- a/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wing_client.go +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wing_client.go @@ -15,6 +15,14 @@ func (c *FakeWing) Instances(namespace string) internalversion.InstanceInterface return &FakeInstances{c, namespace} } +func (c *FakeWing) PuppetTargets(namespace string) internalversion.PuppetTargetInterface { + return &FakePuppetTargets{c, namespace} +} + +func (c *FakeWing) WingJobs(namespace string) internalversion.WingJobInterface { + return &FakeWingJobs{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeWing) RESTClient() rest.Interface { diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wingjob.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wingjob.go new file mode 100644 index 0000000000..02798dcd82 --- /dev/null +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wingjob.go @@ -0,0 +1,123 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package fake + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + 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" +) + +// FakeWingJobs implements WingJobInterface +type FakeWingJobs struct { + Fake *FakeWing + ns string +} + +var wingjobsResource = schema.GroupVersionResource{Group: "wing.tarmak.io", Version: "", Resource: "wingjobs"} + +var wingjobsKind = schema.GroupVersionKind{Group: "wing.tarmak.io", Version: "", Kind: "WingJob"} + +// Get takes name of the wingJob, and returns the corresponding wingJob object, and an error if there is any. +func (c *FakeWingJobs) Get(name string, options v1.GetOptions) (result *wing.WingJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(wingjobsResource, c.ns, name), &wing.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.WingJob), err +} + +// List takes label and field selectors, and returns the list of WingJobs that match those selectors. +func (c *FakeWingJobs) List(opts v1.ListOptions) (result *wing.WingJobList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(wingjobsResource, wingjobsKind, c.ns, opts), &wing.WingJobList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &wing.WingJobList{} + for _, item := range obj.(*wing.WingJobList).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 wingJobs. +func (c *FakeWingJobs) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(wingjobsResource, c.ns, opts)) + +} + +// Create takes the representation of a wingJob and creates it. Returns the server's representation of the wingJob, and an error, if there is any. +func (c *FakeWingJobs) Create(wingJob *wing.WingJob) (result *wing.WingJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(wingjobsResource, c.ns, wingJob), &wing.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.WingJob), err +} + +// Update takes the representation of a wingJob and updates it. Returns the server's representation of the wingJob, and an error, if there is any. +func (c *FakeWingJobs) Update(wingJob *wing.WingJob) (result *wing.WingJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(wingjobsResource, c.ns, wingJob), &wing.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.WingJob), 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 *FakeWingJobs) UpdateStatus(wingJob *wing.WingJob) (*wing.WingJob, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(wingjobsResource, "status", c.ns, wingJob), &wing.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.WingJob), err +} + +// Delete takes name of the wingJob and deletes it. Returns an error if one occurs. +func (c *FakeWingJobs) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(wingjobsResource, c.ns, name), &wing.WingJob{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeWingJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(wingjobsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &wing.WingJobList{}) + return err +} + +// Patch applies the patch and returns the patched wingJob. +func (c *FakeWingJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.WingJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(wingjobsResource, c.ns, name, data, subresources...), &wing.WingJob{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.WingJob), err +} diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/generated_expansion.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/generated_expansion.go index 95e2524747..8684f6f1ce 100644 --- a/pkg/wing/clients/internalclientset/typed/wing/internalversion/generated_expansion.go +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/generated_expansion.go @@ -2,3 +2,7 @@ package internalversion type InstanceExpansion interface{} + +type PuppetTargetExpansion interface{} + +type WingJobExpansion interface{} diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/puppettarget.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/puppettarget.go new file mode 100644 index 0000000000..a6767289ae --- /dev/null +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/puppettarget.go @@ -0,0 +1,140 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + scheme "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset/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" +) + +// PuppetTargetsGetter has a method to return a PuppetTargetInterface. +// A group's client should implement this interface. +type PuppetTargetsGetter interface { + PuppetTargets(namespace string) PuppetTargetInterface +} + +// PuppetTargetInterface has methods to work with PuppetTarget resources. +type PuppetTargetInterface interface { + Create(*wing.PuppetTarget) (*wing.PuppetTarget, error) + Update(*wing.PuppetTarget) (*wing.PuppetTarget, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*wing.PuppetTarget, error) + List(opts v1.ListOptions) (*wing.PuppetTargetList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.PuppetTarget, err error) + PuppetTargetExpansion +} + +// puppetTargets implements PuppetTargetInterface +type puppetTargets struct { + client rest.Interface + ns string +} + +// newPuppetTargets returns a PuppetTargets +func newPuppetTargets(c *WingClient, namespace string) *puppetTargets { + return &puppetTargets{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the puppetTarget, and returns the corresponding puppetTarget object, and an error if there is any. +func (c *puppetTargets) Get(name string, options v1.GetOptions) (result *wing.PuppetTarget, err error) { + result = &wing.PuppetTarget{} + err = c.client.Get(). + Namespace(c.ns). + Resource("puppettargets"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PuppetTargets that match those selectors. +func (c *puppetTargets) List(opts v1.ListOptions) (result *wing.PuppetTargetList, err error) { + result = &wing.PuppetTargetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("puppettargets"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested puppetTargets. +func (c *puppetTargets) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("puppettargets"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a puppetTarget and creates it. Returns the server's representation of the puppetTarget, and an error, if there is any. +func (c *puppetTargets) Create(puppetTarget *wing.PuppetTarget) (result *wing.PuppetTarget, err error) { + result = &wing.PuppetTarget{} + err = c.client.Post(). + Namespace(c.ns). + Resource("puppettargets"). + Body(puppetTarget). + Do(). + Into(result) + return +} + +// Update takes the representation of a puppetTarget and updates it. Returns the server's representation of the puppetTarget, and an error, if there is any. +func (c *puppetTargets) Update(puppetTarget *wing.PuppetTarget) (result *wing.PuppetTarget, err error) { + result = &wing.PuppetTarget{} + err = c.client.Put(). + Namespace(c.ns). + Resource("puppettargets"). + Name(puppetTarget.Name). + Body(puppetTarget). + Do(). + Into(result) + return +} + +// Delete takes name of the puppetTarget and deletes it. Returns an error if one occurs. +func (c *puppetTargets) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("puppettargets"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *puppetTargets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("puppettargets"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched puppetTarget. +func (c *puppetTargets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.PuppetTarget, err error) { + result = &wing.PuppetTarget{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("puppettargets"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/wing_client.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/wing_client.go index 90a84e4c47..0cb4e4fd4c 100644 --- a/pkg/wing/clients/internalclientset/typed/wing/internalversion/wing_client.go +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/wing_client.go @@ -9,6 +9,8 @@ import ( type WingInterface interface { RESTClient() rest.Interface InstancesGetter + PuppetTargetsGetter + WingJobsGetter } // WingClient is used to interact with features provided by the wing.tarmak.io group. @@ -20,6 +22,14 @@ func (c *WingClient) Instances(namespace string) InstanceInterface { return newInstances(c, namespace) } +func (c *WingClient) PuppetTargets(namespace string) PuppetTargetInterface { + return newPuppetTargets(c, namespace) +} + +func (c *WingClient) WingJobs(namespace string) WingJobInterface { + return newWingJobs(c, namespace) +} + // NewForConfig creates a new WingClient for the given config. func NewForConfig(c *rest.Config) (*WingClient, error) { config := *c diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/wingjob.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/wingjob.go new file mode 100644 index 0000000000..d37205a4fc --- /dev/null +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/wingjob.go @@ -0,0 +1,157 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + scheme "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset/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" +) + +// WingJobsGetter has a method to return a WingJobInterface. +// A group's client should implement this interface. +type WingJobsGetter interface { + WingJobs(namespace string) WingJobInterface +} + +// WingJobInterface has methods to work with WingJob resources. +type WingJobInterface interface { + Create(*wing.WingJob) (*wing.WingJob, error) + Update(*wing.WingJob) (*wing.WingJob, error) + UpdateStatus(*wing.WingJob) (*wing.WingJob, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*wing.WingJob, error) + List(opts v1.ListOptions) (*wing.WingJobList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.WingJob, err error) + WingJobExpansion +} + +// wingJobs implements WingJobInterface +type wingJobs struct { + client rest.Interface + ns string +} + +// newWingJobs returns a WingJobs +func newWingJobs(c *WingClient, namespace string) *wingJobs { + return &wingJobs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the wingJob, and returns the corresponding wingJob object, and an error if there is any. +func (c *wingJobs) Get(name string, options v1.GetOptions) (result *wing.WingJob, err error) { + result = &wing.WingJob{} + err = c.client.Get(). + Namespace(c.ns). + Resource("wingjobs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of WingJobs that match those selectors. +func (c *wingJobs) List(opts v1.ListOptions) (result *wing.WingJobList, err error) { + result = &wing.WingJobList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("wingjobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested wingJobs. +func (c *wingJobs) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("wingjobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a wingJob and creates it. Returns the server's representation of the wingJob, and an error, if there is any. +func (c *wingJobs) Create(wingJob *wing.WingJob) (result *wing.WingJob, err error) { + result = &wing.WingJob{} + err = c.client.Post(). + Namespace(c.ns). + Resource("wingjobs"). + Body(wingJob). + Do(). + Into(result) + return +} + +// Update takes the representation of a wingJob and updates it. Returns the server's representation of the wingJob, and an error, if there is any. +func (c *wingJobs) Update(wingJob *wing.WingJob) (result *wing.WingJob, err error) { + result = &wing.WingJob{} + err = c.client.Put(). + Namespace(c.ns). + Resource("wingjobs"). + Name(wingJob.Name). + Body(wingJob). + 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 *wingJobs) UpdateStatus(wingJob *wing.WingJob) (result *wing.WingJob, err error) { + result = &wing.WingJob{} + err = c.client.Put(). + Namespace(c.ns). + Resource("wingjobs"). + Name(wingJob.Name). + SubResource("status"). + Body(wingJob). + Do(). + Into(result) + return +} + +// Delete takes name of the wingJob and deletes it. Returns an error if one occurs. +func (c *wingJobs) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("wingjobs"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *wingJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("wingjobs"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched wingJob. +func (c *wingJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.WingJob, err error) { + result = &wing.WingJob{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("wingjobs"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/wing/informers/externalversions/generic.go b/pkg/wing/informers/externalversions/generic.go index 42d5bf9f58..78b15575b0 100644 --- a/pkg/wing/informers/externalversions/generic.go +++ b/pkg/wing/informers/externalversions/generic.go @@ -40,6 +40,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=wing.tarmak.io, Version=v1alpha1 case v1alpha1.SchemeGroupVersion.WithResource("instances"): return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().V1alpha1().Instances().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("puppettargets"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().V1alpha1().PuppetTargets().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("wingjobs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().V1alpha1().WingJobs().Informer()}, nil } diff --git a/pkg/wing/informers/externalversions/wing/v1alpha1/interface.go b/pkg/wing/informers/externalversions/wing/v1alpha1/interface.go index 66807cc9ef..57bdac5c1c 100644 --- a/pkg/wing/informers/externalversions/wing/v1alpha1/interface.go +++ b/pkg/wing/informers/externalversions/wing/v1alpha1/interface.go @@ -12,6 +12,10 @@ import ( type Interface interface { // Instances returns a InstanceInformer. Instances() InstanceInformer + // PuppetTargets returns a PuppetTargetInformer. + PuppetTargets() PuppetTargetInformer + // WingJobs returns a WingJobInformer. + WingJobs() WingJobInformer } type version struct { @@ -29,3 +33,13 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (v *version) Instances() InstanceInformer { return &instanceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } + +// PuppetTargets returns a PuppetTargetInformer. +func (v *version) PuppetTargets() PuppetTargetInformer { + return &puppetTargetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// WingJobs returns a WingJobInformer. +func (v *version) WingJobs() WingJobInformer { + return &wingJobInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/wing/informers/externalversions/wing/v1alpha1/puppettarget.go b/pkg/wing/informers/externalversions/wing/v1alpha1/puppettarget.go new file mode 100644 index 0000000000..48fb849c6b --- /dev/null +++ b/pkg/wing/informers/externalversions/wing/v1alpha1/puppettarget.go @@ -0,0 +1,74 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by informer-gen + +package v1alpha1 + +import ( + wing_v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + client "github.com/jetstack/tarmak/pkg/wing/client" + internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/jetstack/tarmak/pkg/wing/listers/wing/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" + time "time" +) + +// PuppetTargetInformer provides access to a shared informer and lister for +// PuppetTargets. +type PuppetTargetInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PuppetTargetLister +} + +type puppetTargetInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPuppetTargetInformer constructs a new informer for PuppetTarget 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 NewPuppetTargetInformer(client client.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPuppetTargetInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPuppetTargetInformer constructs a new informer for PuppetTarget 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 NewFilteredPuppetTargetInformer(client client.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.WingV1alpha1().PuppetTargets(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.WingV1alpha1().PuppetTargets(namespace).Watch(options) + }, + }, + &wing_v1alpha1.PuppetTarget{}, + resyncPeriod, + indexers, + ) +} + +func (f *puppetTargetInformer) defaultInformer(client client.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPuppetTargetInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *puppetTargetInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&wing_v1alpha1.PuppetTarget{}, f.defaultInformer) +} + +func (f *puppetTargetInformer) Lister() v1alpha1.PuppetTargetLister { + return v1alpha1.NewPuppetTargetLister(f.Informer().GetIndexer()) +} diff --git a/pkg/wing/informers/externalversions/wing/v1alpha1/wingjob.go b/pkg/wing/informers/externalversions/wing/v1alpha1/wingjob.go new file mode 100644 index 0000000000..228c44ec49 --- /dev/null +++ b/pkg/wing/informers/externalversions/wing/v1alpha1/wingjob.go @@ -0,0 +1,74 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by informer-gen + +package v1alpha1 + +import ( + wing_v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + client "github.com/jetstack/tarmak/pkg/wing/client" + internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/jetstack/tarmak/pkg/wing/listers/wing/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" + time "time" +) + +// WingJobInformer provides access to a shared informer and lister for +// WingJobs. +type WingJobInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.WingJobLister +} + +type wingJobInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewWingJobInformer constructs a new informer for WingJob 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 NewWingJobInformer(client client.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredWingJobInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredWingJobInformer constructs a new informer for WingJob 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 NewFilteredWingJobInformer(client client.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.WingV1alpha1().WingJobs(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.WingV1alpha1().WingJobs(namespace).Watch(options) + }, + }, + &wing_v1alpha1.WingJob{}, + resyncPeriod, + indexers, + ) +} + +func (f *wingJobInformer) defaultInformer(client client.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredWingJobInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *wingJobInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&wing_v1alpha1.WingJob{}, f.defaultInformer) +} + +func (f *wingJobInformer) Lister() v1alpha1.WingJobLister { + return v1alpha1.NewWingJobLister(f.Informer().GetIndexer()) +} diff --git a/pkg/wing/informers/internalversion/generic.go b/pkg/wing/informers/internalversion/generic.go index bc2e902c07..27a673f67d 100644 --- a/pkg/wing/informers/internalversion/generic.go +++ b/pkg/wing/informers/internalversion/generic.go @@ -40,6 +40,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=wing.tarmak.io, Version=internalVersion case wing.SchemeGroupVersion.WithResource("instances"): return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().InternalVersion().Instances().Informer()}, nil + case wing.SchemeGroupVersion.WithResource("puppettargets"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().InternalVersion().PuppetTargets().Informer()}, nil + case wing.SchemeGroupVersion.WithResource("wingjobs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().InternalVersion().WingJobs().Informer()}, nil } diff --git a/pkg/wing/informers/internalversion/wing/internalversion/interface.go b/pkg/wing/informers/internalversion/wing/internalversion/interface.go index 7078eb7bef..7e0b0a1359 100644 --- a/pkg/wing/informers/internalversion/wing/internalversion/interface.go +++ b/pkg/wing/informers/internalversion/wing/internalversion/interface.go @@ -12,6 +12,10 @@ import ( type Interface interface { // Instances returns a InstanceInformer. Instances() InstanceInformer + // PuppetTargets returns a PuppetTargetInformer. + PuppetTargets() PuppetTargetInformer + // WingJobs returns a WingJobInformer. + WingJobs() WingJobInformer } type version struct { @@ -29,3 +33,13 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (v *version) Instances() InstanceInformer { return &instanceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } + +// PuppetTargets returns a PuppetTargetInformer. +func (v *version) PuppetTargets() PuppetTargetInformer { + return &puppetTargetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// WingJobs returns a WingJobInformer. +func (v *version) WingJobs() WingJobInformer { + return &wingJobInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/wing/informers/internalversion/wing/internalversion/puppettarget.go b/pkg/wing/informers/internalversion/wing/internalversion/puppettarget.go new file mode 100644 index 0000000000..22f4fbcd12 --- /dev/null +++ b/pkg/wing/informers/internalversion/wing/internalversion/puppettarget.go @@ -0,0 +1,74 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + internalclientset "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset" + internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/internalversion/internalinterfaces" + internalversion "github.com/jetstack/tarmak/pkg/wing/listers/wing/internalversion" + 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" + time "time" +) + +// PuppetTargetInformer provides access to a shared informer and lister for +// PuppetTargets. +type PuppetTargetInformer interface { + Informer() cache.SharedIndexInformer + Lister() internalversion.PuppetTargetLister +} + +type puppetTargetInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPuppetTargetInformer constructs a new informer for PuppetTarget 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 NewPuppetTargetInformer(client internalclientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPuppetTargetInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPuppetTargetInformer constructs a new informer for PuppetTarget 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 NewFilteredPuppetTargetInformer(client internalclientset.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.Wing().PuppetTargets(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.Wing().PuppetTargets(namespace).Watch(options) + }, + }, + &wing.PuppetTarget{}, + resyncPeriod, + indexers, + ) +} + +func (f *puppetTargetInformer) defaultInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPuppetTargetInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *puppetTargetInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&wing.PuppetTarget{}, f.defaultInformer) +} + +func (f *puppetTargetInformer) Lister() internalversion.PuppetTargetLister { + return internalversion.NewPuppetTargetLister(f.Informer().GetIndexer()) +} diff --git a/pkg/wing/informers/internalversion/wing/internalversion/wingjob.go b/pkg/wing/informers/internalversion/wing/internalversion/wingjob.go new file mode 100644 index 0000000000..178458ca9f --- /dev/null +++ b/pkg/wing/informers/internalversion/wing/internalversion/wingjob.go @@ -0,0 +1,74 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + internalclientset "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset" + internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/internalversion/internalinterfaces" + internalversion "github.com/jetstack/tarmak/pkg/wing/listers/wing/internalversion" + 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" + time "time" +) + +// WingJobInformer provides access to a shared informer and lister for +// WingJobs. +type WingJobInformer interface { + Informer() cache.SharedIndexInformer + Lister() internalversion.WingJobLister +} + +type wingJobInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewWingJobInformer constructs a new informer for WingJob 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 NewWingJobInformer(client internalclientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredWingJobInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredWingJobInformer constructs a new informer for WingJob 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 NewFilteredWingJobInformer(client internalclientset.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.Wing().WingJobs(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.Wing().WingJobs(namespace).Watch(options) + }, + }, + &wing.WingJob{}, + resyncPeriod, + indexers, + ) +} + +func (f *wingJobInformer) defaultInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredWingJobInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *wingJobInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&wing.WingJob{}, f.defaultInformer) +} + +func (f *wingJobInformer) Lister() internalversion.WingJobLister { + return internalversion.NewWingJobLister(f.Informer().GetIndexer()) +} diff --git a/pkg/wing/listers/wing/internalversion/expansion_generated.go b/pkg/wing/listers/wing/internalversion/expansion_generated.go index a74252d677..c7d63398b9 100644 --- a/pkg/wing/listers/wing/internalversion/expansion_generated.go +++ b/pkg/wing/listers/wing/internalversion/expansion_generated.go @@ -11,3 +11,19 @@ type InstanceListerExpansion interface{} // InstanceNamespaceListerExpansion allows custom methods to be added to // InstanceNamespaceLister. type InstanceNamespaceListerExpansion interface{} + +// PuppetTargetListerExpansion allows custom methods to be added to +// PuppetTargetLister. +type PuppetTargetListerExpansion interface{} + +// PuppetTargetNamespaceListerExpansion allows custom methods to be added to +// PuppetTargetNamespaceLister. +type PuppetTargetNamespaceListerExpansion interface{} + +// WingJobListerExpansion allows custom methods to be added to +// WingJobLister. +type WingJobListerExpansion interface{} + +// WingJobNamespaceListerExpansion allows custom methods to be added to +// WingJobNamespaceLister. +type WingJobNamespaceListerExpansion interface{} diff --git a/pkg/wing/listers/wing/internalversion/puppettarget.go b/pkg/wing/listers/wing/internalversion/puppettarget.go new file mode 100644 index 0000000000..b24126b756 --- /dev/null +++ b/pkg/wing/listers/wing/internalversion/puppettarget.go @@ -0,0 +1,80 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by lister-gen + +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PuppetTargetLister helps list PuppetTargets. +type PuppetTargetLister interface { + // List lists all PuppetTargets in the indexer. + List(selector labels.Selector) (ret []*wing.PuppetTarget, err error) + // PuppetTargets returns an object that can list and get PuppetTargets. + PuppetTargets(namespace string) PuppetTargetNamespaceLister + PuppetTargetListerExpansion +} + +// puppetTargetLister implements the PuppetTargetLister interface. +type puppetTargetLister struct { + indexer cache.Indexer +} + +// NewPuppetTargetLister returns a new PuppetTargetLister. +func NewPuppetTargetLister(indexer cache.Indexer) PuppetTargetLister { + return &puppetTargetLister{indexer: indexer} +} + +// List lists all PuppetTargets in the indexer. +func (s *puppetTargetLister) List(selector labels.Selector) (ret []*wing.PuppetTarget, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*wing.PuppetTarget)) + }) + return ret, err +} + +// PuppetTargets returns an object that can list and get PuppetTargets. +func (s *puppetTargetLister) PuppetTargets(namespace string) PuppetTargetNamespaceLister { + return puppetTargetNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PuppetTargetNamespaceLister helps list and get PuppetTargets. +type PuppetTargetNamespaceLister interface { + // List lists all PuppetTargets in the indexer for a given namespace. + List(selector labels.Selector) (ret []*wing.PuppetTarget, err error) + // Get retrieves the PuppetTarget from the indexer for a given namespace and name. + Get(name string) (*wing.PuppetTarget, error) + PuppetTargetNamespaceListerExpansion +} + +// puppetTargetNamespaceLister implements the PuppetTargetNamespaceLister +// interface. +type puppetTargetNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PuppetTargets in the indexer for a given namespace. +func (s puppetTargetNamespaceLister) List(selector labels.Selector) (ret []*wing.PuppetTarget, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*wing.PuppetTarget)) + }) + return ret, err +} + +// Get retrieves the PuppetTarget from the indexer for a given namespace and name. +func (s puppetTargetNamespaceLister) Get(name string) (*wing.PuppetTarget, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(wing.Resource("puppettarget"), name) + } + return obj.(*wing.PuppetTarget), nil +} diff --git a/pkg/wing/listers/wing/internalversion/wingjob.go b/pkg/wing/listers/wing/internalversion/wingjob.go new file mode 100644 index 0000000000..8b0857bd1a --- /dev/null +++ b/pkg/wing/listers/wing/internalversion/wingjob.go @@ -0,0 +1,80 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by lister-gen + +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// WingJobLister helps list WingJobs. +type WingJobLister interface { + // List lists all WingJobs in the indexer. + List(selector labels.Selector) (ret []*wing.WingJob, err error) + // WingJobs returns an object that can list and get WingJobs. + WingJobs(namespace string) WingJobNamespaceLister + WingJobListerExpansion +} + +// wingJobLister implements the WingJobLister interface. +type wingJobLister struct { + indexer cache.Indexer +} + +// NewWingJobLister returns a new WingJobLister. +func NewWingJobLister(indexer cache.Indexer) WingJobLister { + return &wingJobLister{indexer: indexer} +} + +// List lists all WingJobs in the indexer. +func (s *wingJobLister) List(selector labels.Selector) (ret []*wing.WingJob, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*wing.WingJob)) + }) + return ret, err +} + +// WingJobs returns an object that can list and get WingJobs. +func (s *wingJobLister) WingJobs(namespace string) WingJobNamespaceLister { + return wingJobNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// WingJobNamespaceLister helps list and get WingJobs. +type WingJobNamespaceLister interface { + // List lists all WingJobs in the indexer for a given namespace. + List(selector labels.Selector) (ret []*wing.WingJob, err error) + // Get retrieves the WingJob from the indexer for a given namespace and name. + Get(name string) (*wing.WingJob, error) + WingJobNamespaceListerExpansion +} + +// wingJobNamespaceLister implements the WingJobNamespaceLister +// interface. +type wingJobNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all WingJobs in the indexer for a given namespace. +func (s wingJobNamespaceLister) List(selector labels.Selector) (ret []*wing.WingJob, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*wing.WingJob)) + }) + return ret, err +} + +// Get retrieves the WingJob from the indexer for a given namespace and name. +func (s wingJobNamespaceLister) Get(name string) (*wing.WingJob, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(wing.Resource("wingjob"), name) + } + return obj.(*wing.WingJob), nil +} diff --git a/pkg/wing/listers/wing/v1alpha1/expansion_generated.go b/pkg/wing/listers/wing/v1alpha1/expansion_generated.go index e3271e34c9..7ec86f6a73 100644 --- a/pkg/wing/listers/wing/v1alpha1/expansion_generated.go +++ b/pkg/wing/listers/wing/v1alpha1/expansion_generated.go @@ -11,3 +11,19 @@ type InstanceListerExpansion interface{} // InstanceNamespaceListerExpansion allows custom methods to be added to // InstanceNamespaceLister. type InstanceNamespaceListerExpansion interface{} + +// PuppetTargetListerExpansion allows custom methods to be added to +// PuppetTargetLister. +type PuppetTargetListerExpansion interface{} + +// PuppetTargetNamespaceListerExpansion allows custom methods to be added to +// PuppetTargetNamespaceLister. +type PuppetTargetNamespaceListerExpansion interface{} + +// WingJobListerExpansion allows custom methods to be added to +// WingJobLister. +type WingJobListerExpansion interface{} + +// WingJobNamespaceListerExpansion allows custom methods to be added to +// WingJobNamespaceLister. +type WingJobNamespaceListerExpansion interface{} diff --git a/pkg/wing/listers/wing/v1alpha1/puppettarget.go b/pkg/wing/listers/wing/v1alpha1/puppettarget.go new file mode 100644 index 0000000000..40ab60a7e9 --- /dev/null +++ b/pkg/wing/listers/wing/v1alpha1/puppettarget.go @@ -0,0 +1,80 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by lister-gen + +package v1alpha1 + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PuppetTargetLister helps list PuppetTargets. +type PuppetTargetLister interface { + // List lists all PuppetTargets in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.PuppetTarget, err error) + // PuppetTargets returns an object that can list and get PuppetTargets. + PuppetTargets(namespace string) PuppetTargetNamespaceLister + PuppetTargetListerExpansion +} + +// puppetTargetLister implements the PuppetTargetLister interface. +type puppetTargetLister struct { + indexer cache.Indexer +} + +// NewPuppetTargetLister returns a new PuppetTargetLister. +func NewPuppetTargetLister(indexer cache.Indexer) PuppetTargetLister { + return &puppetTargetLister{indexer: indexer} +} + +// List lists all PuppetTargets in the indexer. +func (s *puppetTargetLister) List(selector labels.Selector) (ret []*v1alpha1.PuppetTarget, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PuppetTarget)) + }) + return ret, err +} + +// PuppetTargets returns an object that can list and get PuppetTargets. +func (s *puppetTargetLister) PuppetTargets(namespace string) PuppetTargetNamespaceLister { + return puppetTargetNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PuppetTargetNamespaceLister helps list and get PuppetTargets. +type PuppetTargetNamespaceLister interface { + // List lists all PuppetTargets in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.PuppetTarget, err error) + // Get retrieves the PuppetTarget from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.PuppetTarget, error) + PuppetTargetNamespaceListerExpansion +} + +// puppetTargetNamespaceLister implements the PuppetTargetNamespaceLister +// interface. +type puppetTargetNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PuppetTargets in the indexer for a given namespace. +func (s puppetTargetNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PuppetTarget, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PuppetTarget)) + }) + return ret, err +} + +// Get retrieves the PuppetTarget from the indexer for a given namespace and name. +func (s puppetTargetNamespaceLister) Get(name string) (*v1alpha1.PuppetTarget, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("puppettarget"), name) + } + return obj.(*v1alpha1.PuppetTarget), nil +} diff --git a/pkg/wing/listers/wing/v1alpha1/wingjob.go b/pkg/wing/listers/wing/v1alpha1/wingjob.go new file mode 100644 index 0000000000..a08ed02437 --- /dev/null +++ b/pkg/wing/listers/wing/v1alpha1/wingjob.go @@ -0,0 +1,80 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by lister-gen + +package v1alpha1 + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// WingJobLister helps list WingJobs. +type WingJobLister interface { + // List lists all WingJobs in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.WingJob, err error) + // WingJobs returns an object that can list and get WingJobs. + WingJobs(namespace string) WingJobNamespaceLister + WingJobListerExpansion +} + +// wingJobLister implements the WingJobLister interface. +type wingJobLister struct { + indexer cache.Indexer +} + +// NewWingJobLister returns a new WingJobLister. +func NewWingJobLister(indexer cache.Indexer) WingJobLister { + return &wingJobLister{indexer: indexer} +} + +// List lists all WingJobs in the indexer. +func (s *wingJobLister) List(selector labels.Selector) (ret []*v1alpha1.WingJob, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.WingJob)) + }) + return ret, err +} + +// WingJobs returns an object that can list and get WingJobs. +func (s *wingJobLister) WingJobs(namespace string) WingJobNamespaceLister { + return wingJobNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// WingJobNamespaceLister helps list and get WingJobs. +type WingJobNamespaceLister interface { + // List lists all WingJobs in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.WingJob, err error) + // Get retrieves the WingJob from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.WingJob, error) + WingJobNamespaceListerExpansion +} + +// wingJobNamespaceLister implements the WingJobNamespaceLister +// interface. +type wingJobNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all WingJobs in the indexer for a given namespace. +func (s wingJobNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.WingJob, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.WingJob)) + }) + return ret, err +} + +// Get retrieves the WingJob from the indexer for a given namespace and name. +func (s wingJobNamespaceLister) Get(name string) (*v1alpha1.WingJob, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("wingjob"), name) + } + return obj.(*v1alpha1.WingJob), nil +} From 08161f2e1a0a3de4f07c228419731b762060f207 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Wed, 13 Jun 2018 12:18:19 +0100 Subject: [PATCH 02/14] Don't prune non-go from k8s.io/code-generator --- Gopkg.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gopkg.toml b/Gopkg.toml index feb3b915fa..bac060ac74 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -74,6 +74,11 @@ required = [ name = "k8s.io/code-generator" version = "kubernetes-1.9.3" +[[prune.project]] + name = "k8s.io/code-generator" + non-go = false + unused-packages = false + [[constraint]] name = "gopkg.in/src-d/go-git.v4" revision = "b08cc8dc5450981530af3e6f6ad1159ae8ea8705" From deaa3943069fa34f4942361a20d2fecfae49ca90 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Wed, 13 Jun 2018 12:25:33 +0100 Subject: [PATCH 03/14] Vendor k8s.io/code-generator --- .../k8s.io/code-generator/Godeps/Godeps.json | 262 ++++++ vendor/k8s.io/code-generator/Godeps/Readme | 5 + vendor/k8s.io/code-generator/OWNERS | 8 + vendor/k8s.io/code-generator/README.md | 24 + .../_examples/apiserver/apis/example/doc.go | 19 + .../apiserver/apis/example/install/install.go | 43 + .../apiserver/apis/example/register.go | 45 + .../_examples/apiserver/apis/example/types.go | 44 + .../apiserver/apis/example/v1/doc.go | 20 + .../apiserver/apis/example/v1/register.go | 59 ++ .../apiserver/apis/example/v1/types.go | 47 ++ .../example/v1/zz_generated.conversion.go | 113 +++ .../example/v1/zz_generated.conversions.go | 113 +++ .../apis/example/v1/zz_generated.deepcopy.go | 103 +++ .../apis/example/v1/zz_generated.defaults.go | 32 + .../apis/example/zz_generated.deepcopy.go | 103 +++ .../_examples/apiserver/apis/example2/doc.go | 20 + .../apis/example2/install/install.go | 43 + .../apiserver/apis/example2/register.go | 45 + .../apiserver/apis/example2/types.go | 44 + .../apiserver/apis/example2/v1/doc.go | 21 + .../apiserver/apis/example2/v1/register.go | 59 ++ .../apiserver/apis/example2/v1/types.go | 47 ++ .../example2/v1/zz_generated.conversion.go | 113 +++ .../apis/example2/v1/zz_generated.deepcopy.go | 103 +++ .../apis/example2/v1/zz_generated.defaults.go | 32 + .../apis/example2/zz_generated.deepcopy.go | 103 +++ .../clientset/internalversion/clientset.go | 104 +++ .../clientset/internalversion/doc.go | 18 + .../fake/clientset_generated.go | 73 ++ .../clientset/internalversion/fake/doc.go | 18 + .../internalversion/fake/register.go | 55 ++ .../clientset/internalversion/scheme/doc.go | 18 + .../internalversion/scheme/register.go | 48 ++ .../typed/example/internalversion/doc.go | 18 + .../example/internalversion/example_client.go | 99 +++ .../typed/example/internalversion/fake/doc.go | 18 + .../fake/fake_example_client.go | 38 + .../internalversion/fake/fake_testtype.go | 138 ++++ .../internalversion/generated_expansion.go | 19 + .../typed/example/internalversion/testtype.go | 172 ++++ .../typed/example2/internalversion/doc.go | 18 + .../internalversion/example2_client.go | 99 +++ .../example2/internalversion/fake/doc.go | 18 + .../fake/fake_example2_client.go | 38 + .../internalversion/fake/fake_testtype.go | 138 ++++ .../internalversion/generated_expansion.go | 19 + .../example2/internalversion/testtype.go | 172 ++++ .../clientset/versioned/clientset.go | 120 +++ .../apiserver/clientset/versioned/doc.go | 18 + .../versioned/fake/clientset_generated.go | 83 ++ .../apiserver/clientset/versioned/fake/doc.go | 18 + .../clientset/versioned/fake/register.go | 55 ++ .../clientset/versioned/scheme/doc.go | 18 + .../clientset/versioned/scheme/register.go | 55 ++ .../versioned/typed/example/v1/doc.go | 18 + .../typed/example/v1/example_client.go | 88 ++ .../versioned/typed/example/v1/fake/doc.go | 18 + .../example/v1/fake/fake_example_client.go | 38 + .../typed/example/v1/fake/fake_testtype.go | 138 ++++ .../typed/example/v1/generated_expansion.go | 19 + .../versioned/typed/example/v1/testtype.go | 172 ++++ .../versioned/typed/example2/v1/doc.go | 18 + .../typed/example2/v1/example2_client.go | 88 ++ .../versioned/typed/example2/v1/fake/doc.go | 18 + .../example2/v1/fake/fake_example2_client.go | 38 + .../typed/example2/v1/fake/fake_testtype.go | 138 ++++ .../typed/example2/v1/generated_expansion.go | 19 + .../versioned/typed/example2/v1/testtype.go | 172 ++++ .../externalversions/example/interface.go | 46 ++ .../externalversions/example/v1/interface.go | 45 + .../externalversions/example/v1/testtype.go | 88 ++ .../externalversions/example2/interface.go | 46 ++ .../externalversions/example2/v1/interface.go | 45 + .../externalversions/example2/v1/testtype.go | 88 ++ .../informers/externalversions/factory.go | 136 ++++ .../informers/externalversions/generic.go | 66 ++ .../internalinterfaces/factory_interfaces.go | 37 + .../internalversion/example/interface.go | 46 ++ .../example/internalversion/interface.go | 45 + .../example/internalversion/testtype.go | 88 ++ .../internalversion/example2/interface.go | 46 ++ .../example2/internalversion/interface.go | 45 + .../example2/internalversion/testtype.go | 88 ++ .../informers/internalversion/factory.go | 136 ++++ .../informers/internalversion/generic.go | 66 ++ .../internalinterfaces/factory_interfaces.go | 37 + .../internalversion/expansion_generated.go | 27 + .../example/internalversion/testtype.go | 94 +++ .../listers/example/v1/expansion_generated.go | 27 + .../apiserver/listers/example/v1/testtype.go | 94 +++ .../internalversion/expansion_generated.go | 27 + .../example2/internalversion/testtype.go | 94 +++ .../example2/v1/expansion_generated.go | 27 + .../apiserver/listers/example2/v1/testtype.go | 94 +++ .../_examples/crd/apis/example/v1/doc.go | 19 + .../_examples/crd/apis/example/v1/register.go | 59 ++ .../_examples/crd/apis/example/v1/types.go | 47 ++ .../apis/example/v1/zz_generated.deepcopy.go | 103 +++ .../_examples/crd/apis/example2/v1/doc.go | 20 + .../crd/apis/example2/v1/register.go | 59 ++ .../_examples/crd/apis/example2/v1/types.go | 47 ++ .../apis/example2/v1/zz_generated.deepcopy.go | 103 +++ .../crd/clientset/versioned/clientset.go | 120 +++ .../_examples/crd/clientset/versioned/doc.go | 18 + .../versioned/fake/clientset_generated.go | 83 ++ .../crd/clientset/versioned/fake/doc.go | 18 + .../crd/clientset/versioned/fake/register.go | 55 ++ .../crd/clientset/versioned/scheme/doc.go | 18 + .../clientset/versioned/scheme/register.go | 55 ++ .../versioned/typed/example/v1/doc.go | 18 + .../typed/example/v1/example_client.go | 88 ++ .../versioned/typed/example/v1/fake/doc.go | 18 + .../example/v1/fake/fake_example_client.go | 38 + .../typed/example/v1/fake/fake_testtype.go | 138 ++++ .../typed/example/v1/generated_expansion.go | 19 + .../versioned/typed/example/v1/testtype.go | 172 ++++ .../versioned/typed/example2/v1/doc.go | 18 + .../typed/example2/v1/example2_client.go | 88 ++ .../versioned/typed/example2/v1/fake/doc.go | 18 + .../example2/v1/fake/fake_example2_client.go | 38 + .../typed/example2/v1/fake/fake_testtype.go | 138 ++++ .../typed/example2/v1/generated_expansion.go | 19 + .../versioned/typed/example2/v1/testtype.go | 172 ++++ .../externalversions/example/interface.go | 46 ++ .../externalversions/example/v1/interface.go | 45 + .../externalversions/example/v1/testtype.go | 88 ++ .../externalversions/example2/interface.go | 46 ++ .../externalversions/example2/v1/interface.go | 45 + .../externalversions/example2/v1/testtype.go | 88 ++ .../crd/informers/externalversions/factory.go | 136 ++++ .../crd/informers/externalversions/generic.go | 66 ++ .../internalinterfaces/factory_interfaces.go | 37 + .../listers/example/v1/expansion_generated.go | 27 + .../crd/listers/example/v1/testtype.go | 94 +++ .../example2/v1/expansion_generated.go | 27 + .../crd/listers/example2/v1/testtype.go | 94 +++ .../code-generator/cmd/client-gen/BUILD | 45 + .../code-generator/cmd/client-gen/OWNERS | 8 + .../code-generator/cmd/client-gen/README.md | 4 + .../code-generator/cmd/client-gen/args/BUILD | 45 + .../cmd/client-gen/generators/BUILD | 50 ++ .../cmd/client-gen/generators/fake/BUILD | 40 + .../cmd/client-gen/generators/scheme/BUILD | 32 + .../cmd/client-gen/generators/util/BUILD | 34 + .../code-generator/cmd/client-gen/path/BUILD | 25 + .../code-generator/cmd/client-gen/types/BUILD | 37 + .../code-generator/cmd/conversion-gen/BUILD | 41 + .../cmd/conversion-gen/generators/BUILD | 32 + .../code-generator/cmd/deepcopy-gen/BUILD | 38 + .../code-generator/cmd/defaulter-gen/BUILD | 38 + .../cmd/go-to-protobuf/.gitignore | 1 + .../code-generator/cmd/go-to-protobuf/BUILD | 40 + .../code-generator/cmd/go-to-protobuf/OWNERS | 4 + .../code-generator/cmd/go-to-protobuf/main.go | 38 + .../cmd/go-to-protobuf/protobuf/BUILD | 51 ++ .../cmd/go-to-protobuf/protobuf/cmd.go | 347 ++++++++ .../cmd/go-to-protobuf/protobuf/generator.go | 766 ++++++++++++++++++ .../go-to-protobuf/protobuf/import_tracker.go | 50 ++ .../cmd/go-to-protobuf/protobuf/namer.go | 205 +++++ .../cmd/go-to-protobuf/protobuf/package.go | 215 +++++ .../cmd/go-to-protobuf/protobuf/parser.go | 452 +++++++++++ .../cmd/go-to-protobuf/protobuf/tags.go | 33 + .../cmd/go-to-protobuf/protoc-gen-gogo/BUILD | 38 + .../go-to-protobuf/protoc-gen-gogo/main.go | 32 + .../code-generator/cmd/import-boss/.gitignore | 1 + .../code-generator/cmd/import-boss/BUILD | 37 + .../code-generator/cmd/import-boss/main.go | 88 ++ .../code-generator/cmd/informer-gen/BUILD | 41 + .../cmd/informer-gen/generators/BUILD | 46 ++ .../cmd/lister-gen/.import-restrictions | 1 + .../code-generator/cmd/lister-gen/BUILD | 40 + .../cmd/lister-gen/generators/BUILD | 38 + .../code-generator/cmd/openapi-gen/BUILD | 37 + .../code-generator/cmd/openapi-gen/README | 13 + .../code-generator/cmd/openapi-gen/main.go | 47 ++ .../code-generator/cmd/set-gen/.gitignore | 1 + .../k8s.io/code-generator/cmd/set-gen/BUILD | 41 + .../k8s.io/code-generator/cmd/set-gen/main.go | 54 ++ .../k8s.io/code-generator/generate-groups.sh | 86 ++ .../generate-internal-groups.sh | 109 +++ .../code-generator/hack/update-codegen.sh | 32 + .../code-generator/hack/verify-codegen.sh | 53 ++ .../third_party/forked/golang/reflect/BUILD | 25 + .../third_party/forked/golang/reflect/type.go | 91 +++ 185 files changed, 12302 insertions(+) create mode 100644 vendor/k8s.io/code-generator/Godeps/Godeps.json create mode 100644 vendor/k8s.io/code-generator/Godeps/Readme create mode 100644 vendor/k8s.io/code-generator/OWNERS create mode 100644 vendor/k8s.io/code-generator/README.md create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversions.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.defaults.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.conversion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.defaults.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/clientset.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/clientset_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/clientset.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/clientset_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/factory.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/generic.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/factory.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/generic.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/clientset.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/clientset_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/factory.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/generic.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/OWNERS create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/README.md create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/args/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/fake/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/scheme/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/util/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/path/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/types/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/conversion-gen/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/conversion-gen/generators/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/deepcopy-gen/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/defaulter-gen/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/.gitignore create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/generator.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/import_tracker.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/namer.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/package.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/tags.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/import-boss/.gitignore create mode 100644 vendor/k8s.io/code-generator/cmd/import-boss/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/import-boss/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/.import-restrictions create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/generators/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/openapi-gen/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/openapi-gen/README create mode 100644 vendor/k8s.io/code-generator/cmd/openapi-gen/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/set-gen/.gitignore create mode 100644 vendor/k8s.io/code-generator/cmd/set-gen/BUILD create mode 100644 vendor/k8s.io/code-generator/cmd/set-gen/main.go create mode 100755 vendor/k8s.io/code-generator/generate-groups.sh create mode 100755 vendor/k8s.io/code-generator/generate-internal-groups.sh create mode 100755 vendor/k8s.io/code-generator/hack/update-codegen.sh create mode 100755 vendor/k8s.io/code-generator/hack/verify-codegen.sh create mode 100644 vendor/k8s.io/code-generator/third_party/forked/golang/reflect/BUILD create mode 100644 vendor/k8s.io/code-generator/third_party/forked/golang/reflect/type.go diff --git a/vendor/k8s.io/code-generator/Godeps/Godeps.json b/vendor/k8s.io/code-generator/Godeps/Godeps.json new file mode 100644 index 0000000000..239636cbe3 --- /dev/null +++ b/vendor/k8s.io/code-generator/Godeps/Godeps.json @@ -0,0 +1,262 @@ +{ + "ImportPath": "k8s.io/code-generator", + "GoVersion": "go1.9", + "GodepVersion": "v79", + "Packages": [ + "./..." + ], + "Deps": [ + { + "ImportPath": "github.com/PuerkitoBio/purell", + "Rev": "8a290539e2e8629dbc4e6bad948158f790ec31f4" + }, + { + "ImportPath": "github.com/PuerkitoBio/urlesc", + "Rev": "5bd2802263f21d8788851d5305584c82a5c75d7e" + }, + { + "ImportPath": "github.com/emicklei/go-restful", + "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" + }, + { + "ImportPath": "github.com/emicklei/go-restful/log", + "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" + }, + { + "ImportPath": "github.com/go-openapi/jsonpointer", + "Rev": "46af16f9f7b149af66e5d1bd010e3574dc06de98" + }, + { + "ImportPath": "github.com/go-openapi/jsonreference", + "Rev": "13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272" + }, + { + "ImportPath": "github.com/go-openapi/spec", + "Rev": "7abd5745472fff5eb3685386d5fb8bf38683154d" + }, + { + "ImportPath": "github.com/go-openapi/swag", + "Rev": "f3f9494671f93fcff853e3c6e9e948b3eb71e590" + }, + { + "ImportPath": "github.com/gogo/protobuf/gogoproto", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/compare", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/defaultcheck", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/description", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/embedcheck", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/enumstringer", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/equal", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/face", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/gostring", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/marshalto", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/oneofcheck", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/populate", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/size", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/stringer", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/testgen", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/union", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/plugin/unmarshal", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/proto", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/protoc-gen-gogo/descriptor", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/protoc-gen-gogo/generator", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/protoc-gen-gogo/grpc", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/protoc-gen-gogo/plugin", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/sortkeys", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/vanity", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/gogo/protobuf/vanity/command", + "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" + }, + { + "ImportPath": "github.com/golang/glog", + "Rev": "44145f04b68cf362d9c4df2182967c2275eaefed" + }, + { + "ImportPath": "github.com/mailru/easyjson/buffer", + "Rev": "2f5df55504ebc322e4d52d34df6a1f5b503bf26d" + }, + { + "ImportPath": "github.com/mailru/easyjson/jlexer", + "Rev": "2f5df55504ebc322e4d52d34df6a1f5b503bf26d" + }, + { + "ImportPath": "github.com/mailru/easyjson/jwriter", + "Rev": "2f5df55504ebc322e4d52d34df6a1f5b503bf26d" + }, + { + "ImportPath": "github.com/spf13/pflag", + "Rev": "9ff6c6923cfffbcd502984b8e0c80539a94968b7" + }, + { + "ImportPath": "golang.org/x/net/idna", + "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" + }, + { + "ImportPath": "golang.org/x/text/cases", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/internal", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/internal/tag", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/language", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/runes", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/secure/bidirule", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/secure/precis", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/transform", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/unicode/bidi", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/unicode/norm", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "golang.org/x/text/width", + "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" + }, + { + "ImportPath": "gopkg.in/yaml.v2", + "Rev": "53feefa2559fb8dfa8d81baad31be332c97d6c77" + }, + { + "ImportPath": "k8s.io/gengo/args", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/examples/deepcopy-gen/generators", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/examples/defaulter-gen/generators", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/examples/import-boss/generators", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/examples/set-gen/generators", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/examples/set-gen/sets", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/generator", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/namer", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/parser", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/gengo/types", + "Rev": "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4" + }, + { + "ImportPath": "k8s.io/kube-openapi/pkg/common", + "Rev": "39a7bf85c140f972372c2a0d1ee40adbf0c8bfe1" + }, + { + "ImportPath": "k8s.io/kube-openapi/pkg/generators", + "Rev": "39a7bf85c140f972372c2a0d1ee40adbf0c8bfe1" + } + ] +} diff --git a/vendor/k8s.io/code-generator/Godeps/Readme b/vendor/k8s.io/code-generator/Godeps/Readme new file mode 100644 index 0000000000..4cdaa53d56 --- /dev/null +++ b/vendor/k8s.io/code-generator/Godeps/Readme @@ -0,0 +1,5 @@ +This directory tree is generated automatically by godep. + +Please do not edit. + +See https://github.com/tools/godep for more information. diff --git a/vendor/k8s.io/code-generator/OWNERS b/vendor/k8s.io/code-generator/OWNERS new file mode 100644 index 0000000000..ce432f59d8 --- /dev/null +++ b/vendor/k8s.io/code-generator/OWNERS @@ -0,0 +1,8 @@ +approvers: +- lavalamp +- wojtek-t +- sttts +reviewers: +- lavalamp +- wojtek-t +- sttts diff --git a/vendor/k8s.io/code-generator/README.md b/vendor/k8s.io/code-generator/README.md new file mode 100644 index 0000000000..5808c86b35 --- /dev/null +++ b/vendor/k8s.io/code-generator/README.md @@ -0,0 +1,24 @@ +# code-generator + +Golang code-generators used to implement [Kubernetes-style API types](https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md). + +## Purpose + +These code-generators can be used +- in the context of [CustomResourceDefinition](https://kubernetes.io/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/) to build native, versioned clients, + informers and other helpers +- in the context of [User-provider API Servers](https://github.com/kubernetes/apiserver) to build conversions between internal and versioned types, defaulters, protobuf codecs, + internal and versioned clients and informers. + +## Resources +- The example [sample controller](https://github.com/kubernetes/sample-controller) shows a code example of a controller that uses the clients, listers and informers generated by this library. +- The article [Kubernetes Deep Dive: Code Generation for CustomResources](https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/) gives a step by step instruction on how to use this library. + +## Compatibility + +HEAD of this repo will match HEAD of k8s.io/apiserver, k8s.io/apimachinery, and k8s.io/client-go. + +## Where does it come from? + +`code-generator` is synced from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/code-generator. +Code changes are made in that location, merged into `k8s.io/kubernetes` and later synced here. diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/doc.go new file mode 100644 index 0000000000..b221d7eb49 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2015 The Kubernetes 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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=example.apiserver.code-generator.k8s.io +package example // import "k8s.io/code-generator/_examples/apiserver/apis/example" diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go new file mode 100644 index 0000000000..b5182d690f --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go @@ -0,0 +1,43 @@ +/* +Copyright 2015 The Kubernetes 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 install installs the experimental API group, making it available as +// an option to all of the API encoding/decoding machinery. +package install + +import ( + "k8s.io/apimachinery/pkg/apimachinery/announced" + "k8s.io/apimachinery/pkg/apimachinery/registered" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/code-generator/_examples/apiserver/apis/example" + "k8s.io/code-generator/_examples/apiserver/apis/example/v1" +) + +// Install registers the API group and adds types to a scheme +func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: example.SchemeGroupVersion.Group, + VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version}, + AddInternalObjectsToScheme: example.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1.SchemeGroupVersion.Version: v1.AddToScheme, + }, + ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + panic(err) + } +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/register.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/register.go new file mode 100644 index 0000000000..da397b524a --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/register.go @@ -0,0 +1,45 @@ +/* +Copyright 2015 The Kubernetes 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 example + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var SchemeGroupVersion = schema.GroupVersion{Group: "example.api.code-generator.k8s.io", Version: runtime.APIVersionInternal} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &TestType{}, + &TestTypeList{}, + ) + + scheme.AddKnownTypes(SchemeGroupVersion) + return nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/types.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/types.go new file mode 100644 index 0000000000..b4fc976684 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/types.go @@ -0,0 +1,44 @@ +/* +Copyright 2015 The Kubernetes 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 example + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestType is a top-level type. A client is created for it. +type TestType struct { + metav1.TypeMeta + metav1.ObjectMeta + Status TestTypeStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestTypeList is a top-level list type. The client methods for lists are automatically created. +// You are not supposed to create a separated client for this one. +type TestTypeList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []TestType +} + +type TestTypeStatus struct { + Blah string +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/doc.go new file mode 100644 index 0000000000..242d3904dd --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes 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. +*/ + +// +k8s:deepcopy-gen=package +// +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example +// +groupName=example.apiserver.code-generator.k8s.io +package v1 diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/register.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/register.go new file mode 100644 index 0000000000..c99619d7ac --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/register.go @@ -0,0 +1,59 @@ +/* +Copyright 2015 The Kubernetes 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 v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var SchemeGroupVersion = schema.GroupVersion{Group: "example.apiserver.code-generator.k8s.io", Version: "v1"} + +var ( + // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &TestType{}, + &TestTypeList{}, + ) + + scheme.AddKnownTypes(SchemeGroupVersion, + &metav1.Status{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/types.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/types.go new file mode 100644 index 0000000000..5c2ebc4d6f --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/types.go @@ -0,0 +1,47 @@ +/* +Copyright 2015 The Kubernetes 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 v1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestType is a top-level type. A client is created for it. +type TestType struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional + Status TestTypeStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestTypeList is a top-level list type. The client methods for lists are automatically created. +// You are not supposed to create a separated client for this one. +type TestTypeList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []TestType `json:"items"` +} + +type TestTypeStatus struct { + Blah string +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversion.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversion.go new file mode 100644 index 0000000000..85dd5b954e --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversion.go @@ -0,0 +1,113 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by conversion-gen. Do not edit it manually! + +package v1 + +import ( + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + example "k8s.io/code-generator/_examples/apiserver/apis/example" + unsafe "unsafe" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(scheme *runtime.Scheme) error { + return scheme.AddGeneratedConversionFuncs( + Convert_v1_TestType_To_example_TestType, + Convert_example_TestType_To_v1_TestType, + Convert_v1_TestTypeList_To_example_TestTypeList, + Convert_example_TestTypeList_To_v1_TestTypeList, + Convert_v1_TestTypeStatus_To_example_TestTypeStatus, + Convert_example_TestTypeStatus_To_v1_TestTypeStatus, + ) +} + +func autoConvert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1_TestTypeStatus_To_example_TestTypeStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1_TestType_To_example_TestType is an autogenerated conversion function. +func Convert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error { + return autoConvert_v1_TestType_To_example_TestType(in, out, s) +} + +func autoConvert_example_TestType_To_v1_TestType(in *example.TestType, out *TestType, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_example_TestTypeStatus_To_v1_TestTypeStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_example_TestType_To_v1_TestType is an autogenerated conversion function. +func Convert_example_TestType_To_v1_TestType(in *example.TestType, out *TestType, s conversion.Scope) error { + return autoConvert_example_TestType_To_v1_TestType(in, out, s) +} + +func autoConvert_v1_TestTypeList_To_example_TestTypeList(in *TestTypeList, out *example.TestTypeList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]example.TestType)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1_TestTypeList_To_example_TestTypeList is an autogenerated conversion function. +func Convert_v1_TestTypeList_To_example_TestTypeList(in *TestTypeList, out *example.TestTypeList, s conversion.Scope) error { + return autoConvert_v1_TestTypeList_To_example_TestTypeList(in, out, s) +} + +func autoConvert_example_TestTypeList_To_v1_TestTypeList(in *example.TestTypeList, out *TestTypeList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]TestType)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_example_TestTypeList_To_v1_TestTypeList is an autogenerated conversion function. +func Convert_example_TestTypeList_To_v1_TestTypeList(in *example.TestTypeList, out *TestTypeList, s conversion.Scope) error { + return autoConvert_example_TestTypeList_To_v1_TestTypeList(in, out, s) +} + +func autoConvert_v1_TestTypeStatus_To_example_TestTypeStatus(in *TestTypeStatus, out *example.TestTypeStatus, s conversion.Scope) error { + out.Blah = in.Blah + return nil +} + +// Convert_v1_TestTypeStatus_To_example_TestTypeStatus is an autogenerated conversion function. +func Convert_v1_TestTypeStatus_To_example_TestTypeStatus(in *TestTypeStatus, out *example.TestTypeStatus, s conversion.Scope) error { + return autoConvert_v1_TestTypeStatus_To_example_TestTypeStatus(in, out, s) +} + +func autoConvert_example_TestTypeStatus_To_v1_TestTypeStatus(in *example.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error { + out.Blah = in.Blah + return nil +} + +// Convert_example_TestTypeStatus_To_v1_TestTypeStatus is an autogenerated conversion function. +func Convert_example_TestTypeStatus_To_v1_TestTypeStatus(in *example.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error { + return autoConvert_example_TestTypeStatus_To_v1_TestTypeStatus(in, out, s) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversions.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversions.go new file mode 100644 index 0000000000..183921e9dc --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversions.go @@ -0,0 +1,113 @@ +// +build !ignore_autogenerated + +/* +Copyright 2017 The Kubernetes 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. +*/ + +// This file was autogenerated by conversion-gen. Do not edit it manually! + +package v1 + +import ( + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + example "k8s.io/code-generator/_examples/apiserver/apis/example" + unsafe "unsafe" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(scheme *runtime.Scheme) error { + return scheme.AddGeneratedConversionFuncs( + Convert_v1_TestType_To_example_TestType, + Convert_example_TestType_To_v1_TestType, + Convert_v1_TestTypeList_To_example_TestTypeList, + Convert_example_TestTypeList_To_v1_TestTypeList, + Convert_v1_TestTypeStatus_To_example_TestTypeStatus, + Convert_example_TestTypeStatus_To_v1_TestTypeStatus, + ) +} + +func autoConvert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1_TestTypeStatus_To_example_TestTypeStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1_TestType_To_example_TestType is an autogenerated conversion function. +func Convert_v1_TestType_To_example_TestType(in *TestType, out *example.TestType, s conversion.Scope) error { + return autoConvert_v1_TestType_To_example_TestType(in, out, s) +} + +func autoConvert_example_TestType_To_v1_TestType(in *example.TestType, out *TestType, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_example_TestTypeStatus_To_v1_TestTypeStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_example_TestType_To_v1_TestType is an autogenerated conversion function. +func Convert_example_TestType_To_v1_TestType(in *example.TestType, out *TestType, s conversion.Scope) error { + return autoConvert_example_TestType_To_v1_TestType(in, out, s) +} + +func autoConvert_v1_TestTypeList_To_example_TestTypeList(in *TestTypeList, out *example.TestTypeList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]example.TestType)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1_TestTypeList_To_example_TestTypeList is an autogenerated conversion function. +func Convert_v1_TestTypeList_To_example_TestTypeList(in *TestTypeList, out *example.TestTypeList, s conversion.Scope) error { + return autoConvert_v1_TestTypeList_To_example_TestTypeList(in, out, s) +} + +func autoConvert_example_TestTypeList_To_v1_TestTypeList(in *example.TestTypeList, out *TestTypeList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]TestType)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_example_TestTypeList_To_v1_TestTypeList is an autogenerated conversion function. +func Convert_example_TestTypeList_To_v1_TestTypeList(in *example.TestTypeList, out *TestTypeList, s conversion.Scope) error { + return autoConvert_example_TestTypeList_To_v1_TestTypeList(in, out, s) +} + +func autoConvert_v1_TestTypeStatus_To_example_TestTypeStatus(in *TestTypeStatus, out *example.TestTypeStatus, s conversion.Scope) error { + out.Blah = in.Blah + return nil +} + +// Convert_v1_TestTypeStatus_To_example_TestTypeStatus is an autogenerated conversion function. +func Convert_v1_TestTypeStatus_To_example_TestTypeStatus(in *TestTypeStatus, out *example.TestTypeStatus, s conversion.Scope) error { + return autoConvert_v1_TestTypeStatus_To_example_TestTypeStatus(in, out, s) +} + +func autoConvert_example_TestTypeStatus_To_v1_TestTypeStatus(in *example.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error { + out.Blah = in.Blah + return nil +} + +// Convert_example_TestTypeStatus_To_v1_TestTypeStatus is an autogenerated conversion function. +func Convert_example_TestTypeStatus_To_v1_TestTypeStatus(in *example.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error { + return autoConvert_example_TestTypeStatus_To_v1_TestTypeStatus(in, out, s) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.deepcopy.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..96771586c7 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.deepcopy.go @@ -0,0 +1,103 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package v1 + +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 *TestType) DeepCopyInto(out *TestType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. +func (in *TestType) DeepCopy() *TestType { + if in == nil { + return nil + } + out := new(TestType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeList) DeepCopyInto(out *TestTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TestType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeList. +func (in *TestTypeList) DeepCopy() *TestTypeList { + if in == nil { + return nil + } + out := new(TestTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeStatus) DeepCopyInto(out *TestTypeStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeStatus. +func (in *TestTypeStatus) DeepCopy() *TestTypeStatus { + if in == nil { + return nil + } + out := new(TestTypeStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.defaults.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.defaults.go new file mode 100644 index 0000000000..88d7af085b --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.defaults.go @@ -0,0 +1,32 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by defaulter-gen. Do not edit it manually! + +package v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + return nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/zz_generated.deepcopy.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/zz_generated.deepcopy.go new file mode 100644 index 0000000000..7f46d2bbe2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example/zz_generated.deepcopy.go @@ -0,0 +1,103 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package example + +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 *TestType) DeepCopyInto(out *TestType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. +func (in *TestType) DeepCopy() *TestType { + if in == nil { + return nil + } + out := new(TestType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeList) DeepCopyInto(out *TestTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TestType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeList. +func (in *TestTypeList) DeepCopy() *TestTypeList { + if in == nil { + return nil + } + out := new(TestTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeStatus) DeepCopyInto(out *TestTypeStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeStatus. +func (in *TestTypeStatus) DeepCopy() *TestTypeStatus { + if in == nil { + return nil + } + out := new(TestTypeStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/doc.go new file mode 100644 index 0000000000..3864803757 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2015 The Kubernetes 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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=example.test.apiserver.code-generator.k8s.io +// +groupGoName=SecondExample +package example2 // import "k8s.io/code-generator/_examples/apiserver/apis/example2" diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go new file mode 100644 index 0000000000..ef241a33f2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go @@ -0,0 +1,43 @@ +/* +Copyright 2015 The Kubernetes 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 install installs the experimental API group, making it available as +// an option to all of the API encoding/decoding machinery. +package install + +import ( + "k8s.io/apimachinery/pkg/apimachinery/announced" + "k8s.io/apimachinery/pkg/apimachinery/registered" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/code-generator/_examples/apiserver/apis/example2" + "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" +) + +// Install registers the API group and adds types to a scheme +func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: example2.SchemeGroupVersion.Group, + VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version}, + AddInternalObjectsToScheme: example2.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1.SchemeGroupVersion.Version: v1.AddToScheme, + }, + ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { + panic(err) + } +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/register.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/register.go new file mode 100644 index 0000000000..508565af7a --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/register.go @@ -0,0 +1,45 @@ +/* +Copyright 2015 The Kubernetes 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 example2 + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var SchemeGroupVersion = schema.GroupVersion{Group: "example.test.apiserver.code-generator.k8s.io", Version: runtime.APIVersionInternal} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &TestType{}, + &TestTypeList{}, + ) + + scheme.AddKnownTypes(SchemeGroupVersion) + return nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/types.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/types.go new file mode 100644 index 0000000000..10219129be --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/types.go @@ -0,0 +1,44 @@ +/* +Copyright 2015 The Kubernetes 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 example2 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestType is a top-level type. A client is created for it. +type TestType struct { + metav1.TypeMeta + metav1.ObjectMeta + Status TestTypeStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestTypeList is a top-level list type. The client methods for lists are automatically created. +// You are not supposed to create a separated client for this one. +type TestTypeList struct { + metav1.TypeMeta + metav1.ListMeta + + Items []TestType +} + +type TestTypeStatus struct { + Blah string +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/doc.go new file mode 100644 index 0000000000..41e271d223 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2016 The Kubernetes 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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=example.test.apiserver.code-generator.k8s.io +// +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example2 +// +groupGoName=SecondExample +package v1 diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/register.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/register.go new file mode 100644 index 0000000000..19dd0c356f --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/register.go @@ -0,0 +1,59 @@ +/* +Copyright 2015 The Kubernetes 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 v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var SchemeGroupVersion = schema.GroupVersion{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1"} + +var ( + // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &TestType{}, + &TestTypeList{}, + ) + + scheme.AddKnownTypes(SchemeGroupVersion, + &metav1.Status{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/types.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/types.go new file mode 100644 index 0000000000..5c2ebc4d6f --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/types.go @@ -0,0 +1,47 @@ +/* +Copyright 2015 The Kubernetes 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 v1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestType is a top-level type. A client is created for it. +type TestType struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional + Status TestTypeStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestTypeList is a top-level list type. The client methods for lists are automatically created. +// You are not supposed to create a separated client for this one. +type TestTypeList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []TestType `json:"items"` +} + +type TestTypeStatus struct { + Blah string +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.conversion.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.conversion.go new file mode 100644 index 0000000000..738d2d9bc8 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.conversion.go @@ -0,0 +1,113 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by conversion-gen. Do not edit it manually! + +package v1 + +import ( + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + example2 "k8s.io/code-generator/_examples/apiserver/apis/example2" + unsafe "unsafe" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(scheme *runtime.Scheme) error { + return scheme.AddGeneratedConversionFuncs( + Convert_v1_TestType_To_example2_TestType, + Convert_example2_TestType_To_v1_TestType, + Convert_v1_TestTypeList_To_example2_TestTypeList, + Convert_example2_TestTypeList_To_v1_TestTypeList, + Convert_v1_TestTypeStatus_To_example2_TestTypeStatus, + Convert_example2_TestTypeStatus_To_v1_TestTypeStatus, + ) +} + +func autoConvert_v1_TestType_To_example2_TestType(in *TestType, out *example2.TestType, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1_TestTypeStatus_To_example2_TestTypeStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1_TestType_To_example2_TestType is an autogenerated conversion function. +func Convert_v1_TestType_To_example2_TestType(in *TestType, out *example2.TestType, s conversion.Scope) error { + return autoConvert_v1_TestType_To_example2_TestType(in, out, s) +} + +func autoConvert_example2_TestType_To_v1_TestType(in *example2.TestType, out *TestType, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_example2_TestTypeStatus_To_v1_TestTypeStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_example2_TestType_To_v1_TestType is an autogenerated conversion function. +func Convert_example2_TestType_To_v1_TestType(in *example2.TestType, out *TestType, s conversion.Scope) error { + return autoConvert_example2_TestType_To_v1_TestType(in, out, s) +} + +func autoConvert_v1_TestTypeList_To_example2_TestTypeList(in *TestTypeList, out *example2.TestTypeList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]example2.TestType)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1_TestTypeList_To_example2_TestTypeList is an autogenerated conversion function. +func Convert_v1_TestTypeList_To_example2_TestTypeList(in *TestTypeList, out *example2.TestTypeList, s conversion.Scope) error { + return autoConvert_v1_TestTypeList_To_example2_TestTypeList(in, out, s) +} + +func autoConvert_example2_TestTypeList_To_v1_TestTypeList(in *example2.TestTypeList, out *TestTypeList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]TestType)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_example2_TestTypeList_To_v1_TestTypeList is an autogenerated conversion function. +func Convert_example2_TestTypeList_To_v1_TestTypeList(in *example2.TestTypeList, out *TestTypeList, s conversion.Scope) error { + return autoConvert_example2_TestTypeList_To_v1_TestTypeList(in, out, s) +} + +func autoConvert_v1_TestTypeStatus_To_example2_TestTypeStatus(in *TestTypeStatus, out *example2.TestTypeStatus, s conversion.Scope) error { + out.Blah = in.Blah + return nil +} + +// Convert_v1_TestTypeStatus_To_example2_TestTypeStatus is an autogenerated conversion function. +func Convert_v1_TestTypeStatus_To_example2_TestTypeStatus(in *TestTypeStatus, out *example2.TestTypeStatus, s conversion.Scope) error { + return autoConvert_v1_TestTypeStatus_To_example2_TestTypeStatus(in, out, s) +} + +func autoConvert_example2_TestTypeStatus_To_v1_TestTypeStatus(in *example2.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error { + out.Blah = in.Blah + return nil +} + +// Convert_example2_TestTypeStatus_To_v1_TestTypeStatus is an autogenerated conversion function. +func Convert_example2_TestTypeStatus_To_v1_TestTypeStatus(in *example2.TestTypeStatus, out *TestTypeStatus, s conversion.Scope) error { + return autoConvert_example2_TestTypeStatus_To_v1_TestTypeStatus(in, out, s) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.deepcopy.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..96771586c7 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.deepcopy.go @@ -0,0 +1,103 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package v1 + +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 *TestType) DeepCopyInto(out *TestType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. +func (in *TestType) DeepCopy() *TestType { + if in == nil { + return nil + } + out := new(TestType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeList) DeepCopyInto(out *TestTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TestType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeList. +func (in *TestTypeList) DeepCopy() *TestTypeList { + if in == nil { + return nil + } + out := new(TestTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeStatus) DeepCopyInto(out *TestTypeStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeStatus. +func (in *TestTypeStatus) DeepCopy() *TestTypeStatus { + if in == nil { + return nil + } + out := new(TestTypeStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.defaults.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.defaults.go new file mode 100644 index 0000000000..88d7af085b --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.defaults.go @@ -0,0 +1,32 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by defaulter-gen. Do not edit it manually! + +package v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + return nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/zz_generated.deepcopy.go b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/zz_generated.deepcopy.go new file mode 100644 index 0000000000..55746bfeb5 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/zz_generated.deepcopy.go @@ -0,0 +1,103 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package example2 + +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 *TestType) DeepCopyInto(out *TestType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. +func (in *TestType) DeepCopy() *TestType { + if in == nil { + return nil + } + out := new(TestType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeList) DeepCopyInto(out *TestTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TestType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeList. +func (in *TestTypeList) DeepCopy() *TestTypeList { + if in == nil { + return nil + } + out := new(TestTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeStatus) DeepCopyInto(out *TestTypeStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeStatus. +func (in *TestTypeStatus) DeepCopy() *TestTypeStatus { + if in == nil { + return nil + } + out := new(TestTypeStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/clientset.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/clientset.go new file mode 100644 index 0000000000..cf71a67726 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/clientset.go @@ -0,0 +1,104 @@ +/* +Copyright 2018 The Kubernetes 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 internalversion + +import ( + glog "github.com/golang/glog" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" + exampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion" + secondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + Example() exampleinternalversion.ExampleInterface + SecondExample() secondexampleinternalversion.SecondExampleInterface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + example *exampleinternalversion.ExampleClient + secondExample *secondexampleinternalversion.SecondExampleClient +} + +// Example retrieves the ExampleClient +func (c *Clientset) Example() exampleinternalversion.ExampleInterface { + return c.example +} + +// SecondExample retrieves the SecondExampleClient +func (c *Clientset) SecondExample() secondexampleinternalversion.SecondExampleInterface { + return c.secondExample +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.example, err = exampleinternalversion.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.secondExample, err = secondexampleinternalversion.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + glog.Errorf("failed to create the DiscoveryClient: %v", err) + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.example = exampleinternalversion.NewForConfigOrDie(c) + cs.secondExample = secondexampleinternalversion.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.example = exampleinternalversion.New(c) + cs.secondExample = secondexampleinternalversion.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/doc.go new file mode 100644 index 0000000000..6a6cae177b --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated clientset. +package internalversion diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/clientset_generated.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/clientset_generated.go new file mode 100644 index 0000000000..62ab5446f2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/clientset_generated.go @@ -0,0 +1,73 @@ +/* +Copyright 2018 The Kubernetes 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 ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" + clientset "k8s.io/code-generator/_examples/apiserver/clientset/internalversion" + exampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion" + fakeexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake" + secondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion" + fakesecondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + fakePtr := testing.Fake{} + fakePtr.AddReactor("*", "*", testing.ObjectReaction(o)) + fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil)) + + return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}} +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +var _ clientset.Interface = &Clientset{} + +// Example retrieves the ExampleClient +func (c *Clientset) Example() exampleinternalversion.ExampleInterface { + return &fakeexampleinternalversion.FakeExample{Fake: &c.Fake} +} + +// SecondExample retrieves the SecondExampleClient +func (c *Clientset) SecondExample() secondexampleinternalversion.SecondExampleInterface { + return &fakesecondexampleinternalversion.FakeSecondExample{Fake: &c.Fake} +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/doc.go new file mode 100644 index 0000000000..8a3101e398 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated fake clientset. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/register.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/register.go new file mode 100644 index 0000000000..910e117d7e --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/register.go @@ -0,0 +1,55 @@ +/* +Copyright 2018 The Kubernetes 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 ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + exampleinternalversion "k8s.io/code-generator/_examples/apiserver/apis/example" + secondexampleinternalversion "k8s.io/code-generator/_examples/apiserver/apis/example2" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + AddToScheme(scheme) +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kuberentes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +func AddToScheme(scheme *runtime.Scheme) { + exampleinternalversion.AddToScheme(scheme) + secondexampleinternalversion.AddToScheme(scheme) + +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/doc.go new file mode 100644 index 0000000000..3d3ab5f4ed --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/register.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/register.go new file mode 100644 index 0000000000..5ee4dddba2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/register.go @@ -0,0 +1,48 @@ +/* +Copyright 2018 The Kubernetes 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 scheme + +import ( + announced "k8s.io/apimachinery/pkg/apimachinery/announced" + registered "k8s.io/apimachinery/pkg/apimachinery/registered" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + example "k8s.io/code-generator/_examples/apiserver/apis/example/install" + secondexample "k8s.io/code-generator/_examples/apiserver/apis/example2/install" + os "os" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) + +var Registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS")) +var GroupFactoryRegistry = make(announced.APIGroupFactoryRegistry) + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + Install(GroupFactoryRegistry, Registry, Scheme) +} + +// Install registers the API group and adds types to a scheme +func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { + example.Install(groupFactoryRegistry, registry, scheme) + secondexample.Install(groupFactoryRegistry, registry, scheme) + +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/doc.go new file mode 100644 index 0000000000..8615019757 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated typed clients. +package internalversion diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/example_client.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/example_client.go new file mode 100644 index 0000000000..906aa3f47a --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/example_client.go @@ -0,0 +1,99 @@ +/* +Copyright 2018 The Kubernetes 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 internalversion + +import ( + rest "k8s.io/client-go/rest" + "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme" +) + +type ExampleInterface interface { + RESTClient() rest.Interface + TestTypesGetter +} + +// ExampleClient is used to interact with features provided by the example.apiserver.code-generator.k8s.io group. +type ExampleClient struct { + restClient rest.Interface +} + +func (c *ExampleClient) TestTypes(namespace string) TestTypeInterface { + return newTestTypes(c, namespace) +} + +// NewForConfig creates a new ExampleClient for the given config. +func NewForConfig(c *rest.Config) (*ExampleClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ExampleClient{client}, nil +} + +// NewForConfigOrDie creates a new ExampleClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ExampleClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ExampleClient for the given RESTClient. +func New(c rest.Interface) *ExampleClient { + return &ExampleClient{c} +} + +func setConfigDefaults(config *rest.Config) error { + g, err := scheme.Registry.Group("example.apiserver.code-generator.k8s.io") + if err != nil { + return err + } + + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + if config.GroupVersion == nil || config.GroupVersion.Group != g.GroupVersion.Group { + gv := g.GroupVersion + config.GroupVersion = &gv + } + config.NegotiatedSerializer = scheme.Codecs + + if config.QPS == 0 { + config.QPS = 5 + } + if config.Burst == 0 { + config.Burst = 10 + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ExampleClient) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/doc.go new file mode 100644 index 0000000000..63e2c8a082 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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 has the automatically generated clients. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_example_client.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_example_client.go new file mode 100644 index 0000000000..b8c081d955 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_example_client.go @@ -0,0 +1,38 @@ +/* +Copyright 2018 The Kubernetes 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion" +) + +type FakeExample struct { + *testing.Fake +} + +func (c *FakeExample) TestTypes(namespace string) internalversion.TestTypeInterface { + return &FakeTestTypes{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeExample) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go new file mode 100644 index 0000000000..bee016ecf5 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go @@ -0,0 +1,138 @@ +/* +Copyright 2018 The Kubernetes 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 ( + 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" + example "k8s.io/code-generator/_examples/apiserver/apis/example" +) + +// FakeTestTypes implements TestTypeInterface +type FakeTestTypes struct { + Fake *FakeExample + ns string +} + +var testtypesResource = schema.GroupVersionResource{Group: "example.apiserver.code-generator.k8s.io", Version: "", Resource: "testtypes"} + +var testtypesKind = schema.GroupVersionKind{Group: "example.apiserver.code-generator.k8s.io", Version: "", Kind: "TestType"} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example.TestType), err +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example.TestTypeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example.TestTypeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &example.TestTypeList{} + for _, item := range obj.(*example.TestTypeList).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 testTypes. +func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) + +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Create(testType *example.TestType) (result *example.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example.TestType), err +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Update(testType *example.TestType) (result *example.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example.TestType), 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 *FakeTestTypes) UpdateStatus(testType *example.TestType) (*example.TestType, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example.TestType), err +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example.TestType{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &example.TestTypeList{}) + return err +} + +// Patch applies the patch and returns the patched testType. +func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example.TestType), err +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/generated_expansion.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/generated_expansion.go new file mode 100644 index 0000000000..189d4e23f2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2018 The Kubernetes 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 internalversion + +type TestTypeExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/testtype.go new file mode 100644 index 0000000000..5077c0ca77 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/testtype.go @@ -0,0 +1,172 @@ +/* +Copyright 2018 The Kubernetes 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 internalversion + +import ( + 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" + example "k8s.io/code-generator/_examples/apiserver/apis/example" + scheme "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme" +) + +// TestTypesGetter has a method to return a TestTypeInterface. +// A group's client should implement this interface. +type TestTypesGetter interface { + TestTypes(namespace string) TestTypeInterface +} + +// TestTypeInterface has methods to work with TestType resources. +type TestTypeInterface interface { + Create(*example.TestType) (*example.TestType, error) + Update(*example.TestType) (*example.TestType, error) + UpdateStatus(*example.TestType) (*example.TestType, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*example.TestType, error) + List(opts v1.ListOptions) (*example.TestTypeList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example.TestType, err error) + TestTypeExpansion +} + +// testTypes implements TestTypeInterface +type testTypes struct { + client rest.Interface + ns string +} + +// newTestTypes returns a TestTypes +func newTestTypes(c *ExampleClient, namespace string) *testTypes { + return &testTypes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *testTypes) Get(name string, options v1.GetOptions) (result *example.TestType, err error) { + result = &example.TestType{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *testTypes) List(opts v1.ListOptions) (result *example.TestTypeList, err error) { + result = &example.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested testTypes. +func (c *testTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Create(testType *example.TestType) (result *example.TestType, err error) { + result = &example.TestType{} + err = c.client.Post(). + Namespace(c.ns). + Resource("testtypes"). + Body(testType). + Do(). + Into(result) + return +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Update(testType *example.TestType) (result *example.TestType, err error) { + result = &example.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + Body(testType). + 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 *testTypes) UpdateStatus(testType *example.TestType) (result *example.TestType, err error) { + result = &example.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + SubResource("status"). + Body(testType). + Do(). + Into(result) + return +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *testTypes) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *testTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched testType. +func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example.TestType, err error) { + result = &example.TestType{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("testtypes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/doc.go new file mode 100644 index 0000000000..8615019757 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated typed clients. +package internalversion diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/example2_client.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/example2_client.go new file mode 100644 index 0000000000..4939e1ec23 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/example2_client.go @@ -0,0 +1,99 @@ +/* +Copyright 2018 The Kubernetes 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 internalversion + +import ( + rest "k8s.io/client-go/rest" + "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme" +) + +type SecondExampleInterface interface { + RESTClient() rest.Interface + TestTypesGetter +} + +// SecondExampleClient is used to interact with features provided by the example.test.apiserver.code-generator.k8s.io group. +type SecondExampleClient struct { + restClient rest.Interface +} + +func (c *SecondExampleClient) TestTypes(namespace string) TestTypeInterface { + return newTestTypes(c, namespace) +} + +// NewForConfig creates a new SecondExampleClient for the given config. +func NewForConfig(c *rest.Config) (*SecondExampleClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &SecondExampleClient{client}, nil +} + +// NewForConfigOrDie creates a new SecondExampleClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SecondExampleClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SecondExampleClient for the given RESTClient. +func New(c rest.Interface) *SecondExampleClient { + return &SecondExampleClient{c} +} + +func setConfigDefaults(config *rest.Config) error { + g, err := scheme.Registry.Group("example.test.apiserver.code-generator.k8s.io") + if err != nil { + return err + } + + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + if config.GroupVersion == nil || config.GroupVersion.Group != g.GroupVersion.Group { + gv := g.GroupVersion + config.GroupVersion = &gv + } + config.NegotiatedSerializer = scheme.Codecs + + if config.QPS == 0 { + config.QPS = 5 + } + if config.Burst == 0 { + config.Burst = 10 + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *SecondExampleClient) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/doc.go new file mode 100644 index 0000000000..63e2c8a082 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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 has the automatically generated clients. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_example2_client.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_example2_client.go new file mode 100644 index 0000000000..ea617dc8ef --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_example2_client.go @@ -0,0 +1,38 @@ +/* +Copyright 2018 The Kubernetes 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion" +) + +type FakeSecondExample struct { + *testing.Fake +} + +func (c *FakeSecondExample) TestTypes(namespace string) internalversion.TestTypeInterface { + return &FakeTestTypes{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSecondExample) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go new file mode 100644 index 0000000000..0691a49567 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go @@ -0,0 +1,138 @@ +/* +Copyright 2018 The Kubernetes 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 ( + 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" + example2 "k8s.io/code-generator/_examples/apiserver/apis/example2" +) + +// FakeTestTypes implements TestTypeInterface +type FakeTestTypes struct { + Fake *FakeSecondExample + ns string +} + +var testtypesResource = schema.GroupVersionResource{Group: "example.test.apiserver.code-generator.k8s.io", Version: "", Resource: "testtypes"} + +var testtypesKind = schema.GroupVersionKind{Group: "example.test.apiserver.code-generator.k8s.io", Version: "", Kind: "TestType"} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2.TestType), err +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2.TestTypeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2.TestTypeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &example2.TestTypeList{} + for _, item := range obj.(*example2.TestTypeList).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 testTypes. +func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) + +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Create(testType *example2.TestType) (result *example2.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2.TestType), err +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Update(testType *example2.TestType) (result *example2.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2.TestType), 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 *FakeTestTypes) UpdateStatus(testType *example2.TestType) (*example2.TestType, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2.TestType), err +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2.TestType{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &example2.TestTypeList{}) + return err +} + +// Patch applies the patch and returns the patched testType. +func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example2.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2.TestType), err +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/generated_expansion.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/generated_expansion.go new file mode 100644 index 0000000000..189d4e23f2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2018 The Kubernetes 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 internalversion + +type TestTypeExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/testtype.go new file mode 100644 index 0000000000..10725f494b --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/testtype.go @@ -0,0 +1,172 @@ +/* +Copyright 2018 The Kubernetes 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 internalversion + +import ( + 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" + example2 "k8s.io/code-generator/_examples/apiserver/apis/example2" + scheme "k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme" +) + +// TestTypesGetter has a method to return a TestTypeInterface. +// A group's client should implement this interface. +type TestTypesGetter interface { + TestTypes(namespace string) TestTypeInterface +} + +// TestTypeInterface has methods to work with TestType resources. +type TestTypeInterface interface { + Create(*example2.TestType) (*example2.TestType, error) + Update(*example2.TestType) (*example2.TestType, error) + UpdateStatus(*example2.TestType) (*example2.TestType, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*example2.TestType, error) + List(opts v1.ListOptions) (*example2.TestTypeList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2.TestType, err error) + TestTypeExpansion +} + +// testTypes implements TestTypeInterface +type testTypes struct { + client rest.Interface + ns string +} + +// newTestTypes returns a TestTypes +func newTestTypes(c *SecondExampleClient, namespace string) *testTypes { + return &testTypes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *testTypes) Get(name string, options v1.GetOptions) (result *example2.TestType, err error) { + result = &example2.TestType{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *testTypes) List(opts v1.ListOptions) (result *example2.TestTypeList, err error) { + result = &example2.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested testTypes. +func (c *testTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Create(testType *example2.TestType) (result *example2.TestType, err error) { + result = &example2.TestType{} + err = c.client.Post(). + Namespace(c.ns). + Resource("testtypes"). + Body(testType). + Do(). + Into(result) + return +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Update(testType *example2.TestType) (result *example2.TestType, err error) { + result = &example2.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + Body(testType). + 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 *testTypes) UpdateStatus(testType *example2.TestType) (result *example2.TestType, err error) { + result = &example2.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + SubResource("status"). + Body(testType). + Do(). + Into(result) + return +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *testTypes) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *testTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched testType. +func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2.TestType, err error) { + result = &example2.TestType{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("testtypes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/clientset.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/clientset.go new file mode 100644 index 0000000000..86cca3b19f --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/clientset.go @@ -0,0 +1,120 @@ +/* +Copyright 2018 The Kubernetes 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 versioned + +import ( + glog "github.com/golang/glog" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" + examplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1" + secondexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + ExampleV1() examplev1.ExampleV1Interface + // Deprecated: please explicitly pick a version if possible. + Example() examplev1.ExampleV1Interface + SecondExampleV1() secondexamplev1.SecondExampleV1Interface + // Deprecated: please explicitly pick a version if possible. + SecondExample() secondexamplev1.SecondExampleV1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + exampleV1 *examplev1.ExampleV1Client + secondExampleV1 *secondexamplev1.SecondExampleV1Client +} + +// ExampleV1 retrieves the ExampleV1Client +func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface { + return c.exampleV1 +} + +// Deprecated: Example retrieves the default version of ExampleClient. +// Please explicitly pick a version. +func (c *Clientset) Example() examplev1.ExampleV1Interface { + return c.exampleV1 +} + +// SecondExampleV1 retrieves the SecondExampleV1Client +func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface { + return c.secondExampleV1 +} + +// Deprecated: SecondExample retrieves the default version of SecondExampleClient. +// Please explicitly pick a version. +func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface { + return c.secondExampleV1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.exampleV1, err = examplev1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.secondExampleV1, err = secondexamplev1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + glog.Errorf("failed to create the DiscoveryClient: %v", err) + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.exampleV1 = examplev1.NewForConfigOrDie(c) + cs.secondExampleV1 = secondexamplev1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.exampleV1 = examplev1.New(c) + cs.secondExampleV1 = secondexamplev1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/doc.go new file mode 100644 index 0000000000..9c6dfafa73 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated clientset. +package versioned diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/clientset_generated.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000000..2a692a5ca4 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,83 @@ +/* +Copyright 2018 The Kubernetes 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 ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" + clientset "k8s.io/code-generator/_examples/apiserver/clientset/versioned" + examplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1" + fakeexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake" + secondexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1" + fakesecondexamplev1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + fakePtr := testing.Fake{} + fakePtr.AddReactor("*", "*", testing.ObjectReaction(o)) + fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil)) + + return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}} +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +var _ clientset.Interface = &Clientset{} + +// ExampleV1 retrieves the ExampleV1Client +func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface { + return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake} +} + +// Example retrieves the ExampleV1Client +func (c *Clientset) Example() examplev1.ExampleV1Interface { + return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake} +} + +// SecondExampleV1 retrieves the SecondExampleV1Client +func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface { + return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake} +} + +// SecondExample retrieves the SecondExampleV1Client +func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface { + return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake} +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/doc.go new file mode 100644 index 0000000000..8a3101e398 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated fake clientset. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/register.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/register.go new file mode 100644 index 0000000000..b4a0ec52fa --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/register.go @@ -0,0 +1,55 @@ +/* +Copyright 2018 The Kubernetes 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 ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" + secondexamplev1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + AddToScheme(scheme) +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kuberentes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +func AddToScheme(scheme *runtime.Scheme) { + examplev1.AddToScheme(scheme) + secondexamplev1.AddToScheme(scheme) + +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000000..3d3ab5f4ed --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/register.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/register.go new file mode 100644 index 0000000000..cad0ee75cb --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/register.go @@ -0,0 +1,55 @@ +/* +Copyright 2018 The Kubernetes 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 scheme + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + examplev1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" + secondexamplev1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + AddToScheme(Scheme) +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kuberentes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +func AddToScheme(scheme *runtime.Scheme) { + examplev1.AddToScheme(scheme) + secondexamplev1.AddToScheme(scheme) + +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/doc.go new file mode 100644 index 0000000000..95b44dfa87 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated typed clients. +package v1 diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/example_client.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/example_client.go new file mode 100644 index 0000000000..407fa9e266 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/example_client.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +import ( + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" + v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" + "k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme" +) + +type ExampleV1Interface interface { + RESTClient() rest.Interface + TestTypesGetter +} + +// ExampleV1Client is used to interact with features provided by the example.apiserver.code-generator.k8s.io group. +type ExampleV1Client struct { + restClient rest.Interface +} + +func (c *ExampleV1Client) TestTypes(namespace string) TestTypeInterface { + return newTestTypes(c, namespace) +} + +// NewForConfig creates a new ExampleV1Client for the given config. +func NewForConfig(c *rest.Config) (*ExampleV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ExampleV1Client{client}, nil +} + +// NewForConfigOrDie creates a new ExampleV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ExampleV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ExampleV1Client for the given RESTClient. +func New(c rest.Interface) *ExampleV1Client { + return &ExampleV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ExampleV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/doc.go new file mode 100644 index 0000000000..63e2c8a082 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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 has the automatically generated clients. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_example_client.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_example_client.go new file mode 100644 index 0000000000..1a86363746 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_example_client.go @@ -0,0 +1,38 @@ +/* +Copyright 2018 The Kubernetes 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1" +) + +type FakeExampleV1 struct { + *testing.Fake +} + +func (c *FakeExampleV1) TestTypes(namespace string) v1.TestTypeInterface { + return &FakeTestTypes{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeExampleV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go new file mode 100644 index 0000000000..063d8cc79d --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go @@ -0,0 +1,138 @@ +/* +Copyright 2018 The Kubernetes 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 ( + 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" + example_v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" +) + +// FakeTestTypes implements TestTypeInterface +type FakeTestTypes struct { + Fake *FakeExampleV1 + ns string +} + +var testtypesResource = schema.GroupVersionResource{Group: "example.apiserver.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} + +var testtypesKind = schema.GroupVersionKind{Group: "example.apiserver.code-generator.k8s.io", Version: "v1", Kind: "TestType"} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), err +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example_v1.TestTypeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example_v1.TestTypeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &example_v1.TestTypeList{} + for _, item := range obj.(*example_v1.TestTypeList).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 testTypes. +func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) + +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Create(testType *example_v1.TestType) (result *example_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), err +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Update(testType *example_v1.TestType) (result *example_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), 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 *FakeTestTypes) UpdateStatus(testType *example_v1.TestType) (*example_v1.TestType, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), err +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example_v1.TestType{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &example_v1.TestTypeList{}) + return err +} + +// Patch applies the patch and returns the patched testType. +func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), err +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/generated_expansion.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/generated_expansion.go new file mode 100644 index 0000000000..4e2775e3a6 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +type TestTypeExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/testtype.go new file mode 100644 index 0000000000..70fded42a2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/testtype.go @@ -0,0 +1,172 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +import ( + meta_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" + v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" + scheme "k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme" +) + +// TestTypesGetter has a method to return a TestTypeInterface. +// A group's client should implement this interface. +type TestTypesGetter interface { + TestTypes(namespace string) TestTypeInterface +} + +// TestTypeInterface has methods to work with TestType resources. +type TestTypeInterface interface { + Create(*v1.TestType) (*v1.TestType, error) + Update(*v1.TestType) (*v1.TestType, error) + UpdateStatus(*v1.TestType) (*v1.TestType, error) + Delete(name string, options *meta_v1.DeleteOptions) error + DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error + Get(name string, options meta_v1.GetOptions) (*v1.TestType, error) + List(opts meta_v1.ListOptions) (*v1.TestTypeList, error) + Watch(opts meta_v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) + TestTypeExpansion +} + +// testTypes implements TestTypeInterface +type testTypes struct { + client rest.Interface + ns string +} + +// newTestTypes returns a TestTypes +func newTestTypes(c *ExampleV1Client, namespace string) *testTypes { + return &testTypes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *testTypes) List(opts meta_v1.ListOptions) (result *v1.TestTypeList, err error) { + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested testTypes. +func (c *testTypes) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Create(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Post(). + Namespace(c.ns). + Resource("testtypes"). + Body(testType). + Do(). + Into(result) + return +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Update(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + Body(testType). + 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 *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + SubResource("status"). + Body(testType). + Do(). + Into(result) + return +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched testType. +func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("testtypes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/doc.go new file mode 100644 index 0000000000..95b44dfa87 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated typed clients. +package v1 diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/example2_client.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/example2_client.go new file mode 100644 index 0000000000..552a87f8af --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/example2_client.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +import ( + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" + v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" + "k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme" +) + +type SecondExampleV1Interface interface { + RESTClient() rest.Interface + TestTypesGetter +} + +// SecondExampleV1Client is used to interact with features provided by the example.test.apiserver.code-generator.k8s.io group. +type SecondExampleV1Client struct { + restClient rest.Interface +} + +func (c *SecondExampleV1Client) TestTypes(namespace string) TestTypeInterface { + return newTestTypes(c, namespace) +} + +// NewForConfig creates a new SecondExampleV1Client for the given config. +func NewForConfig(c *rest.Config) (*SecondExampleV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &SecondExampleV1Client{client}, nil +} + +// NewForConfigOrDie creates a new SecondExampleV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SecondExampleV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SecondExampleV1Client for the given RESTClient. +func New(c rest.Interface) *SecondExampleV1Client { + return &SecondExampleV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *SecondExampleV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/doc.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/doc.go new file mode 100644 index 0000000000..63e2c8a082 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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 has the automatically generated clients. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go new file mode 100644 index 0000000000..43ad4e988c --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go @@ -0,0 +1,38 @@ +/* +Copyright 2018 The Kubernetes 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1 "k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1" +) + +type FakeSecondExampleV1 struct { + *testing.Fake +} + +func (c *FakeSecondExampleV1) TestTypes(namespace string) v1.TestTypeInterface { + return &FakeTestTypes{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSecondExampleV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go new file mode 100644 index 0000000000..12bbdcbe52 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go @@ -0,0 +1,138 @@ +/* +Copyright 2018 The Kubernetes 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 ( + 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" + example2_v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" +) + +// FakeTestTypes implements TestTypeInterface +type FakeTestTypes struct { + Fake *FakeSecondExampleV1 + ns string +} + +var testtypesResource = schema.GroupVersionResource{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} + +var testtypesKind = schema.GroupVersionKind{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1", Kind: "TestType"} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), err +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2_v1.TestTypeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2_v1.TestTypeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &example2_v1.TestTypeList{} + for _, item := range obj.(*example2_v1.TestTypeList).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 testTypes. +func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) + +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Create(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), err +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Update(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), 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 *FakeTestTypes) UpdateStatus(testType *example2_v1.TestType) (*example2_v1.TestType, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), err +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2_v1.TestType{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &example2_v1.TestTypeList{}) + return err +} + +// Patch applies the patch and returns the patched testType. +func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), err +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/generated_expansion.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/generated_expansion.go new file mode 100644 index 0000000000..4e2775e3a6 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +type TestTypeExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go new file mode 100644 index 0000000000..fa39745adf --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go @@ -0,0 +1,172 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +import ( + meta_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" + v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" + scheme "k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme" +) + +// TestTypesGetter has a method to return a TestTypeInterface. +// A group's client should implement this interface. +type TestTypesGetter interface { + TestTypes(namespace string) TestTypeInterface +} + +// TestTypeInterface has methods to work with TestType resources. +type TestTypeInterface interface { + Create(*v1.TestType) (*v1.TestType, error) + Update(*v1.TestType) (*v1.TestType, error) + UpdateStatus(*v1.TestType) (*v1.TestType, error) + Delete(name string, options *meta_v1.DeleteOptions) error + DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error + Get(name string, options meta_v1.GetOptions) (*v1.TestType, error) + List(opts meta_v1.ListOptions) (*v1.TestTypeList, error) + Watch(opts meta_v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) + TestTypeExpansion +} + +// testTypes implements TestTypeInterface +type testTypes struct { + client rest.Interface + ns string +} + +// newTestTypes returns a TestTypes +func newTestTypes(c *SecondExampleV1Client, namespace string) *testTypes { + return &testTypes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *testTypes) List(opts meta_v1.ListOptions) (result *v1.TestTypeList, err error) { + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested testTypes. +func (c *testTypes) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Create(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Post(). + Namespace(c.ns). + Resource("testtypes"). + Body(testType). + Do(). + Into(result) + return +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Update(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + Body(testType). + 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 *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + SubResource("status"). + Body(testType). + Do(). + Into(result) + return +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched testType. +func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("testtypes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/interface.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/interface.go new file mode 100644 index 0000000000..21d8874a0d --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package example + +import ( + v1 "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/interface.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/interface.go new file mode 100644 index 0000000000..21e19c623b --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package v1 + +import ( + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // TestTypes returns a TestTypeInformer. + TestTypes() TestTypeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// TestTypes returns a TestTypeInformer. +func (v *version) TestTypes() TestTypeInformer { + return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/testtype.go new file mode 100644 index 0000000000..0beb10fa72 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/testtype.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package v1 + +import ( + meta_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" + example_v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" + versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces" + v1 "k8s.io/code-generator/_examples/apiserver/listers/example/v1" + time "time" +) + +// TestTypeInformer provides access to a shared informer and lister for +// TestTypes. +type TestTypeInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.TestTypeLister +} + +type testTypeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTestTypeInformer constructs a new informer for TestType 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 NewTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTestTypeInformer constructs a new informer for TestType 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 NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ExampleV1().TestTypes(namespace).List(options) + }, + WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ExampleV1().TestTypes(namespace).Watch(options) + }, + }, + &example_v1.TestType{}, + resyncPeriod, + indexers, + ) +} + +func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *testTypeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&example_v1.TestType{}, f.defaultInformer) +} + +func (f *testTypeInformer) Lister() v1.TestTypeLister { + return v1.NewTestTypeLister(f.Informer().GetIndexer()) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/interface.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/interface.go new file mode 100644 index 0000000000..c6a0444687 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package example + +import ( + v1 "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/interface.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/interface.go new file mode 100644 index 0000000000..21e19c623b --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package v1 + +import ( + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // TestTypes returns a TestTypeInformer. + TestTypes() TestTypeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// TestTypes returns a TestTypeInformer. +func (v *version) TestTypes() TestTypeInformer { + return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/testtype.go new file mode 100644 index 0000000000..c07397c98a --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/testtype.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package v1 + +import ( + meta_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" + example2_v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" + versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces" + v1 "k8s.io/code-generator/_examples/apiserver/listers/example2/v1" + time "time" +) + +// TestTypeInformer provides access to a shared informer and lister for +// TestTypes. +type TestTypeInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.TestTypeLister +} + +type testTypeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTestTypeInformer constructs a new informer for TestType 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 NewTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTestTypeInformer constructs a new informer for TestType 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 NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SecondExampleV1().TestTypes(namespace).List(options) + }, + WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SecondExampleV1().TestTypes(namespace).Watch(options) + }, + }, + &example2_v1.TestType{}, + resyncPeriod, + indexers, + ) +} + +func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *testTypeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&example2_v1.TestType{}, f.defaultInformer) +} + +func (f *testTypeInformer) Lister() v1.TestTypeLister { + return v1.NewTestTypeLister(f.Informer().GetIndexer()) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/factory.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/factory.go new file mode 100644 index 0000000000..6b77479ee5 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/factory.go @@ -0,0 +1,136 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package externalversions + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned" + example "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example" + example2 "k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces" + reflect "reflect" + sync "sync" + time "time" +) + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewFilteredSharedInformerFactory(client, defaultResync, v1.NamespaceAll, nil) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return &sharedInformerFactory{ + client: client, + namespace: namespace, + tweakListOptions: tweakListOptions, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + } +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + informer = newFunc(f.client, f.defaultResync) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Example() example.Interface + SecondExample() example2.Interface +} + +func (f *sharedInformerFactory) Example() example.Interface { + return example.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) SecondExample() example2.Interface { + return example2.New(f, f.namespace, f.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/generic.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/generic.go new file mode 100644 index 0000000000..6fd29b0b41 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/generic.go @@ -0,0 +1,66 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package externalversions + +import ( + "fmt" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" + example2_v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=example.apiserver.code-generator.k8s.io, Version=v1 + case v1.SchemeGroupVersion.WithResource("testtypes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().TestTypes().Informer()}, nil + + // Group=example.test.apiserver.code-generator.k8s.io, Version=v1 + case example2_v1.SchemeGroupVersion.WithResource("testtypes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().V1().TestTypes().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces/factory_interfaces.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000000..31df120f6a --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,37 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalinterfaces + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" + versioned "k8s.io/code-generator/_examples/apiserver/clientset/versioned" + time "time" +) + +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/interface.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/interface.go new file mode 100644 index 0000000000..836e7e01b6 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package example + +import ( + internalversion "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // InternalVersion provides access to shared informers for resources in InternalVersion. + InternalVersion() internalversion.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// InternalVersion returns a new internalversion.Interface. +func (g *group) InternalVersion() internalversion.Interface { + return internalversion.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/interface.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/interface.go new file mode 100644 index 0000000000..5abe385230 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // TestTypes returns a TestTypeInformer. + TestTypes() TestTypeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// TestTypes returns a TestTypeInformer. +func (v *version) TestTypes() TestTypeInformer { + return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/testtype.go new file mode 100644 index 0000000000..5c1c1fe8dc --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/testtype.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + 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" + example "k8s.io/code-generator/_examples/apiserver/apis/example" + clientset_internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces" + internalversion "k8s.io/code-generator/_examples/apiserver/listers/example/internalversion" + time "time" +) + +// TestTypeInformer provides access to a shared informer and lister for +// TestTypes. +type TestTypeInformer interface { + Informer() cache.SharedIndexInformer + Lister() internalversion.TestTypeLister +} + +type testTypeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTestTypeInformer constructs a new informer for TestType 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 NewTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTestTypeInformer constructs a new informer for TestType 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 NewFilteredTestTypeInformer(client clientset_internalversion.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.Example().TestTypes(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.Example().TestTypes(namespace).Watch(options) + }, + }, + &example.TestType{}, + resyncPeriod, + indexers, + ) +} + +func (f *testTypeInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *testTypeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&example.TestType{}, f.defaultInformer) +} + +func (f *testTypeInformer) Lister() internalversion.TestTypeLister { + return internalversion.NewTestTypeLister(f.Informer().GetIndexer()) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/interface.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/interface.go new file mode 100644 index 0000000000..0656ffbdcd --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package example + +import ( + internalversion "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // InternalVersion provides access to shared informers for resources in InternalVersion. + InternalVersion() internalversion.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// InternalVersion returns a new internalversion.Interface. +func (g *group) InternalVersion() internalversion.Interface { + return internalversion.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/interface.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/interface.go new file mode 100644 index 0000000000..5abe385230 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // TestTypes returns a TestTypeInformer. + TestTypes() TestTypeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// TestTypes returns a TestTypeInformer. +func (v *version) TestTypes() TestTypeInformer { + return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/testtype.go new file mode 100644 index 0000000000..2c00c3d826 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/testtype.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + 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" + example2 "k8s.io/code-generator/_examples/apiserver/apis/example2" + clientset_internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces" + internalversion "k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion" + time "time" +) + +// TestTypeInformer provides access to a shared informer and lister for +// TestTypes. +type TestTypeInformer interface { + Informer() cache.SharedIndexInformer + Lister() internalversion.TestTypeLister +} + +type testTypeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTestTypeInformer constructs a new informer for TestType 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 NewTestTypeInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTestTypeInformer constructs a new informer for TestType 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 NewFilteredTestTypeInformer(client clientset_internalversion.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.SecondExample().TestTypes(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SecondExample().TestTypes(namespace).Watch(options) + }, + }, + &example2.TestType{}, + resyncPeriod, + indexers, + ) +} + +func (f *testTypeInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *testTypeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&example2.TestType{}, f.defaultInformer) +} + +func (f *testTypeInformer) Lister() internalversion.TestTypeLister { + return internalversion.NewTestTypeLister(f.Informer().GetIndexer()) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/factory.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/factory.go new file mode 100644 index 0000000000..fee4e7910b --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/factory.go @@ -0,0 +1,136 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion" + example "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example" + example2 "k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2" + internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces" + reflect "reflect" + sync "sync" + time "time" +) + +type sharedInformerFactory struct { + client internalversion.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory +func NewSharedInformerFactory(client internalversion.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewFilteredSharedInformerFactory(client, defaultResync, v1.NamespaceAll, nil) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +func NewFilteredSharedInformerFactory(client internalversion.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return &sharedInformerFactory{ + client: client, + namespace: namespace, + tweakListOptions: tweakListOptions, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + } +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + informer = newFunc(f.client, f.defaultResync) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Example() example.Interface + SecondExample() example2.Interface +} + +func (f *sharedInformerFactory) Example() example.Interface { + return example.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) SecondExample() example2.Interface { + return example2.New(f, f.namespace, f.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/generic.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/generic.go new file mode 100644 index 0000000000..bddd60f7b7 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/generic.go @@ -0,0 +1,66 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + "fmt" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + example "k8s.io/code-generator/_examples/apiserver/apis/example" + example2 "k8s.io/code-generator/_examples/apiserver/apis/example2" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=example.apiserver.code-generator.k8s.io, Version=internalVersion + case example.SchemeGroupVersion.WithResource("testtypes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Example().InternalVersion().TestTypes().Informer()}, nil + + // Group=example.test.apiserver.code-generator.k8s.io, Version=internalVersion + case example2.SchemeGroupVersion.WithResource("testtypes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().InternalVersion().TestTypes().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces/factory_interfaces.go b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000000..973d73d1de --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces/factory_interfaces.go @@ -0,0 +1,37 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalinterfaces + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" + internalversion "k8s.io/code-generator/_examples/apiserver/clientset/internalversion" + time "time" +) + +type NewInformerFunc func(internalversion.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/expansion_generated.go b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/expansion_generated.go new file mode 100644 index 0000000000..f308c16734 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package internalversion + +// TestTypeListerExpansion allows custom methods to be added to +// TestTypeLister. +type TestTypeListerExpansion interface{} + +// TestTypeNamespaceListerExpansion allows custom methods to be added to +// TestTypeNamespaceLister. +type TestTypeNamespaceListerExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/testtype.go new file mode 100644 index 0000000000..ccfe8f80fa --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/testtype.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package internalversion + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + example "k8s.io/code-generator/_examples/apiserver/apis/example" +) + +// TestTypeLister helps list TestTypes. +type TestTypeLister interface { + // List lists all TestTypes in the indexer. + List(selector labels.Selector) (ret []*example.TestType, err error) + // TestTypes returns an object that can list and get TestTypes. + TestTypes(namespace string) TestTypeNamespaceLister + TestTypeListerExpansion +} + +// testTypeLister implements the TestTypeLister interface. +type testTypeLister struct { + indexer cache.Indexer +} + +// NewTestTypeLister returns a new TestTypeLister. +func NewTestTypeLister(indexer cache.Indexer) TestTypeLister { + return &testTypeLister{indexer: indexer} +} + +// List lists all TestTypes in the indexer. +func (s *testTypeLister) List(selector labels.Selector) (ret []*example.TestType, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*example.TestType)) + }) + return ret, err +} + +// TestTypes returns an object that can list and get TestTypes. +func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister { + return testTypeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TestTypeNamespaceLister helps list and get TestTypes. +type TestTypeNamespaceLister interface { + // List lists all TestTypes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*example.TestType, err error) + // Get retrieves the TestType from the indexer for a given namespace and name. + Get(name string) (*example.TestType, error) + TestTypeNamespaceListerExpansion +} + +// testTypeNamespaceLister implements the TestTypeNamespaceLister +// interface. +type testTypeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all TestTypes in the indexer for a given namespace. +func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*example.TestType, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*example.TestType)) + }) + return ret, err +} + +// Get retrieves the TestType from the indexer for a given namespace and name. +func (s testTypeNamespaceLister) Get(name string) (*example.TestType, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(example.Resource("testtype"), name) + } + return obj.(*example.TestType), nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/expansion_generated.go b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/expansion_generated.go new file mode 100644 index 0000000000..d258c22f06 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package v1 + +// TestTypeListerExpansion allows custom methods to be added to +// TestTypeLister. +type TestTypeListerExpansion interface{} + +// TestTypeNamespaceListerExpansion allows custom methods to be added to +// TestTypeNamespaceLister. +type TestTypeNamespaceListerExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/testtype.go new file mode 100644 index 0000000000..5e420f12cf --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/testtype.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "k8s.io/code-generator/_examples/apiserver/apis/example/v1" +) + +// TestTypeLister helps list TestTypes. +type TestTypeLister interface { + // List lists all TestTypes in the indexer. + List(selector labels.Selector) (ret []*v1.TestType, err error) + // TestTypes returns an object that can list and get TestTypes. + TestTypes(namespace string) TestTypeNamespaceLister + TestTypeListerExpansion +} + +// testTypeLister implements the TestTypeLister interface. +type testTypeLister struct { + indexer cache.Indexer +} + +// NewTestTypeLister returns a new TestTypeLister. +func NewTestTypeLister(indexer cache.Indexer) TestTypeLister { + return &testTypeLister{indexer: indexer} +} + +// List lists all TestTypes in the indexer. +func (s *testTypeLister) List(selector labels.Selector) (ret []*v1.TestType, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.TestType)) + }) + return ret, err +} + +// TestTypes returns an object that can list and get TestTypes. +func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister { + return testTypeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TestTypeNamespaceLister helps list and get TestTypes. +type TestTypeNamespaceLister interface { + // List lists all TestTypes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.TestType, err error) + // Get retrieves the TestType from the indexer for a given namespace and name. + Get(name string) (*v1.TestType, error) + TestTypeNamespaceListerExpansion +} + +// testTypeNamespaceLister implements the TestTypeNamespaceLister +// interface. +type testTypeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all TestTypes in the indexer for a given namespace. +func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*v1.TestType, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.TestType)) + }) + return ret, err +} + +// Get retrieves the TestType from the indexer for a given namespace and name. +func (s testTypeNamespaceLister) Get(name string) (*v1.TestType, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("testtype"), name) + } + return obj.(*v1.TestType), nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/expansion_generated.go b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/expansion_generated.go new file mode 100644 index 0000000000..f308c16734 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package internalversion + +// TestTypeListerExpansion allows custom methods to be added to +// TestTypeLister. +type TestTypeListerExpansion interface{} + +// TestTypeNamespaceListerExpansion allows custom methods to be added to +// TestTypeNamespaceLister. +type TestTypeNamespaceListerExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/testtype.go new file mode 100644 index 0000000000..35abf86610 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/testtype.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package internalversion + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + example2 "k8s.io/code-generator/_examples/apiserver/apis/example2" +) + +// TestTypeLister helps list TestTypes. +type TestTypeLister interface { + // List lists all TestTypes in the indexer. + List(selector labels.Selector) (ret []*example2.TestType, err error) + // TestTypes returns an object that can list and get TestTypes. + TestTypes(namespace string) TestTypeNamespaceLister + TestTypeListerExpansion +} + +// testTypeLister implements the TestTypeLister interface. +type testTypeLister struct { + indexer cache.Indexer +} + +// NewTestTypeLister returns a new TestTypeLister. +func NewTestTypeLister(indexer cache.Indexer) TestTypeLister { + return &testTypeLister{indexer: indexer} +} + +// List lists all TestTypes in the indexer. +func (s *testTypeLister) List(selector labels.Selector) (ret []*example2.TestType, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*example2.TestType)) + }) + return ret, err +} + +// TestTypes returns an object that can list and get TestTypes. +func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister { + return testTypeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TestTypeNamespaceLister helps list and get TestTypes. +type TestTypeNamespaceLister interface { + // List lists all TestTypes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*example2.TestType, err error) + // Get retrieves the TestType from the indexer for a given namespace and name. + Get(name string) (*example2.TestType, error) + TestTypeNamespaceListerExpansion +} + +// testTypeNamespaceLister implements the TestTypeNamespaceLister +// interface. +type testTypeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all TestTypes in the indexer for a given namespace. +func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*example2.TestType, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*example2.TestType)) + }) + return ret, err +} + +// Get retrieves the TestType from the indexer for a given namespace and name. +func (s testTypeNamespaceLister) Get(name string) (*example2.TestType, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(example2.Resource("testtype"), name) + } + return obj.(*example2.TestType), nil +} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/expansion_generated.go b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/expansion_generated.go new file mode 100644 index 0000000000..d258c22f06 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package v1 + +// TestTypeListerExpansion allows custom methods to be added to +// TestTypeLister. +type TestTypeListerExpansion interface{} + +// TestTypeNamespaceListerExpansion allows custom methods to be added to +// TestTypeNamespaceLister. +type TestTypeNamespaceListerExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/testtype.go new file mode 100644 index 0000000000..65f5a58b93 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/testtype.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "k8s.io/code-generator/_examples/apiserver/apis/example2/v1" +) + +// TestTypeLister helps list TestTypes. +type TestTypeLister interface { + // List lists all TestTypes in the indexer. + List(selector labels.Selector) (ret []*v1.TestType, err error) + // TestTypes returns an object that can list and get TestTypes. + TestTypes(namespace string) TestTypeNamespaceLister + TestTypeListerExpansion +} + +// testTypeLister implements the TestTypeLister interface. +type testTypeLister struct { + indexer cache.Indexer +} + +// NewTestTypeLister returns a new TestTypeLister. +func NewTestTypeLister(indexer cache.Indexer) TestTypeLister { + return &testTypeLister{indexer: indexer} +} + +// List lists all TestTypes in the indexer. +func (s *testTypeLister) List(selector labels.Selector) (ret []*v1.TestType, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.TestType)) + }) + return ret, err +} + +// TestTypes returns an object that can list and get TestTypes. +func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister { + return testTypeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TestTypeNamespaceLister helps list and get TestTypes. +type TestTypeNamespaceLister interface { + // List lists all TestTypes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.TestType, err error) + // Get retrieves the TestType from the indexer for a given namespace and name. + Get(name string) (*v1.TestType, error) + TestTypeNamespaceListerExpansion +} + +// testTypeNamespaceLister implements the TestTypeNamespaceLister +// interface. +type testTypeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all TestTypes in the indexer for a given namespace. +func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*v1.TestType, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.TestType)) + }) + return ret, err +} + +// Get retrieves the TestType from the indexer for a given namespace and name. +func (s testTypeNamespaceLister) Get(name string) (*v1.TestType, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("testtype"), name) + } + return obj.(*v1.TestType), nil +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/doc.go b/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/doc.go new file mode 100644 index 0000000000..08f1279fb8 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes 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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=example.crd.code-generator.k8s.io +package v1 diff --git a/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/register.go b/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/register.go new file mode 100644 index 0000000000..58371e0e94 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/register.go @@ -0,0 +1,59 @@ +/* +Copyright 2015 The Kubernetes 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 v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var SchemeGroupVersion = schema.GroupVersion{Group: "example.crd.code-generator.k8s.io", Version: "v1"} + +var ( + // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &TestType{}, + &TestTypeList{}, + ) + + scheme.AddKnownTypes(SchemeGroupVersion, + &metav1.Status{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/types.go b/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/types.go new file mode 100644 index 0000000000..5c2ebc4d6f --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/types.go @@ -0,0 +1,47 @@ +/* +Copyright 2015 The Kubernetes 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 v1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestType is a top-level type. A client is created for it. +type TestType struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional + Status TestTypeStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestTypeList is a top-level list type. The client methods for lists are automatically created. +// You are not supposed to create a separated client for this one. +type TestTypeList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []TestType `json:"items"` +} + +type TestTypeStatus struct { + Blah string +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/zz_generated.deepcopy.go b/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..96771586c7 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/zz_generated.deepcopy.go @@ -0,0 +1,103 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package v1 + +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 *TestType) DeepCopyInto(out *TestType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. +func (in *TestType) DeepCopy() *TestType { + if in == nil { + return nil + } + out := new(TestType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeList) DeepCopyInto(out *TestTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TestType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeList. +func (in *TestTypeList) DeepCopy() *TestTypeList { + if in == nil { + return nil + } + out := new(TestTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeStatus) DeepCopyInto(out *TestTypeStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeStatus. +func (in *TestTypeStatus) DeepCopy() *TestTypeStatus { + if in == nil { + return nil + } + out := new(TestTypeStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/doc.go b/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/doc.go new file mode 100644 index 0000000000..702b716348 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 The Kubernetes 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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=example.test.crd.code-generator.k8s.io +// +groupGoName=SecondExample +package v1 diff --git a/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/register.go b/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/register.go new file mode 100644 index 0000000000..d0a852a310 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/register.go @@ -0,0 +1,59 @@ +/* +Copyright 2015 The Kubernetes 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 v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var SchemeGroupVersion = schema.GroupVersion{Group: "example.test.crd.code-generator.k8s.io", Version: "v1"} + +var ( + // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &TestType{}, + &TestTypeList{}, + ) + + scheme.AddKnownTypes(SchemeGroupVersion, + &metav1.Status{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/types.go b/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/types.go new file mode 100644 index 0000000000..5c2ebc4d6f --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/types.go @@ -0,0 +1,47 @@ +/* +Copyright 2015 The Kubernetes 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 v1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestType is a top-level type. A client is created for it. +type TestType struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional + Status TestTypeStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TestTypeList is a top-level list type. The client methods for lists are automatically created. +// You are not supposed to create a separated client for this one. +type TestTypeList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []TestType `json:"items"` +} + +type TestTypeStatus struct { + Blah string +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/zz_generated.deepcopy.go b/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..96771586c7 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/zz_generated.deepcopy.go @@ -0,0 +1,103 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package v1 + +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 *TestType) DeepCopyInto(out *TestType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. +func (in *TestType) DeepCopy() *TestType { + if in == nil { + return nil + } + out := new(TestType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeList) DeepCopyInto(out *TestTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TestType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeList. +func (in *TestTypeList) DeepCopy() *TestTypeList { + if in == nil { + return nil + } + out := new(TestTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TestTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTypeStatus) DeepCopyInto(out *TestTypeStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTypeStatus. +func (in *TestTypeStatus) DeepCopy() *TestTypeStatus { + if in == nil { + return nil + } + out := new(TestTypeStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/clientset.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/clientset.go new file mode 100644 index 0000000000..c0c581df82 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/clientset.go @@ -0,0 +1,120 @@ +/* +Copyright 2018 The Kubernetes 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 versioned + +import ( + glog "github.com/golang/glog" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" + examplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1" + secondexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + ExampleV1() examplev1.ExampleV1Interface + // Deprecated: please explicitly pick a version if possible. + Example() examplev1.ExampleV1Interface + SecondExampleV1() secondexamplev1.SecondExampleV1Interface + // Deprecated: please explicitly pick a version if possible. + SecondExample() secondexamplev1.SecondExampleV1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + exampleV1 *examplev1.ExampleV1Client + secondExampleV1 *secondexamplev1.SecondExampleV1Client +} + +// ExampleV1 retrieves the ExampleV1Client +func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface { + return c.exampleV1 +} + +// Deprecated: Example retrieves the default version of ExampleClient. +// Please explicitly pick a version. +func (c *Clientset) Example() examplev1.ExampleV1Interface { + return c.exampleV1 +} + +// SecondExampleV1 retrieves the SecondExampleV1Client +func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface { + return c.secondExampleV1 +} + +// Deprecated: SecondExample retrieves the default version of SecondExampleClient. +// Please explicitly pick a version. +func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface { + return c.secondExampleV1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.exampleV1, err = examplev1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.secondExampleV1, err = secondexamplev1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + glog.Errorf("failed to create the DiscoveryClient: %v", err) + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.exampleV1 = examplev1.NewForConfigOrDie(c) + cs.secondExampleV1 = secondexamplev1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.exampleV1 = examplev1.New(c) + cs.secondExampleV1 = secondexamplev1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/doc.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/doc.go new file mode 100644 index 0000000000..9c6dfafa73 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated clientset. +package versioned diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/clientset_generated.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000000..7fd60de7b2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,83 @@ +/* +Copyright 2018 The Kubernetes 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 ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" + clientset "k8s.io/code-generator/_examples/crd/clientset/versioned" + examplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1" + fakeexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake" + secondexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1" + fakesecondexamplev1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + fakePtr := testing.Fake{} + fakePtr.AddReactor("*", "*", testing.ObjectReaction(o)) + fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil)) + + return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}} +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +var _ clientset.Interface = &Clientset{} + +// ExampleV1 retrieves the ExampleV1Client +func (c *Clientset) ExampleV1() examplev1.ExampleV1Interface { + return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake} +} + +// Example retrieves the ExampleV1Client +func (c *Clientset) Example() examplev1.ExampleV1Interface { + return &fakeexamplev1.FakeExampleV1{Fake: &c.Fake} +} + +// SecondExampleV1 retrieves the SecondExampleV1Client +func (c *Clientset) SecondExampleV1() secondexamplev1.SecondExampleV1Interface { + return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake} +} + +// SecondExample retrieves the SecondExampleV1Client +func (c *Clientset) SecondExample() secondexamplev1.SecondExampleV1Interface { + return &fakesecondexamplev1.FakeSecondExampleV1{Fake: &c.Fake} +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/doc.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/doc.go new file mode 100644 index 0000000000..8a3101e398 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated fake clientset. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/register.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/register.go new file mode 100644 index 0000000000..79d9250433 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/register.go @@ -0,0 +1,55 @@ +/* +Copyright 2018 The Kubernetes 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 ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1" + secondexamplev1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + AddToScheme(scheme) +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kuberentes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +func AddToScheme(scheme *runtime.Scheme) { + examplev1.AddToScheme(scheme) + secondexamplev1.AddToScheme(scheme) + +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/doc.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000000..3d3ab5f4ed --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/register.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/register.go new file mode 100644 index 0000000000..1b55c1cf0d --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/register.go @@ -0,0 +1,55 @@ +/* +Copyright 2018 The Kubernetes 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 scheme + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + examplev1 "k8s.io/code-generator/_examples/crd/apis/example/v1" + secondexamplev1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + AddToScheme(Scheme) +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kuberentes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +func AddToScheme(scheme *runtime.Scheme) { + examplev1.AddToScheme(scheme) + secondexamplev1.AddToScheme(scheme) + +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/doc.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/doc.go new file mode 100644 index 0000000000..95b44dfa87 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated typed clients. +package v1 diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/example_client.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/example_client.go new file mode 100644 index 0000000000..1e282aa17a --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/example_client.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +import ( + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" + v1 "k8s.io/code-generator/_examples/crd/apis/example/v1" + "k8s.io/code-generator/_examples/crd/clientset/versioned/scheme" +) + +type ExampleV1Interface interface { + RESTClient() rest.Interface + TestTypesGetter +} + +// ExampleV1Client is used to interact with features provided by the example.crd.code-generator.k8s.io group. +type ExampleV1Client struct { + restClient rest.Interface +} + +func (c *ExampleV1Client) TestTypes(namespace string) TestTypeInterface { + return newTestTypes(c, namespace) +} + +// NewForConfig creates a new ExampleV1Client for the given config. +func NewForConfig(c *rest.Config) (*ExampleV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ExampleV1Client{client}, nil +} + +// NewForConfigOrDie creates a new ExampleV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ExampleV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ExampleV1Client for the given RESTClient. +func New(c rest.Interface) *ExampleV1Client { + return &ExampleV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ExampleV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/doc.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/doc.go new file mode 100644 index 0000000000..63e2c8a082 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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 has the automatically generated clients. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_example_client.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_example_client.go new file mode 100644 index 0000000000..c7bf2dfc42 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_example_client.go @@ -0,0 +1,38 @@ +/* +Copyright 2018 The Kubernetes 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1" +) + +type FakeExampleV1 struct { + *testing.Fake +} + +func (c *FakeExampleV1) TestTypes(namespace string) v1.TestTypeInterface { + return &FakeTestTypes{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeExampleV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go new file mode 100644 index 0000000000..124396f2f2 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go @@ -0,0 +1,138 @@ +/* +Copyright 2018 The Kubernetes 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 ( + 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" + example_v1 "k8s.io/code-generator/_examples/crd/apis/example/v1" +) + +// FakeTestTypes implements TestTypeInterface +type FakeTestTypes struct { + Fake *FakeExampleV1 + ns string +} + +var testtypesResource = schema.GroupVersionResource{Group: "example.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} + +var testtypesKind = schema.GroupVersionKind{Group: "example.crd.code-generator.k8s.io", Version: "v1", Kind: "TestType"} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), err +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example_v1.TestTypeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example_v1.TestTypeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &example_v1.TestTypeList{} + for _, item := range obj.(*example_v1.TestTypeList).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 testTypes. +func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) + +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Create(testType *example_v1.TestType) (result *example_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), err +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Update(testType *example_v1.TestType) (result *example_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), 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 *FakeTestTypes) UpdateStatus(testType *example_v1.TestType) (*example_v1.TestType, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), err +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example_v1.TestType{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &example_v1.TestTypeList{}) + return err +} + +// Patch applies the patch and returns the patched testType. +func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example_v1.TestType), err +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/generated_expansion.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/generated_expansion.go new file mode 100644 index 0000000000..4e2775e3a6 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +type TestTypeExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/testtype.go new file mode 100644 index 0000000000..460b68abfb --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/testtype.go @@ -0,0 +1,172 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +import ( + meta_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" + v1 "k8s.io/code-generator/_examples/crd/apis/example/v1" + scheme "k8s.io/code-generator/_examples/crd/clientset/versioned/scheme" +) + +// TestTypesGetter has a method to return a TestTypeInterface. +// A group's client should implement this interface. +type TestTypesGetter interface { + TestTypes(namespace string) TestTypeInterface +} + +// TestTypeInterface has methods to work with TestType resources. +type TestTypeInterface interface { + Create(*v1.TestType) (*v1.TestType, error) + Update(*v1.TestType) (*v1.TestType, error) + UpdateStatus(*v1.TestType) (*v1.TestType, error) + Delete(name string, options *meta_v1.DeleteOptions) error + DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error + Get(name string, options meta_v1.GetOptions) (*v1.TestType, error) + List(opts meta_v1.ListOptions) (*v1.TestTypeList, error) + Watch(opts meta_v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) + TestTypeExpansion +} + +// testTypes implements TestTypeInterface +type testTypes struct { + client rest.Interface + ns string +} + +// newTestTypes returns a TestTypes +func newTestTypes(c *ExampleV1Client, namespace string) *testTypes { + return &testTypes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *testTypes) List(opts meta_v1.ListOptions) (result *v1.TestTypeList, err error) { + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested testTypes. +func (c *testTypes) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Create(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Post(). + Namespace(c.ns). + Resource("testtypes"). + Body(testType). + Do(). + Into(result) + return +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Update(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + Body(testType). + 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 *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + SubResource("status"). + Body(testType). + Do(). + Into(result) + return +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched testType. +func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("testtypes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/doc.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/doc.go new file mode 100644 index 0000000000..95b44dfa87 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This package has the automatically generated typed clients. +package v1 diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/example2_client.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/example2_client.go new file mode 100644 index 0000000000..a753b9689b --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/example2_client.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +import ( + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" + v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" + "k8s.io/code-generator/_examples/crd/clientset/versioned/scheme" +) + +type SecondExampleV1Interface interface { + RESTClient() rest.Interface + TestTypesGetter +} + +// SecondExampleV1Client is used to interact with features provided by the example.test.crd.code-generator.k8s.io group. +type SecondExampleV1Client struct { + restClient rest.Interface +} + +func (c *SecondExampleV1Client) TestTypes(namespace string) TestTypeInterface { + return newTestTypes(c, namespace) +} + +// NewForConfig creates a new SecondExampleV1Client for the given config. +func NewForConfig(c *rest.Config) (*SecondExampleV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &SecondExampleV1Client{client}, nil +} + +// NewForConfigOrDie creates a new SecondExampleV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SecondExampleV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SecondExampleV1Client for the given RESTClient. +func New(c rest.Interface) *SecondExampleV1Client { + return &SecondExampleV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *SecondExampleV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/doc.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/doc.go new file mode 100644 index 0000000000..63e2c8a082 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2018 The Kubernetes 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 has the automatically generated clients. +package fake diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go new file mode 100644 index 0000000000..89e64d6484 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go @@ -0,0 +1,38 @@ +/* +Copyright 2018 The Kubernetes 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1 "k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1" +) + +type FakeSecondExampleV1 struct { + *testing.Fake +} + +func (c *FakeSecondExampleV1) TestTypes(namespace string) v1.TestTypeInterface { + return &FakeTestTypes{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSecondExampleV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go new file mode 100644 index 0000000000..ccba168aa3 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go @@ -0,0 +1,138 @@ +/* +Copyright 2018 The Kubernetes 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 ( + 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" + example2_v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" +) + +// FakeTestTypes implements TestTypeInterface +type FakeTestTypes struct { + Fake *FakeSecondExampleV1 + ns string +} + +var testtypesResource = schema.GroupVersionResource{Group: "example.test.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} + +var testtypesKind = schema.GroupVersionKind{Group: "example.test.crd.code-generator.k8s.io", Version: "v1", Kind: "TestType"} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *FakeTestTypes) Get(name string, options v1.GetOptions) (result *example2_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), err +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *FakeTestTypes) List(opts v1.ListOptions) (result *example2_v1.TestTypeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2_v1.TestTypeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &example2_v1.TestTypeList{} + for _, item := range obj.(*example2_v1.TestTypeList).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 testTypes. +func (c *FakeTestTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) + +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Create(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), err +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *FakeTestTypes) Update(testType *example2_v1.TestType) (result *example2_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), 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 *FakeTestTypes) UpdateStatus(testType *example2_v1.TestType) (*example2_v1.TestType, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), err +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *FakeTestTypes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(testtypesResource, c.ns, name), &example2_v1.TestType{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTestTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &example2_v1.TestTypeList{}) + return err +} + +// Patch applies the patch and returns the patched testType. +func (c *FakeTestTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *example2_v1.TestType, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, data, subresources...), &example2_v1.TestType{}) + + if obj == nil { + return nil, err + } + return obj.(*example2_v1.TestType), err +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/generated_expansion.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/generated_expansion.go new file mode 100644 index 0000000000..4e2775e3a6 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +type TestTypeExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/testtype.go new file mode 100644 index 0000000000..bf6b4de43c --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/testtype.go @@ -0,0 +1,172 @@ +/* +Copyright 2018 The Kubernetes 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 v1 + +import ( + meta_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" + v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" + scheme "k8s.io/code-generator/_examples/crd/clientset/versioned/scheme" +) + +// TestTypesGetter has a method to return a TestTypeInterface. +// A group's client should implement this interface. +type TestTypesGetter interface { + TestTypes(namespace string) TestTypeInterface +} + +// TestTypeInterface has methods to work with TestType resources. +type TestTypeInterface interface { + Create(*v1.TestType) (*v1.TestType, error) + Update(*v1.TestType) (*v1.TestType, error) + UpdateStatus(*v1.TestType) (*v1.TestType, error) + Delete(name string, options *meta_v1.DeleteOptions) error + DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error + Get(name string, options meta_v1.GetOptions) (*v1.TestType, error) + List(opts meta_v1.ListOptions) (*v1.TestTypeList, error) + Watch(opts meta_v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) + TestTypeExpansion +} + +// testTypes implements TestTypeInterface +type testTypes struct { + client rest.Interface + ns string +} + +// newTestTypes returns a TestTypes +func newTestTypes(c *SecondExampleV1Client, namespace string) *testTypes { + return &testTypes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. +func (c *testTypes) Get(name string, options meta_v1.GetOptions) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of TestTypes that match those selectors. +func (c *testTypes) List(opts meta_v1.ListOptions) (result *v1.TestTypeList, err error) { + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested testTypes. +func (c *testTypes) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Create(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Post(). + Namespace(c.ns). + Resource("testtypes"). + Body(testType). + Do(). + Into(result) + return +} + +// Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. +func (c *testTypes) Update(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + Body(testType). + 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 *testTypes) UpdateStatus(testType *v1.TestType) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("testtypes"). + Name(testType.Name). + SubResource("status"). + Body(testType). + Do(). + Into(result) + return +} + +// Delete takes name of the testType and deletes it. Returns an error if one occurs. +func (c *testTypes) Delete(name string, options *meta_v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *testTypes) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched testType. +func (c *testTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.TestType, err error) { + result = &v1.TestType{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("testtypes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/interface.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/interface.go new file mode 100644 index 0000000000..d74e15f5cf --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package example + +import ( + v1 "k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1" + internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/interface.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/interface.go new file mode 100644 index 0000000000..d0a447bda6 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package v1 + +import ( + internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // TestTypes returns a TestTypeInformer. + TestTypes() TestTypeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// TestTypes returns a TestTypeInformer. +func (v *version) TestTypes() TestTypeInformer { + return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/testtype.go new file mode 100644 index 0000000000..7fe59ce3e3 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/testtype.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package v1 + +import ( + meta_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" + example_v1 "k8s.io/code-generator/_examples/crd/apis/example/v1" + versioned "k8s.io/code-generator/_examples/crd/clientset/versioned" + internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces" + v1 "k8s.io/code-generator/_examples/crd/listers/example/v1" + time "time" +) + +// TestTypeInformer provides access to a shared informer and lister for +// TestTypes. +type TestTypeInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.TestTypeLister +} + +type testTypeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTestTypeInformer constructs a new informer for TestType 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 NewTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTestTypeInformer constructs a new informer for TestType 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 NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ExampleV1().TestTypes(namespace).List(options) + }, + WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ExampleV1().TestTypes(namespace).Watch(options) + }, + }, + &example_v1.TestType{}, + resyncPeriod, + indexers, + ) +} + +func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *testTypeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&example_v1.TestType{}, f.defaultInformer) +} + +func (f *testTypeInformer) Lister() v1.TestTypeLister { + return v1.NewTestTypeLister(f.Informer().GetIndexer()) +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/interface.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/interface.go new file mode 100644 index 0000000000..d58b0edb4d --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package example + +import ( + v1 "k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1" + internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/interface.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/interface.go new file mode 100644 index 0000000000..d0a447bda6 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package v1 + +import ( + internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // TestTypes returns a TestTypeInformer. + TestTypes() TestTypeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// TestTypes returns a TestTypeInformer. +func (v *version) TestTypes() TestTypeInformer { + return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/testtype.go new file mode 100644 index 0000000000..303b347364 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/testtype.go @@ -0,0 +1,88 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package v1 + +import ( + meta_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" + example2_v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" + versioned "k8s.io/code-generator/_examples/crd/clientset/versioned" + internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces" + v1 "k8s.io/code-generator/_examples/crd/listers/example2/v1" + time "time" +) + +// TestTypeInformer provides access to a shared informer and lister for +// TestTypes. +type TestTypeInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.TestTypeLister +} + +type testTypeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTestTypeInformer constructs a new informer for TestType 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 NewTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTestTypeInformer constructs a new informer for TestType 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 NewFilteredTestTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SecondExampleV1().TestTypes(namespace).List(options) + }, + WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SecondExampleV1().TestTypes(namespace).Watch(options) + }, + }, + &example2_v1.TestType{}, + resyncPeriod, + indexers, + ) +} + +func (f *testTypeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTestTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *testTypeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&example2_v1.TestType{}, f.defaultInformer) +} + +func (f *testTypeInformer) Lister() v1.TestTypeLister { + return v1.NewTestTypeLister(f.Informer().GetIndexer()) +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/factory.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/factory.go new file mode 100644 index 0000000000..2d0b35f969 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/factory.go @@ -0,0 +1,136 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package externalversions + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + versioned "k8s.io/code-generator/_examples/crd/clientset/versioned" + example "k8s.io/code-generator/_examples/crd/informers/externalversions/example" + example2 "k8s.io/code-generator/_examples/crd/informers/externalversions/example2" + internalinterfaces "k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces" + reflect "reflect" + sync "sync" + time "time" +) + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewFilteredSharedInformerFactory(client, defaultResync, v1.NamespaceAll, nil) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return &sharedInformerFactory{ + client: client, + namespace: namespace, + tweakListOptions: tweakListOptions, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + } +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + informer = newFunc(f.client, f.defaultResync) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Example() example.Interface + SecondExample() example2.Interface +} + +func (f *sharedInformerFactory) Example() example.Interface { + return example.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) SecondExample() example2.Interface { + return example2.New(f, f.namespace, f.tweakListOptions) +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/generic.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/generic.go new file mode 100644 index 0000000000..25acc5078e --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/generic.go @@ -0,0 +1,66 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package externalversions + +import ( + "fmt" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + v1 "k8s.io/code-generator/_examples/crd/apis/example/v1" + example2_v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=example.crd.code-generator.k8s.io, Version=v1 + case v1.SchemeGroupVersion.WithResource("testtypes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Example().V1().TestTypes().Informer()}, nil + + // Group=example.test.crd.code-generator.k8s.io, Version=v1 + case example2_v1.SchemeGroupVersion.WithResource("testtypes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().V1().TestTypes().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces/factory_interfaces.go b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000000..b8da4f9fc7 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,37 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by informer-gen + +package internalinterfaces + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" + versioned "k8s.io/code-generator/_examples/crd/clientset/versioned" + time "time" +) + +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/expansion_generated.go b/vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/expansion_generated.go new file mode 100644 index 0000000000..d258c22f06 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package v1 + +// TestTypeListerExpansion allows custom methods to be added to +// TestTypeLister. +type TestTypeListerExpansion interface{} + +// TestTypeNamespaceListerExpansion allows custom methods to be added to +// TestTypeNamespaceLister. +type TestTypeNamespaceListerExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/testtype.go new file mode 100644 index 0000000000..ce132fd2f9 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/testtype.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "k8s.io/code-generator/_examples/crd/apis/example/v1" +) + +// TestTypeLister helps list TestTypes. +type TestTypeLister interface { + // List lists all TestTypes in the indexer. + List(selector labels.Selector) (ret []*v1.TestType, err error) + // TestTypes returns an object that can list and get TestTypes. + TestTypes(namespace string) TestTypeNamespaceLister + TestTypeListerExpansion +} + +// testTypeLister implements the TestTypeLister interface. +type testTypeLister struct { + indexer cache.Indexer +} + +// NewTestTypeLister returns a new TestTypeLister. +func NewTestTypeLister(indexer cache.Indexer) TestTypeLister { + return &testTypeLister{indexer: indexer} +} + +// List lists all TestTypes in the indexer. +func (s *testTypeLister) List(selector labels.Selector) (ret []*v1.TestType, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.TestType)) + }) + return ret, err +} + +// TestTypes returns an object that can list and get TestTypes. +func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister { + return testTypeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TestTypeNamespaceLister helps list and get TestTypes. +type TestTypeNamespaceLister interface { + // List lists all TestTypes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.TestType, err error) + // Get retrieves the TestType from the indexer for a given namespace and name. + Get(name string) (*v1.TestType, error) + TestTypeNamespaceListerExpansion +} + +// testTypeNamespaceLister implements the TestTypeNamespaceLister +// interface. +type testTypeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all TestTypes in the indexer for a given namespace. +func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*v1.TestType, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.TestType)) + }) + return ret, err +} + +// Get retrieves the TestType from the indexer for a given namespace and name. +func (s testTypeNamespaceLister) Get(name string) (*v1.TestType, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("testtype"), name) + } + return obj.(*v1.TestType), nil +} diff --git a/vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/expansion_generated.go b/vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/expansion_generated.go new file mode 100644 index 0000000000..d258c22f06 --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package v1 + +// TestTypeListerExpansion allows custom methods to be added to +// TestTypeLister. +type TestTypeListerExpansion interface{} + +// TestTypeNamespaceListerExpansion allows custom methods to be added to +// TestTypeNamespaceLister. +type TestTypeNamespaceListerExpansion interface{} diff --git a/vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/testtype.go b/vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/testtype.go new file mode 100644 index 0000000000..a7ad6062cc --- /dev/null +++ b/vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/testtype.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 The Kubernetes 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. +*/ + +// This file was automatically generated by lister-gen + +package v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "k8s.io/code-generator/_examples/crd/apis/example2/v1" +) + +// TestTypeLister helps list TestTypes. +type TestTypeLister interface { + // List lists all TestTypes in the indexer. + List(selector labels.Selector) (ret []*v1.TestType, err error) + // TestTypes returns an object that can list and get TestTypes. + TestTypes(namespace string) TestTypeNamespaceLister + TestTypeListerExpansion +} + +// testTypeLister implements the TestTypeLister interface. +type testTypeLister struct { + indexer cache.Indexer +} + +// NewTestTypeLister returns a new TestTypeLister. +func NewTestTypeLister(indexer cache.Indexer) TestTypeLister { + return &testTypeLister{indexer: indexer} +} + +// List lists all TestTypes in the indexer. +func (s *testTypeLister) List(selector labels.Selector) (ret []*v1.TestType, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.TestType)) + }) + return ret, err +} + +// TestTypes returns an object that can list and get TestTypes. +func (s *testTypeLister) TestTypes(namespace string) TestTypeNamespaceLister { + return testTypeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TestTypeNamespaceLister helps list and get TestTypes. +type TestTypeNamespaceLister interface { + // List lists all TestTypes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.TestType, err error) + // Get retrieves the TestType from the indexer for a given namespace and name. + Get(name string) (*v1.TestType, error) + TestTypeNamespaceListerExpansion +} + +// testTypeNamespaceLister implements the TestTypeNamespaceLister +// interface. +type testTypeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all TestTypes in the indexer for a given namespace. +func (s testTypeNamespaceLister) List(selector labels.Selector) (ret []*v1.TestType, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.TestType)) + }) + return ret, err +} + +// Get retrieves the TestType from the indexer for a given namespace and name. +func (s testTypeNamespaceLister) Get(name string) (*v1.TestType, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("testtype"), name) + } + return obj.(*v1.TestType), nil +} diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/BUILD b/vendor/k8s.io/code-generator/cmd/client-gen/BUILD new file mode 100644 index 0000000000..c4734980e4 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/BUILD @@ -0,0 +1,45 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "client-gen", + importpath = "k8s.io/code-generator/cmd/client-gen", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/client-gen", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/args:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/generators:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//staging/src/k8s.io/code-generator/cmd/client-gen/args:all-srcs", + "//staging/src/k8s.io/code-generator/cmd/client-gen/generators:all-srcs", + "//staging/src/k8s.io/code-generator/cmd/client-gen/path:all-srcs", + "//staging/src/k8s.io/code-generator/cmd/client-gen/types:all-srcs", + ], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS b/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS new file mode 100644 index 0000000000..0c408a1aa9 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS @@ -0,0 +1,8 @@ +approvers: +- lavalamp +- wojtek-t +- caesarxuchao +reviewers: +- lavalamp +- wojtek-t +- caesarxuchao diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/README.md b/vendor/k8s.io/code-generator/cmd/client-gen/README.md new file mode 100644 index 0000000000..d1d67abdf9 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/README.md @@ -0,0 +1,4 @@ +See [generating-clientset.md](https://git.k8s.io/community/contributors/devel/generating-clientset.md) + + +[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/staging/src/k8s.io/code-generator/client-gen/README.md?pixel)]() diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/args/BUILD b/vendor/k8s.io/code-generator/cmd/client-gen/args/BUILD new file mode 100644 index 0000000000..03a93e447d --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/args/BUILD @@ -0,0 +1,45 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", + "go_test", +) + +go_library( + name = "go_default_library", + srcs = [ + "args.go", + "gvpackages.go", + "gvtype.go", + ], + importpath = "k8s.io/code-generator/cmd/client-gen/args", + deps = [ + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/types:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) + +go_test( + name = "go_default_test", + srcs = ["gvpackages_test.go"], + importpath = "k8s.io/code-generator/cmd/client-gen/args", + library = ":go_default_library", + deps = [ + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/types:go_default_library", + ], +) diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/generators/BUILD b/vendor/k8s.io/code-generator/cmd/client-gen/generators/BUILD new file mode 100644 index 0000000000..cc4e600e64 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/generators/BUILD @@ -0,0 +1,50 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = [ + "client_generator.go", + "generator_for_clientset.go", + "generator_for_expansion.go", + "generator_for_group.go", + "generator_for_type.go", + "tags.go", + ], + importpath = "k8s.io/code-generator/cmd/client-gen/generators", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/args:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/generators/fake:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/generators/scheme:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/generators/util:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/path:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/types:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//staging/src/k8s.io/code-generator/cmd/client-gen/generators/fake:all-srcs", + "//staging/src/k8s.io/code-generator/cmd/client-gen/generators/scheme:all-srcs", + "//staging/src/k8s.io/code-generator/cmd/client-gen/generators/util:all-srcs", + ], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/generators/fake/BUILD b/vendor/k8s.io/code-generator/cmd/client-gen/generators/fake/BUILD new file mode 100644 index 0000000000..8041036cec --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/generators/fake/BUILD @@ -0,0 +1,40 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = [ + "fake_client_generator.go", + "generator_fake_for_clientset.go", + "generator_fake_for_group.go", + "generator_fake_for_type.go", + ], + importpath = "k8s.io/code-generator/cmd/client-gen/generators/fake", + deps = [ + "//vendor/k8s.io/code-generator/cmd/client-gen/args:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/generators/scheme:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/generators/util:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/path:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/types:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/generators/scheme/BUILD b/vendor/k8s.io/code-generator/cmd/client-gen/generators/scheme/BUILD new file mode 100644 index 0000000000..ee7a1c06fb --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/generators/scheme/BUILD @@ -0,0 +1,32 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = ["generator_for_scheme.go"], + importpath = "k8s.io/code-generator/cmd/client-gen/generators/scheme", + deps = [ + "//vendor/k8s.io/code-generator/cmd/client-gen/path:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/types:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/generators/util/BUILD b/vendor/k8s.io/code-generator/cmd/client-gen/generators/util/BUILD new file mode 100644 index 0000000000..e25c24631a --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/generators/util/BUILD @@ -0,0 +1,34 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", + "go_test", +) + +go_test( + name = "go_default_test", + srcs = ["tags_test.go"], + importpath = "k8s.io/code-generator/cmd/client-gen/generators/util", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["tags.go"], + importpath = "k8s.io/code-generator/cmd/client-gen/generators/util", + deps = ["//vendor/k8s.io/gengo/types:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/path/BUILD b/vendor/k8s.io/code-generator/cmd/client-gen/path/BUILD new file mode 100644 index 0000000000..8c042fcaa4 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/path/BUILD @@ -0,0 +1,25 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = ["path.go"], + importpath = "k8s.io/code-generator/cmd/client-gen/path", +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/types/BUILD b/vendor/k8s.io/code-generator/cmd/client-gen/types/BUILD new file mode 100644 index 0000000000..681d4baf8c --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/types/BUILD @@ -0,0 +1,37 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", + "go_test", +) + +go_library( + name = "go_default_library", + srcs = [ + "helpers.go", + "types.go", + ], + importpath = "k8s.io/code-generator/cmd/client-gen/types", + deps = ["//vendor/k8s.io/gengo/namer:go_default_library"], +) + +go_test( + name = "go_default_test", + srcs = ["helpers_test.go"], + importpath = "k8s.io/code-generator/cmd/client-gen/types", + library = ":go_default_library", +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/conversion-gen/BUILD b/vendor/k8s.io/code-generator/cmd/conversion-gen/BUILD new file mode 100644 index 0000000000..eea6e91524 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/conversion-gen/BUILD @@ -0,0 +1,41 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "conversion-gen", + importpath = "k8s.io/code-generator/cmd/conversion-gen", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/conversion-gen", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/code-generator/cmd/conversion-gen/generators:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//staging/src/k8s.io/code-generator/cmd/conversion-gen/generators:all-srcs", + ], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/conversion-gen/generators/BUILD b/vendor/k8s.io/code-generator/cmd/conversion-gen/generators/BUILD new file mode 100644 index 0000000000..49290d578c --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/conversion-gen/generators/BUILD @@ -0,0 +1,32 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = ["conversion.go"], + importpath = "k8s.io/code-generator/cmd/conversion-gen/generators", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/deepcopy-gen/BUILD b/vendor/k8s.io/code-generator/cmd/deepcopy-gen/BUILD new file mode 100644 index 0000000000..d02e19af50 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/deepcopy-gen/BUILD @@ -0,0 +1,38 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "deepcopy-gen", + importpath = "k8s.io/code-generator/cmd/deepcopy-gen", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/deepcopy-gen", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/examples/deepcopy-gen/generators:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/defaulter-gen/BUILD b/vendor/k8s.io/code-generator/cmd/defaulter-gen/BUILD new file mode 100644 index 0000000000..947327e961 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/defaulter-gen/BUILD @@ -0,0 +1,38 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "defaulter-gen", + importpath = "k8s.io/code-generator/cmd/defaulter-gen", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/defaulter-gen", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/examples/defaulter-gen/generators:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/.gitignore b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/.gitignore new file mode 100644 index 0000000000..0e9aa466bb --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/.gitignore @@ -0,0 +1 @@ +go-to-protobuf diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/BUILD b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/BUILD new file mode 100644 index 0000000000..4ad6c27bf7 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/BUILD @@ -0,0 +1,40 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "go-to-protobuf", + importpath = "k8s.io/code-generator/cmd/go-to-protobuf", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/go-to-protobuf", + deps = [ + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf:all-srcs", + "//staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo:all-srcs", + ], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS new file mode 100644 index 0000000000..05d4b2a657 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS @@ -0,0 +1,4 @@ +approvers: +- smarterclayton +reviewers: +- smarterclayton diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/main.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/main.go new file mode 100644 index 0000000000..ce1756c11a --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/main.go @@ -0,0 +1,38 @@ +/* +Copyright 2015 The Kubernetes 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. +*/ + +// go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any +// existing IDL tags on the Go struct. +package main + +import ( + goflag "flag" + + flag "github.com/spf13/pflag" + "k8s.io/code-generator/cmd/go-to-protobuf/protobuf" +) + +var g = protobuf.New() + +func init() { + g.BindFlags(flag.CommandLine) + flag.CommandLine.AddGoFlagSet(goflag.CommandLine) +} + +func main() { + flag.Parse() + protobuf.Run(g) +} diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD new file mode 100644 index 0000000000..5750481bf7 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD @@ -0,0 +1,51 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", + "go_test", +) + +go_library( + name = "go_default_library", + srcs = [ + "cmd.go", + "generator.go", + "import_tracker.go", + "namer.go", + "package.go", + "parser.go", + "tags.go", + ], + importpath = "k8s.io/code-generator/cmd/go-to-protobuf/protobuf", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/code-generator/third_party/forked/golang/reflect:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/parser:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["namer_test.go"], + importpath = "k8s.io/code-generator/cmd/go-to-protobuf/protobuf", + library = ":go_default_library", +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go new file mode 100644 index 0000000000..0c2573bf26 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go @@ -0,0 +1,347 @@ +/* +Copyright 2015 The Kubernetes 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. +*/ + +// go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any +// existing IDL tags on the Go struct. +package protobuf + +import ( + "bytes" + "fmt" + "log" + "os" + "os/exec" + "path/filepath" + "strings" + + "k8s.io/gengo/args" + "k8s.io/gengo/generator" + "k8s.io/gengo/namer" + "k8s.io/gengo/parser" + "k8s.io/gengo/types" + + flag "github.com/spf13/pflag" +) + +type Generator struct { + Common args.GeneratorArgs + APIMachineryPackages string + Packages string + OutputBase string + VendorOutputBase string + ProtoImport []string + Conditional string + Clean bool + OnlyIDL bool + KeepGogoproto bool + SkipGeneratedRewrite bool + DropEmbeddedFields string +} + +func New() *Generator { + sourceTree := args.DefaultSourceTree() + common := args.GeneratorArgs{ + OutputBase: sourceTree, + GoHeaderFilePath: filepath.Join(sourceTree, "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt"), + } + defaultProtoImport := filepath.Join(sourceTree, "k8s.io", "kubernetes", "vendor", "github.com", "gogo", "protobuf", "protobuf") + cwd, err := os.Getwd() + if err != nil { + log.Fatalf("Cannot get current directory.") + } + return &Generator{ + Common: common, + OutputBase: sourceTree, + VendorOutputBase: filepath.Join(cwd, "vendor"), + ProtoImport: []string{defaultProtoImport}, + APIMachineryPackages: strings.Join([]string{ + `+k8s.io/apimachinery/pkg/util/intstr`, + `+k8s.io/apimachinery/pkg/api/resource`, + `+k8s.io/apimachinery/pkg/runtime/schema`, + `+k8s.io/apimachinery/pkg/runtime`, + `k8s.io/apimachinery/pkg/apis/meta/v1`, + `k8s.io/apimachinery/pkg/apis/meta/v1alpha1`, + }, ","), + Packages: "", + DropEmbeddedFields: "k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta", + } +} + +func (g *Generator) BindFlags(flag *flag.FlagSet) { + flag.StringVarP(&g.Common.GoHeaderFilePath, "go-header-file", "h", g.Common.GoHeaderFilePath, "File containing boilerplate header text. The string YEAR will be replaced with the current 4-digit year.") + flag.BoolVar(&g.Common.VerifyOnly, "verify-only", g.Common.VerifyOnly, "If true, only verify existing output, do not write anything.") + flag.StringVarP(&g.Packages, "packages", "p", g.Packages, "comma-separated list of directories to get input types from. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.") + flag.StringVar(&g.APIMachineryPackages, "apimachinery-packages", g.APIMachineryPackages, "comma-separated list of directories to get apimachinery input types from which are needed by any API. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.") + flag.StringVarP(&g.OutputBase, "output-base", "o", g.OutputBase, "Output base; defaults to $GOPATH/src/") + flag.StringVar(&g.VendorOutputBase, "vendor-output-base", g.VendorOutputBase, "The vendor/ directory to look for packages in; defaults to $PWD/vendor/.") + flag.StringSliceVar(&g.ProtoImport, "proto-import", g.ProtoImport, "The search path for the core protobuf .protos, required; defaults $GOPATH/src/k8s.io/kubernetes/vendor/github.com/gogo/protobuf/protobuf.") + flag.StringVar(&g.Conditional, "conditional", g.Conditional, "An optional Golang build tag condition to add to the generated Go code") + flag.BoolVar(&g.Clean, "clean", g.Clean, "If true, remove all generated files for the specified Packages.") + flag.BoolVar(&g.OnlyIDL, "only-idl", g.OnlyIDL, "If true, only generate the IDL for each package.") + flag.BoolVar(&g.KeepGogoproto, "keep-gogoproto", g.KeepGogoproto, "If true, the generated IDL will contain gogoprotobuf extensions which are normally removed") + flag.BoolVar(&g.SkipGeneratedRewrite, "skip-generated-rewrite", g.SkipGeneratedRewrite, "If true, skip fixing up the generated.pb.go file (debugging only).") + flag.StringVar(&g.DropEmbeddedFields, "drop-embedded-fields", g.DropEmbeddedFields, "Comma-delimited list of embedded Go types to omit from generated protobufs") +} + +func Run(g *Generator) { + if g.Common.VerifyOnly { + g.OnlyIDL = true + g.Clean = false + } + + b := parser.New() + b.AddBuildTags("proto") + + omitTypes := map[types.Name]struct{}{} + for _, t := range strings.Split(g.DropEmbeddedFields, ",") { + name := types.Name{} + if i := strings.LastIndex(t, "."); i != -1 { + name.Package, name.Name = t[:i], t[i+1:] + } else { + name.Name = t + } + if len(name.Name) == 0 { + log.Fatalf("--drop-embedded-types requires names in the form of [GOPACKAGE.]TYPENAME: %v", t) + } + omitTypes[name] = struct{}{} + } + + boilerplate, err := g.Common.LoadGoBoilerplate() + if err != nil { + log.Fatalf("Failed loading boilerplate (consider using the go-header-file flag): %v", err) + } + + protobufNames := NewProtobufNamer() + outputPackages := generator.Packages{} + nonOutputPackages := map[string]struct{}{} + + var packages []string + if len(g.APIMachineryPackages) != 0 { + packages = append(packages, strings.Split(g.APIMachineryPackages, ",")...) + } + if len(g.Packages) != 0 { + packages = append(packages, strings.Split(g.Packages, ",")...) + } + if len(packages) == 0 { + log.Fatalf("Both apimachinery-packages and packages are empty. At least one package must be specified.") + } + + for _, d := range packages { + generateAllTypes, outputPackage := true, true + switch { + case strings.HasPrefix(d, "+"): + d = d[1:] + generateAllTypes = false + case strings.HasPrefix(d, "-"): + d = d[1:] + outputPackage = false + } + name := protoSafePackage(d) + parts := strings.SplitN(d, "=", 2) + if len(parts) > 1 { + d = parts[0] + name = parts[1] + } + p := newProtobufPackage(d, name, generateAllTypes, omitTypes) + header := append([]byte{}, boilerplate...) + header = append(header, p.HeaderText...) + p.HeaderText = header + protobufNames.Add(p) + if outputPackage { + outputPackages = append(outputPackages, p) + } else { + nonOutputPackages[name] = struct{}{} + } + } + + if !g.Common.VerifyOnly { + for _, p := range outputPackages { + if err := p.(*protobufPackage).Clean(g.OutputBase); err != nil { + log.Fatalf("Unable to clean package %s: %v", p.Name(), err) + } + } + } + + if g.Clean { + return + } + + for _, p := range protobufNames.List() { + if err := b.AddDir(p.Path()); err != nil { + log.Fatalf("Unable to add directory %q: %v", p.Path(), err) + } + } + + c, err := generator.NewContext( + b, + namer.NameSystems{ + "public": namer.NewPublicNamer(3), + "proto": protobufNames, + }, + "public", + ) + if err != nil { + log.Fatalf("Failed making a context: %v", err) + } + + c.Verify = g.Common.VerifyOnly + c.FileTypes["protoidl"] = NewProtoFile() + + var vendoredOutputPackages, localOutputPackages generator.Packages + for _, p := range protobufNames.packages { + if _, ok := nonOutputPackages[p.Name()]; ok { + // if we're not outputting the package, don't include it in either package list + continue + } + p.Vendored = strings.Contains(c.Universe[p.PackagePath].SourcePath, "/vendor/") + if p.Vendored { + vendoredOutputPackages = append(vendoredOutputPackages, p) + } else { + localOutputPackages = append(localOutputPackages, p) + } + } + + if err := protobufNames.AssignTypesToPackages(c); err != nil { + log.Fatalf("Failed to identify Common types: %v", err) + } + + if err := c.ExecutePackages(g.VendorOutputBase, vendoredOutputPackages); err != nil { + log.Fatalf("Failed executing vendor generator: %v", err) + } + if err := c.ExecutePackages(g.OutputBase, localOutputPackages); err != nil { + log.Fatalf("Failed executing local generator: %v", err) + } + + if g.OnlyIDL { + return + } + + if _, err := exec.LookPath("protoc"); err != nil { + log.Fatalf("Unable to find 'protoc': %v", err) + } + + searchArgs := []string{"-I", ".", "-I", g.OutputBase} + if len(g.ProtoImport) != 0 { + for _, s := range g.ProtoImport { + searchArgs = append(searchArgs, "-I", s) + } + } + args := append(searchArgs, fmt.Sprintf("--gogo_out=%s", g.OutputBase)) + + buf := &bytes.Buffer{} + if len(g.Conditional) > 0 { + fmt.Fprintf(buf, "// +build %s\n\n", g.Conditional) + } + buf.Write(boilerplate) + + for _, outputPackage := range outputPackages { + p := outputPackage.(*protobufPackage) + + path := filepath.Join(g.OutputBase, p.ImportPath()) + outputPath := filepath.Join(g.OutputBase, p.OutputPath()) + if p.Vendored { + path = filepath.Join(g.VendorOutputBase, p.ImportPath()) + outputPath = filepath.Join(g.VendorOutputBase, p.OutputPath()) + } + + // generate the gogoprotobuf protoc + cmd := exec.Command("protoc", append(args, path)...) + out, err := cmd.CombinedOutput() + if len(out) > 0 { + log.Printf(string(out)) + } + if err != nil { + log.Println(strings.Join(cmd.Args, " ")) + log.Fatalf("Unable to generate protoc on %s: %v", p.PackageName, err) + } + + if g.SkipGeneratedRewrite { + continue + } + + // alter the generated protobuf file to remove the generated types (but leave the serializers) and rewrite the + // package statement to match the desired package name + if err := RewriteGeneratedGogoProtobufFile(outputPath, p.ExtractGeneratedType, p.OptionalTypeName, buf.Bytes()); err != nil { + log.Fatalf("Unable to rewrite generated %s: %v", outputPath, err) + } + + // sort imports + cmd = exec.Command("goimports", "-w", outputPath) + out, err = cmd.CombinedOutput() + if len(out) > 0 { + log.Printf(string(out)) + } + if err != nil { + log.Println(strings.Join(cmd.Args, " ")) + log.Fatalf("Unable to rewrite imports for %s: %v", p.PackageName, err) + } + + // format and simplify the generated file + cmd = exec.Command("gofmt", "-s", "-w", outputPath) + out, err = cmd.CombinedOutput() + if len(out) > 0 { + log.Printf(string(out)) + } + if err != nil { + log.Println(strings.Join(cmd.Args, " ")) + log.Fatalf("Unable to apply gofmt for %s: %v", p.PackageName, err) + } + } + + if g.SkipGeneratedRewrite { + return + } + + if !g.KeepGogoproto { + // generate, but do so without gogoprotobuf extensions + for _, outputPackage := range outputPackages { + p := outputPackage.(*protobufPackage) + p.OmitGogo = true + } + if err := c.ExecutePackages(g.VendorOutputBase, vendoredOutputPackages); err != nil { + log.Fatalf("Failed executing vendor generator: %v", err) + } + if err := c.ExecutePackages(g.OutputBase, localOutputPackages); err != nil { + log.Fatalf("Failed executing local generator: %v", err) + } + } + + for _, outputPackage := range outputPackages { + p := outputPackage.(*protobufPackage) + + if len(p.StructTags) == 0 { + continue + } + + pattern := filepath.Join(g.OutputBase, p.PackagePath, "*.go") + if p.Vendored { + pattern = filepath.Join(g.VendorOutputBase, p.PackagePath, "*.go") + } + files, err := filepath.Glob(pattern) + if err != nil { + log.Fatalf("Can't glob pattern %q: %v", pattern, err) + } + + for _, s := range files { + if strings.HasSuffix(s, "_test.go") { + continue + } + if err := RewriteTypesWithProtobufStructTags(s, p.StructTags); err != nil { + log.Fatalf("Unable to rewrite with struct tags %s: %v", s, err) + } + } + } +} diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/generator.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/generator.go new file mode 100644 index 0000000000..94ea7ff66f --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/generator.go @@ -0,0 +1,766 @@ +/* +Copyright 2015 The Kubernetes 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 protobuf + +import ( + "fmt" + "io" + "log" + "reflect" + "sort" + "strconv" + "strings" + + "github.com/golang/glog" + + "k8s.io/gengo/generator" + "k8s.io/gengo/namer" + "k8s.io/gengo/types" +) + +// genProtoIDL produces a .proto IDL. +type genProtoIDL struct { + generator.DefaultGen + localPackage types.Name + localGoPackage types.Name + imports namer.ImportTracker + + generateAll bool + omitGogo bool + omitFieldTypes map[types.Name]struct{} +} + +func (g *genProtoIDL) PackageVars(c *generator.Context) []string { + if g.omitGogo { + return []string{ + fmt.Sprintf("option go_package = %q;", g.localGoPackage.Name), + } + } + return []string{ + "option (gogoproto.marshaler_all) = true;", + "option (gogoproto.stable_marshaler_all) = true;", + "option (gogoproto.sizer_all) = true;", + "option (gogoproto.goproto_stringer_all) = false;", + "option (gogoproto.stringer_all) = true;", + "option (gogoproto.unmarshaler_all) = true;", + "option (gogoproto.goproto_unrecognized_all) = false;", + "option (gogoproto.goproto_enum_prefix_all) = false;", + "option (gogoproto.goproto_getters_all) = false;", + fmt.Sprintf("option go_package = %q;", g.localGoPackage.Name), + } +} +func (g *genProtoIDL) Filename() string { return g.OptionalName + ".proto" } +func (g *genProtoIDL) FileType() string { return "protoidl" } +func (g *genProtoIDL) Namers(c *generator.Context) namer.NameSystems { + return namer.NameSystems{ + // The local namer returns the correct protobuf name for a proto type + // in the context of a package + "local": localNamer{g.localPackage}, + } +} + +// Filter ignores types that are identified as not exportable. +func (g *genProtoIDL) Filter(c *generator.Context, t *types.Type) bool { + tagVals := types.ExtractCommentTags("+", t.CommentLines)["protobuf"] + if tagVals != nil { + if tagVals[0] == "false" { + // Type specified "false". + return false + } + if tagVals[0] == "true" { + // Type specified "true". + return true + } + glog.Fatalf(`Comment tag "protobuf" must be true or false, found: %q`, tagVals[0]) + } + if !g.generateAll { + // We're not generating everything. + return false + } + seen := map[*types.Type]bool{} + ok := isProtoable(seen, t) + return ok +} + +func isProtoable(seen map[*types.Type]bool, t *types.Type) bool { + if seen[t] { + // be optimistic in the case of type cycles. + return true + } + seen[t] = true + switch t.Kind { + case types.Builtin: + return true + case types.Alias: + return isProtoable(seen, t.Underlying) + case types.Slice, types.Pointer: + return isProtoable(seen, t.Elem) + case types.Map: + return isProtoable(seen, t.Key) && isProtoable(seen, t.Elem) + case types.Struct: + if len(t.Members) == 0 { + return true + } + for _, m := range t.Members { + if isProtoable(seen, m.Type) { + return true + } + } + return false + case types.Func, types.Chan: + return false + case types.DeclarationOf, types.Unknown, types.Unsupported: + return false + case types.Interface: + return false + default: + log.Printf("WARNING: type %q is not protable: %s", t.Kind, t.Name) + return false + } +} + +// isOptionalAlias should return true if the specified type has an underlying type +// (is an alias) of a map or slice and has the comment tag protobuf.nullable=true, +// indicating that the type should be nullable in protobuf. +func isOptionalAlias(t *types.Type) bool { + if t.Underlying == nil || (t.Underlying.Kind != types.Map && t.Underlying.Kind != types.Slice) { + return false + } + if extractBoolTagOrDie("protobuf.nullable", t.CommentLines) == false { + return false + } + return true +} + +func (g *genProtoIDL) Imports(c *generator.Context) (imports []string) { + lines := []string{} + // TODO: this could be expressed more cleanly + for _, line := range g.imports.ImportLines() { + if g.omitGogo && line == "github.com/gogo/protobuf/gogoproto/gogo.proto" { + continue + } + lines = append(lines, line) + } + return lines +} + +// GenerateType makes the body of a file implementing a set for type t. +func (g *genProtoIDL) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error { + sw := generator.NewSnippetWriter(w, c, "$", "$") + b := bodyGen{ + locator: &protobufLocator{ + namer: c.Namers["proto"].(ProtobufFromGoNamer), + tracker: g.imports, + universe: c.Universe, + + localGoPackage: g.localGoPackage.Package, + }, + localPackage: g.localPackage, + + omitGogo: g.omitGogo, + omitFieldTypes: g.omitFieldTypes, + + t: t, + } + switch t.Kind { + case types.Alias: + return b.doAlias(sw) + case types.Struct: + return b.doStruct(sw) + default: + return b.unknown(sw) + } +} + +// ProtobufFromGoNamer finds the protobuf name of a type (and its package, and +// the package path) from its Go name. +type ProtobufFromGoNamer interface { + GoNameToProtoName(name types.Name) types.Name +} + +type ProtobufLocator interface { + ProtoTypeFor(t *types.Type) (*types.Type, error) + GoTypeForName(name types.Name) *types.Type + CastTypeName(name types.Name) string +} + +type protobufLocator struct { + namer ProtobufFromGoNamer + tracker namer.ImportTracker + universe types.Universe + + localGoPackage string +} + +// CastTypeName returns the cast type name of a Go type +// TODO: delegate to a new localgo namer? +func (p protobufLocator) CastTypeName(name types.Name) string { + if name.Package == p.localGoPackage { + return name.Name + } + return name.String() +} + +func (p protobufLocator) GoTypeForName(name types.Name) *types.Type { + if len(name.Package) == 0 { + name.Package = p.localGoPackage + } + return p.universe.Type(name) +} + +// ProtoTypeFor locates a Protobuf type for the provided Go type (if possible). +func (p protobufLocator) ProtoTypeFor(t *types.Type) (*types.Type, error) { + switch { + // we've already converted the type, or it's a map + case t.Kind == types.Protobuf || t.Kind == types.Map: + p.tracker.AddType(t) + return t, nil + } + // it's a fundamental type + if t, ok := isFundamentalProtoType(t); ok { + p.tracker.AddType(t) + return t, nil + } + // it's a message + if t.Kind == types.Struct || isOptionalAlias(t) { + t := &types.Type{ + Name: p.namer.GoNameToProtoName(t.Name), + Kind: types.Protobuf, + + CommentLines: t.CommentLines, + } + p.tracker.AddType(t) + return t, nil + } + return nil, errUnrecognizedType +} + +type bodyGen struct { + locator ProtobufLocator + localPackage types.Name + omitGogo bool + omitFieldTypes map[types.Name]struct{} + + t *types.Type +} + +func (b bodyGen) unknown(sw *generator.SnippetWriter) error { + return fmt.Errorf("not sure how to generate: %#v", b.t) +} + +func (b bodyGen) doAlias(sw *generator.SnippetWriter) error { + if !isOptionalAlias(b.t) { + return nil + } + + var kind string + switch b.t.Underlying.Kind { + case types.Map: + kind = "map" + default: + kind = "slice" + } + optional := &types.Type{ + Name: b.t.Name, + Kind: types.Struct, + + CommentLines: b.t.CommentLines, + SecondClosestCommentLines: b.t.SecondClosestCommentLines, + Members: []types.Member{ + { + Name: "Items", + CommentLines: []string{fmt.Sprintf("items, if empty, will result in an empty %s\n", kind)}, + Type: b.t.Underlying, + }, + }, + } + nested := b + nested.t = optional + return nested.doStruct(sw) +} + +func (b bodyGen) doStruct(sw *generator.SnippetWriter) error { + if len(b.t.Name.Name) == 0 { + return nil + } + if namer.IsPrivateGoName(b.t.Name.Name) { + return nil + } + + var alias *types.Type + var fields []protoField + options := []string{} + allOptions := types.ExtractCommentTags("+", b.t.CommentLines) + for k, v := range allOptions { + switch { + case strings.HasPrefix(k, "protobuf.options."): + key := strings.TrimPrefix(k, "protobuf.options.") + switch key { + case "marshal": + if v[0] == "false" { + if !b.omitGogo { + options = append(options, + "(gogoproto.marshaler) = false", + "(gogoproto.unmarshaler) = false", + "(gogoproto.sizer) = false", + ) + } + } + default: + if !b.omitGogo || !strings.HasPrefix(key, "(gogoproto.") { + if key == "(gogoproto.goproto_stringer)" && v[0] == "false" { + options = append(options, "(gogoproto.stringer) = false") + } + options = append(options, fmt.Sprintf("%s = %s", key, v[0])) + } + } + // protobuf.as allows a type to have the same message contents as another Go type + case k == "protobuf.as": + fields = nil + if alias = b.locator.GoTypeForName(types.Name{Name: v[0]}); alias == nil { + return fmt.Errorf("type %v references alias %q which does not exist", b.t, v[0]) + } + // protobuf.embed instructs the generator to use the named type in this package + // as an embedded message. + case k == "protobuf.embed": + fields = []protoField{ + { + Tag: 1, + Name: v[0], + Type: &types.Type{ + Name: types.Name{ + Name: v[0], + Package: b.localPackage.Package, + Path: b.localPackage.Path, + }, + }, + }, + } + } + } + if alias == nil { + alias = b.t + } + + // If we don't explicitly embed anything, generate fields by traversing fields. + if fields == nil { + memberFields, err := membersToFields(b.locator, alias, b.localPackage, b.omitFieldTypes) + if err != nil { + return fmt.Errorf("type %v cannot be converted to protobuf: %v", b.t, err) + } + fields = memberFields + } + + out := sw.Out() + genComment(out, b.t.CommentLines, "") + sw.Do(`message $.Name.Name$ { +`, b.t) + + if len(options) > 0 { + sort.Sort(sort.StringSlice(options)) + for _, s := range options { + fmt.Fprintf(out, " option %s;\n", s) + } + fmt.Fprintln(out) + } + + for i, field := range fields { + genComment(out, field.CommentLines, " ") + fmt.Fprintf(out, " ") + switch { + case field.Map: + case field.Repeated: + fmt.Fprintf(out, "repeated ") + case field.Required: + fmt.Fprintf(out, "required ") + default: + fmt.Fprintf(out, "optional ") + } + sw.Do(`$.Type|local$ $.Name$ = $.Tag$`, field) + if len(field.Extras) > 0 { + extras := []string{} + for k, v := range field.Extras { + if b.omitGogo && strings.HasPrefix(k, "(gogoproto.") { + continue + } + extras = append(extras, fmt.Sprintf("%s = %s", k, v)) + } + sort.Sort(sort.StringSlice(extras)) + if len(extras) > 0 { + fmt.Fprintf(out, " [") + fmt.Fprint(out, strings.Join(extras, ", ")) + fmt.Fprintf(out, "]") + } + } + fmt.Fprintf(out, ";\n") + if i != len(fields)-1 { + fmt.Fprintf(out, "\n") + } + } + fmt.Fprintf(out, "}\n\n") + return nil +} + +type protoField struct { + LocalPackage types.Name + + Tag int + Name string + Type *types.Type + Map bool + Repeated bool + Optional bool + Required bool + Nullable bool + Extras map[string]string + + CommentLines []string +} + +var ( + errUnrecognizedType = fmt.Errorf("did not recognize the provided type") +) + +func isFundamentalProtoType(t *types.Type) (*types.Type, bool) { + // TODO: when we enable proto3, also include other fundamental types in the google.protobuf package + // switch { + // case t.Kind == types.Struct && t.Name == types.Name{Package: "time", Name: "Time"}: + // return &types.Type{ + // Kind: types.Protobuf, + // Name: types.Name{Path: "google/protobuf/timestamp.proto", Package: "google.protobuf", Name: "Timestamp"}, + // }, true + // } + switch t.Kind { + case types.Slice: + if t.Elem.Name.Name == "byte" && len(t.Elem.Name.Package) == 0 { + return &types.Type{Name: types.Name{Name: "bytes"}, Kind: types.Protobuf}, true + } + case types.Builtin: + switch t.Name.Name { + case "string", "uint32", "int32", "uint64", "int64", "bool": + return &types.Type{Name: types.Name{Name: t.Name.Name}, Kind: types.Protobuf}, true + case "int": + return &types.Type{Name: types.Name{Name: "int64"}, Kind: types.Protobuf}, true + case "uint": + return &types.Type{Name: types.Name{Name: "uint64"}, Kind: types.Protobuf}, true + case "float64", "float": + return &types.Type{Name: types.Name{Name: "double"}, Kind: types.Protobuf}, true + case "float32": + return &types.Type{Name: types.Name{Name: "float"}, Kind: types.Protobuf}, true + case "uintptr": + return &types.Type{Name: types.Name{Name: "uint64"}, Kind: types.Protobuf}, true + } + // TODO: complex? + } + return t, false +} + +func memberTypeToProtobufField(locator ProtobufLocator, field *protoField, t *types.Type) error { + var err error + switch t.Kind { + case types.Protobuf: + field.Type, err = locator.ProtoTypeFor(t) + case types.Builtin: + field.Type, err = locator.ProtoTypeFor(t) + case types.Map: + valueField := &protoField{} + if err := memberTypeToProtobufField(locator, valueField, t.Elem); err != nil { + return err + } + keyField := &protoField{} + if err := memberTypeToProtobufField(locator, keyField, t.Key); err != nil { + return err + } + // All other protobuf types have kind types.Protobuf, so setting types.Map + // here would be very misleading. + field.Type = &types.Type{ + Kind: types.Protobuf, + Key: keyField.Type, + Elem: valueField.Type, + } + if !strings.HasPrefix(t.Name.Name, "map[") { + field.Extras["(gogoproto.casttype)"] = strconv.Quote(locator.CastTypeName(t.Name)) + } + if k, ok := keyField.Extras["(gogoproto.casttype)"]; ok { + field.Extras["(gogoproto.castkey)"] = k + } + if v, ok := valueField.Extras["(gogoproto.casttype)"]; ok { + field.Extras["(gogoproto.castvalue)"] = v + } + field.Map = true + case types.Pointer: + if err := memberTypeToProtobufField(locator, field, t.Elem); err != nil { + return err + } + field.Nullable = true + case types.Alias: + if isOptionalAlias(t) { + field.Type, err = locator.ProtoTypeFor(t) + field.Nullable = true + } else { + if err := memberTypeToProtobufField(locator, field, t.Underlying); err != nil { + log.Printf("failed to alias: %s %s: err %v", t.Name, t.Underlying.Name, err) + return err + } + if field.Extras == nil { + field.Extras = make(map[string]string) + } + field.Extras["(gogoproto.casttype)"] = strconv.Quote(locator.CastTypeName(t.Name)) + } + case types.Slice: + if t.Elem.Name.Name == "byte" && len(t.Elem.Name.Package) == 0 { + field.Type = &types.Type{Name: types.Name{Name: "bytes"}, Kind: types.Protobuf} + return nil + } + if err := memberTypeToProtobufField(locator, field, t.Elem); err != nil { + return err + } + field.Repeated = true + case types.Struct: + if len(t.Name.Name) == 0 { + return errUnrecognizedType + } + field.Type, err = locator.ProtoTypeFor(t) + field.Nullable = false + default: + return errUnrecognizedType + } + return err +} + +// protobufTagToField extracts information from an existing protobuf tag +func protobufTagToField(tag string, field *protoField, m types.Member, t *types.Type, localPackage types.Name) error { + if len(tag) == 0 || tag == "-" { + return nil + } + + // protobuf:"bytes,3,opt,name=Id,customtype=github.com/gogo/protobuf/test.Uuid" + parts := strings.Split(tag, ",") + if len(parts) < 3 { + return fmt.Errorf("member %q of %q malformed 'protobuf' tag, not enough segments\n", m.Name, t.Name) + } + protoTag, err := strconv.Atoi(parts[1]) + if err != nil { + return fmt.Errorf("member %q of %q malformed 'protobuf' tag, field ID is %q which is not an integer: %v\n", m.Name, t.Name, parts[1], err) + } + field.Tag = protoTag + + // In general there is doesn't make sense to parse the protobuf tags to get the type, + // as all auto-generated once will have wire type "bytes", "varint" or "fixed64". + // However, sometimes we explicitly set them to have a custom serialization, e.g.: + // type Time struct { + // time.Time `protobuf:"Timestamp,1,req,name=time"` + // } + // to force the generator to use a given type (that we manually wrote serialization & + // deserialization methods for). + switch parts[0] { + case "varint", "fixed32", "fixed64", "bytes", "group": + default: + name := types.Name{} + if last := strings.LastIndex(parts[0], "."); last != -1 { + prefix := parts[0][:last] + name = types.Name{ + Name: parts[0][last+1:], + Package: prefix, + Path: strings.Replace(prefix, ".", "/", -1), + } + } else { + name = types.Name{ + Name: parts[0], + Package: localPackage.Package, + Path: localPackage.Path, + } + } + field.Type = &types.Type{ + Name: name, + Kind: types.Protobuf, + } + } + + protoExtra := make(map[string]string) + for i, extra := range parts[3:] { + parts := strings.SplitN(extra, "=", 2) + if len(parts) != 2 { + return fmt.Errorf("member %q of %q malformed 'protobuf' tag, tag %d should be key=value, got %q\n", m.Name, t.Name, i+4, extra) + } + switch parts[0] { + case "name": + protoExtra[parts[0]] = parts[1] + case "casttype", "castkey", "castvalue": + parts[0] = fmt.Sprintf("(gogoproto.%s)", parts[0]) + protoExtra[parts[0]] = strconv.Quote(parts[1]) + } + } + + field.Extras = protoExtra + if name, ok := protoExtra["name"]; ok { + field.Name = name + delete(protoExtra, "name") + } + + return nil +} + +func membersToFields(locator ProtobufLocator, t *types.Type, localPackage types.Name, omitFieldTypes map[types.Name]struct{}) ([]protoField, error) { + fields := []protoField{} + + for _, m := range t.Members { + if namer.IsPrivateGoName(m.Name) { + // skip private fields + continue + } + if _, ok := omitFieldTypes[types.Name{Name: m.Type.Name.Name, Package: m.Type.Name.Package}]; ok { + continue + } + tags := reflect.StructTag(m.Tags) + field := protoField{ + LocalPackage: localPackage, + + Tag: -1, + Extras: make(map[string]string), + } + + protobufTag := tags.Get("protobuf") + if protobufTag == "-" { + continue + } + + if err := protobufTagToField(protobufTag, &field, m, t, localPackage); err != nil { + return nil, err + } + + // extract information from JSON field tag + if tag := tags.Get("json"); len(tag) > 0 { + parts := strings.Split(tag, ",") + if len(field.Name) == 0 && len(parts[0]) != 0 { + field.Name = parts[0] + } + if field.Tag == -1 && field.Name == "-" { + continue + } + } + + if field.Type == nil { + if err := memberTypeToProtobufField(locator, &field, m.Type); err != nil { + return nil, fmt.Errorf("unable to embed type %q as field %q in %q: %v", m.Type, field.Name, t.Name, err) + } + } + if len(field.Name) == 0 { + field.Name = namer.IL(m.Name) + } + + if field.Map && field.Repeated { + // maps cannot be repeated + field.Repeated = false + field.Nullable = true + } + + if !field.Nullable { + field.Extras["(gogoproto.nullable)"] = "false" + } + if (field.Type.Name.Name == "bytes" && field.Type.Name.Package == "") || (field.Repeated && field.Type.Name.Package == "" && namer.IsPrivateGoName(field.Type.Name.Name)) { + delete(field.Extras, "(gogoproto.nullable)") + } + if field.Name != m.Name { + field.Extras["(gogoproto.customname)"] = strconv.Quote(m.Name) + } + field.CommentLines = m.CommentLines + fields = append(fields, field) + } + + // assign tags + highest := 0 + byTag := make(map[int]*protoField) + // fields are in Go struct order, which we preserve + for i := range fields { + field := &fields[i] + tag := field.Tag + if tag != -1 { + if existing, ok := byTag[tag]; ok { + return nil, fmt.Errorf("field %q and %q both have tag %d", field.Name, existing.Name, tag) + } + byTag[tag] = field + } + if tag > highest { + highest = tag + } + } + // starting from the highest observed tag, assign new field tags + for i := range fields { + field := &fields[i] + if field.Tag != -1 { + continue + } + highest++ + field.Tag = highest + byTag[field.Tag] = field + } + return fields, nil +} + +func genComment(out io.Writer, lines []string, indent string) { + for { + l := len(lines) + if l == 0 || len(lines[l-1]) != 0 { + break + } + lines = lines[:l-1] + } + for _, c := range lines { + fmt.Fprintf(out, "%s// %s\n", indent, c) + } +} + +func formatProtoFile(source []byte) ([]byte, error) { + // TODO; Is there any protobuf formatter? + return source, nil +} + +func assembleProtoFile(w io.Writer, f *generator.File) { + w.Write(f.Header) + + fmt.Fprint(w, "syntax = 'proto2';\n\n") + + if len(f.PackageName) > 0 { + fmt.Fprintf(w, "package %s;\n\n", f.PackageName) + } + + if len(f.Imports) > 0 { + imports := []string{} + for i := range f.Imports { + imports = append(imports, i) + } + sort.Strings(imports) + for _, s := range imports { + fmt.Fprintf(w, "import %q;\n", s) + } + fmt.Fprint(w, "\n") + } + + if f.Vars.Len() > 0 { + fmt.Fprintf(w, "%s\n", f.Vars.String()) + } + + w.Write(f.Body.Bytes()) +} + +func NewProtoFile() *generator.DefaultFileType { + return &generator.DefaultFileType{ + Format: formatProtoFile, + Assemble: assembleProtoFile, + } +} diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/import_tracker.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/import_tracker.go new file mode 100644 index 0000000000..08a991b155 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/import_tracker.go @@ -0,0 +1,50 @@ +/* +Copyright 2015 The Kubernetes 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 protobuf + +import ( + "k8s.io/gengo/namer" + "k8s.io/gengo/types" +) + +type ImportTracker struct { + namer.DefaultImportTracker +} + +func NewImportTracker(local types.Name, typesToAdd ...*types.Type) *ImportTracker { + tracker := namer.NewDefaultImportTracker(local) + tracker.IsInvalidType = func(t *types.Type) bool { return t.Kind != types.Protobuf } + tracker.LocalName = func(name types.Name) string { return name.Package } + tracker.PrintImport = func(path, name string) string { return path } + + tracker.AddTypes(typesToAdd...) + return &ImportTracker{ + DefaultImportTracker: tracker, + } +} + +// AddNullable ensures that support for the nullable Gogo-protobuf extension is added. +func (tracker *ImportTracker) AddNullable() { + tracker.AddType(&types.Type{ + Kind: types.Protobuf, + Name: types.Name{ + Name: "nullable", + Package: "gogoproto", + Path: "github.com/gogo/protobuf/gogoproto/gogo.proto", + }, + }) +} diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/namer.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/namer.go new file mode 100644 index 0000000000..423577a12e --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/namer.go @@ -0,0 +1,205 @@ +/* +Copyright 2015 The Kubernetes 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 protobuf + +import ( + "fmt" + "reflect" + "strings" + + "k8s.io/gengo/generator" + "k8s.io/gengo/namer" + "k8s.io/gengo/types" +) + +type localNamer struct { + localPackage types.Name +} + +func (n localNamer) Name(t *types.Type) string { + if t.Key != nil && t.Elem != nil { + return fmt.Sprintf("map<%s, %s>", n.Name(t.Key), n.Name(t.Elem)) + } + if len(n.localPackage.Package) != 0 && n.localPackage.Package == t.Name.Package { + return t.Name.Name + } + return t.Name.String() +} + +type protobufNamer struct { + packages []*protobufPackage + packagesByPath map[string]*protobufPackage +} + +func NewProtobufNamer() *protobufNamer { + return &protobufNamer{ + packagesByPath: make(map[string]*protobufPackage), + } +} + +func (n *protobufNamer) Name(t *types.Type) string { + if t.Kind == types.Map { + return fmt.Sprintf("map<%s, %s>", n.Name(t.Key), n.Name(t.Elem)) + } + return t.Name.String() +} + +func (n *protobufNamer) List() []generator.Package { + packages := make([]generator.Package, 0, len(n.packages)) + for i := range n.packages { + packages = append(packages, n.packages[i]) + } + return packages +} + +func (n *protobufNamer) Add(p *protobufPackage) { + if _, ok := n.packagesByPath[p.PackagePath]; !ok { + n.packagesByPath[p.PackagePath] = p + n.packages = append(n.packages, p) + } +} + +func (n *protobufNamer) GoNameToProtoName(name types.Name) types.Name { + if p, ok := n.packagesByPath[name.Package]; ok { + return types.Name{ + Name: name.Name, + Package: p.PackageName, + Path: p.ImportPath(), + } + } + for _, p := range n.packages { + if _, ok := p.FilterTypes[name]; ok { + return types.Name{ + Name: name.Name, + Package: p.PackageName, + Path: p.ImportPath(), + } + } + } + return types.Name{Name: name.Name} +} + +func protoSafePackage(name string) string { + pkg := strings.Replace(name, "/", ".", -1) + return strings.Replace(pkg, "-", "_", -1) +} + +type typeNameSet map[types.Name]*protobufPackage + +// assignGoTypeToProtoPackage looks for Go and Protobuf types that are referenced by a type in +// a package. It will not recurse into protobuf types. +func assignGoTypeToProtoPackage(p *protobufPackage, t *types.Type, local, global typeNameSet, optional map[types.Name]struct{}) { + newT, isProto := isFundamentalProtoType(t) + if isProto { + t = newT + } + if otherP, ok := global[t.Name]; ok { + if _, ok := local[t.Name]; !ok { + p.Imports.AddType(&types.Type{ + Kind: types.Protobuf, + Name: otherP.ProtoTypeName(), + }) + } + return + } + global[t.Name] = p + if _, ok := local[t.Name]; ok { + return + } + // don't recurse into existing proto types + if isProto { + p.Imports.AddType(t) + return + } + + local[t.Name] = p + for _, m := range t.Members { + if namer.IsPrivateGoName(m.Name) { + continue + } + field := &protoField{} + tag := reflect.StructTag(m.Tags).Get("protobuf") + if tag == "-" { + continue + } + if err := protobufTagToField(tag, field, m, t, p.ProtoTypeName()); err == nil && field.Type != nil { + assignGoTypeToProtoPackage(p, field.Type, local, global, optional) + continue + } + assignGoTypeToProtoPackage(p, m.Type, local, global, optional) + } + // TODO: should methods be walked? + if t.Elem != nil { + assignGoTypeToProtoPackage(p, t.Elem, local, global, optional) + } + if t.Key != nil { + assignGoTypeToProtoPackage(p, t.Key, local, global, optional) + } + if t.Underlying != nil { + if t.Kind == types.Alias && isOptionalAlias(t) { + optional[t.Name] = struct{}{} + } + assignGoTypeToProtoPackage(p, t.Underlying, local, global, optional) + } +} + +// isTypeApplicableToProtobuf checks to see if a type is relevant for protobuf processing. +// Currently, it filters out functions and private types. +func isTypeApplicableToProtobuf(t *types.Type) bool { + // skip functions -- we don't care about them for protobuf + if t.Kind == types.Func || (t.Kind == types.DeclarationOf && t.Underlying.Kind == types.Func) { + return false + } + // skip private types + if namer.IsPrivateGoName(t.Name.Name) { + return false + } + + return true +} + +func (n *protobufNamer) AssignTypesToPackages(c *generator.Context) error { + global := make(typeNameSet) + for _, p := range n.packages { + local := make(typeNameSet) + optional := make(map[types.Name]struct{}) + p.Imports = NewImportTracker(p.ProtoTypeName()) + for _, t := range c.Order { + if t.Name.Package != p.PackagePath { + continue + } + if !isTypeApplicableToProtobuf(t) { + // skip types that we don't care about, like functions + continue + } + assignGoTypeToProtoPackage(p, t, local, global, optional) + } + p.FilterTypes = make(map[types.Name]struct{}) + p.LocalNames = make(map[string]struct{}) + p.OptionalTypeNames = make(map[string]struct{}) + for k, v := range local { + if v == p { + p.FilterTypes[k] = struct{}{} + p.LocalNames[k.Name] = struct{}{} + if _, ok := optional[k]; ok { + p.OptionalTypeNames[k.Name] = struct{}{} + } + } + } + } + return nil +} diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/package.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/package.go new file mode 100644 index 0000000000..bed4c3e306 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/package.go @@ -0,0 +1,215 @@ +/* +Copyright 2015 The Kubernetes 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 protobuf + +import ( + "fmt" + "go/ast" + "log" + "os" + "path/filepath" + "reflect" + "strings" + + "k8s.io/gengo/generator" + "k8s.io/gengo/types" +) + +func newProtobufPackage(packagePath, packageName string, generateAll bool, omitFieldTypes map[types.Name]struct{}) *protobufPackage { + pkg := &protobufPackage{ + DefaultPackage: generator.DefaultPackage{ + // The protobuf package name (foo.bar.baz) + PackageName: packageName, + // A path segment relative to the GOPATH root (foo/bar/baz) + PackagePath: packagePath, + HeaderText: []byte( + ` +// This file was autogenerated by go-to-protobuf. Do not edit it manually! + +`), + PackageDocumentation: []byte(fmt.Sprintf( + `// Package %s is an autogenerated protobuf IDL. +`, packageName)), + }, + GenerateAll: generateAll, + OmitFieldTypes: omitFieldTypes, + } + pkg.FilterFunc = pkg.filterFunc + pkg.GeneratorFunc = pkg.generatorFunc + return pkg +} + +// protobufPackage contains the protobuf implementation of Package. +type protobufPackage struct { + generator.DefaultPackage + + // If true, this package has been vendored into our source tree and thus can + // only be generated by changing the vendor tree. + Vendored bool + + // If true, generate protobuf serializations for all public types. + // If false, only generate protobuf serializations for structs that + // request serialization. + GenerateAll bool + + // A list of types to filter to; if not specified all types will be included. + FilterTypes map[types.Name]struct{} + + // If true, omit any gogoprotobuf extensions not defined as types. + OmitGogo bool + + // A list of field types that will be excluded from the output struct + OmitFieldTypes map[types.Name]struct{} + + // A list of names that this package exports + LocalNames map[string]struct{} + + // A list of type names in this package that will need marshaller rewriting + // to remove synthetic protobuf fields. + OptionalTypeNames map[string]struct{} + + // A list of struct tags to generate onto named struct fields + StructTags map[string]map[string]string + + // An import tracker for this package + Imports *ImportTracker +} + +func (p *protobufPackage) Clean(outputBase string) error { + for _, s := range []string{p.ImportPath(), p.OutputPath()} { + if err := os.Remove(filepath.Join(outputBase, s)); err != nil && !os.IsNotExist(err) { + return err + } + } + return nil +} + +func (p *protobufPackage) ProtoTypeName() types.Name { + return types.Name{ + Name: p.Path(), // the go path "foo/bar/baz" + Package: p.Name(), // the protobuf package "foo.bar.baz" + Path: p.ImportPath(), // the path of the import to get the proto + } +} + +func (p *protobufPackage) filterFunc(c *generator.Context, t *types.Type) bool { + switch t.Kind { + case types.Func, types.Chan: + return false + case types.Struct: + if t.Name.Name == "struct{}" { + return false + } + case types.Builtin: + return false + case types.Alias: + if !isOptionalAlias(t) { + return false + } + case types.Slice, types.Array, types.Map: + return false + case types.Pointer: + return false + } + if _, ok := isFundamentalProtoType(t); ok { + return false + } + _, ok := p.FilterTypes[t.Name] + return ok +} + +func (p *protobufPackage) HasGoType(name string) bool { + _, ok := p.LocalNames[name] + return ok +} + +func (p *protobufPackage) OptionalTypeName(name string) bool { + _, ok := p.OptionalTypeNames[name] + return ok +} + +func (p *protobufPackage) ExtractGeneratedType(t *ast.TypeSpec) bool { + if !p.HasGoType(t.Name.Name) { + return false + } + + switch s := t.Type.(type) { + case *ast.StructType: + for i, f := range s.Fields.List { + if len(f.Tag.Value) == 0 { + continue + } + tag := strings.Trim(f.Tag.Value, "`") + protobufTag := reflect.StructTag(tag).Get("protobuf") + if len(protobufTag) == 0 { + continue + } + if len(f.Names) > 1 { + log.Printf("WARNING: struct %s field %d %s: defined multiple names but single protobuf tag", t.Name.Name, i, f.Names[0].Name) + // TODO hard error? + } + if p.StructTags == nil { + p.StructTags = make(map[string]map[string]string) + } + m := p.StructTags[t.Name.Name] + if m == nil { + m = make(map[string]string) + p.StructTags[t.Name.Name] = m + } + m[f.Names[0].Name] = tag + } + default: + log.Printf("WARNING: unexpected Go AST type definition: %#v", t) + } + + return true +} + +func (p *protobufPackage) generatorFunc(c *generator.Context) []generator.Generator { + generators := []generator.Generator{} + + p.Imports.AddNullable() + + generators = append(generators, &genProtoIDL{ + DefaultGen: generator.DefaultGen{ + OptionalName: "generated", + }, + localPackage: types.Name{Package: p.PackageName, Path: p.PackagePath}, + localGoPackage: types.Name{Package: p.PackagePath, Name: p.GoPackageName()}, + imports: p.Imports, + generateAll: p.GenerateAll, + omitGogo: p.OmitGogo, + omitFieldTypes: p.OmitFieldTypes, + }) + return generators +} + +func (p *protobufPackage) GoPackageName() string { + return filepath.Base(p.PackagePath) +} + +func (p *protobufPackage) ImportPath() string { + return filepath.Join(p.PackagePath, "generated.proto") +} + +func (p *protobufPackage) OutputPath() string { + return filepath.Join(p.PackagePath, "generated.pb.go") +} + +var ( + _ = generator.Package(&protobufPackage{}) +) diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser.go new file mode 100644 index 0000000000..305b718edb --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser.go @@ -0,0 +1,452 @@ +/* +Copyright 2015 The Kubernetes 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 protobuf + +import ( + "bytes" + "errors" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/printer" + "go/token" + "io/ioutil" + "os" + "reflect" + "strings" + + customreflect "k8s.io/code-generator/third_party/forked/golang/reflect" +) + +func rewriteFile(name string, header []byte, rewriteFn func(*token.FileSet, *ast.File) error) error { + fset := token.NewFileSet() + src, err := ioutil.ReadFile(name) + if err != nil { + return err + } + file, err := parser.ParseFile(fset, name, src, parser.DeclarationErrors|parser.ParseComments) + if err != nil { + return err + } + + if err := rewriteFn(fset, file); err != nil { + return err + } + + b := &bytes.Buffer{} + b.Write(header) + if err := printer.Fprint(b, fset, file); err != nil { + return err + } + + body, err := format.Source(b.Bytes()) + if err != nil { + return err + } + + f, err := os.OpenFile(name, os.O_WRONLY|os.O_TRUNC, 0644) + if err != nil { + return err + } + defer f.Close() + if _, err := f.Write(body); err != nil { + return err + } + return f.Close() +} + +// ExtractFunc extracts information from the provided TypeSpec and returns true if the type should be +// removed from the destination file. +type ExtractFunc func(*ast.TypeSpec) bool + +// OptionalFunc returns true if the provided local name is a type that has protobuf.nullable=true +// and should have its marshal functions adjusted to remove the 'Items' accessor. +type OptionalFunc func(name string) bool + +func RewriteGeneratedGogoProtobufFile(name string, extractFn ExtractFunc, optionalFn OptionalFunc, header []byte) error { + return rewriteFile(name, header, func(fset *token.FileSet, file *ast.File) error { + cmap := ast.NewCommentMap(fset, file, file.Comments) + + // transform methods that point to optional maps or slices + for _, d := range file.Decls { + rewriteOptionalMethods(d, optionalFn) + } + + // remove types that are already declared + decls := []ast.Decl{} + for _, d := range file.Decls { + if dropExistingTypeDeclarations(d, extractFn) { + continue + } + if dropEmptyImportDeclarations(d) { + continue + } + decls = append(decls, d) + } + file.Decls = decls + + // remove unmapped comments + file.Comments = cmap.Filter(file).Comments() + return nil + }) +} + +// rewriteOptionalMethods makes specific mutations to marshaller methods that belong to types identified +// as being "optional" (they may be nil on the wire). This allows protobuf to serialize a map or slice and +// properly discriminate between empty and nil (which is not possible in protobuf). +// TODO: move into upstream gogo-protobuf once https://github.com/gogo/protobuf/issues/181 +// has agreement +func rewriteOptionalMethods(decl ast.Decl, isOptional OptionalFunc) { + switch t := decl.(type) { + case *ast.FuncDecl: + ident, ptr, ok := receiver(t) + if !ok { + return + } + + // correct initialization of the form `m.Field = &OptionalType{}` to + // `m.Field = OptionalType{}` + if t.Name.Name == "Unmarshal" { + ast.Walk(optionalAssignmentVisitor{fn: isOptional}, t.Body) + } + + if !isOptional(ident.Name) { + return + } + + switch t.Name.Name { + case "Unmarshal": + ast.Walk(&optionalItemsVisitor{}, t.Body) + case "MarshalTo", "Size", "String": + ast.Walk(&optionalItemsVisitor{}, t.Body) + fallthrough + case "Marshal": + // if the method has a pointer receiver, set it back to a normal receiver + if ptr { + t.Recv.List[0].Type = ident + } + } + } +} + +type optionalAssignmentVisitor struct { + fn OptionalFunc +} + +// Visit walks the provided node, transforming field initializations of the form +// m.Field = &OptionalType{} -> m.Field = OptionalType{} +func (v optionalAssignmentVisitor) Visit(n ast.Node) ast.Visitor { + switch t := n.(type) { + case *ast.AssignStmt: + if len(t.Lhs) == 1 && len(t.Rhs) == 1 { + if !isFieldSelector(t.Lhs[0], "m", "") { + return nil + } + unary, ok := t.Rhs[0].(*ast.UnaryExpr) + if !ok || unary.Op != token.AND { + return nil + } + composite, ok := unary.X.(*ast.CompositeLit) + if !ok || composite.Type == nil || len(composite.Elts) != 0 { + return nil + } + if ident, ok := composite.Type.(*ast.Ident); ok && v.fn(ident.Name) { + t.Rhs[0] = composite + } + } + return nil + } + return v +} + +type optionalItemsVisitor struct{} + +// Visit walks the provided node, looking for specific patterns to transform that match +// the effective outcome of turning struct{ map[x]y || []x } into map[x]y or []x. +func (v *optionalItemsVisitor) Visit(n ast.Node) ast.Visitor { + switch t := n.(type) { + case *ast.RangeStmt: + if isFieldSelector(t.X, "m", "Items") { + t.X = &ast.Ident{Name: "m"} + } + case *ast.AssignStmt: + if len(t.Lhs) == 1 && len(t.Rhs) == 1 { + switch lhs := t.Lhs[0].(type) { + case *ast.IndexExpr: + if isFieldSelector(lhs.X, "m", "Items") { + lhs.X = &ast.StarExpr{X: &ast.Ident{Name: "m"}} + } + default: + if isFieldSelector(t.Lhs[0], "m", "Items") { + t.Lhs[0] = &ast.StarExpr{X: &ast.Ident{Name: "m"}} + } + } + switch rhs := t.Rhs[0].(type) { + case *ast.CallExpr: + if ident, ok := rhs.Fun.(*ast.Ident); ok && ident.Name == "append" { + ast.Walk(v, rhs) + if len(rhs.Args) > 0 { + switch arg := rhs.Args[0].(type) { + case *ast.Ident: + if arg.Name == "m" { + rhs.Args[0] = &ast.StarExpr{X: &ast.Ident{Name: "m"}} + } + } + } + return nil + } + } + } + case *ast.IfStmt: + switch cond := t.Cond.(type) { + case *ast.BinaryExpr: + if cond.Op == token.EQL { + if isFieldSelector(cond.X, "m", "Items") && isIdent(cond.Y, "nil") { + cond.X = &ast.StarExpr{X: &ast.Ident{Name: "m"}} + } + } + } + if t.Init != nil { + // Find form: + // if err := m[len(m.Items)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { + // return err + // } + switch s := t.Init.(type) { + case *ast.AssignStmt: + if call, ok := s.Rhs[0].(*ast.CallExpr); ok { + if sel, ok := call.Fun.(*ast.SelectorExpr); ok { + if x, ok := sel.X.(*ast.IndexExpr); ok { + // m[] -> (*m)[] + if sel2, ok := x.X.(*ast.SelectorExpr); ok { + if ident, ok := sel2.X.(*ast.Ident); ok && ident.Name == "m" { + x.X = &ast.StarExpr{X: &ast.Ident{Name: "m"}} + } + } + // len(m.Items) -> len(*m) + if bin, ok := x.Index.(*ast.BinaryExpr); ok { + if call2, ok := bin.X.(*ast.CallExpr); ok && len(call2.Args) == 1 { + if isFieldSelector(call2.Args[0], "m", "Items") { + call2.Args[0] = &ast.StarExpr{X: &ast.Ident{Name: "m"}} + } + } + } + } + } + } + } + } + case *ast.IndexExpr: + if isFieldSelector(t.X, "m", "Items") { + t.X = &ast.Ident{Name: "m"} + return nil + } + case *ast.CallExpr: + changed := false + for i := range t.Args { + if isFieldSelector(t.Args[i], "m", "Items") { + t.Args[i] = &ast.Ident{Name: "m"} + changed = true + } + } + if changed { + return nil + } + } + return v +} + +func isFieldSelector(n ast.Expr, name, field string) bool { + s, ok := n.(*ast.SelectorExpr) + if !ok || s.Sel == nil || (field != "" && s.Sel.Name != field) { + return false + } + return isIdent(s.X, name) +} + +func isIdent(n ast.Expr, value string) bool { + ident, ok := n.(*ast.Ident) + return ok && ident.Name == value +} + +func receiver(f *ast.FuncDecl) (ident *ast.Ident, pointer bool, ok bool) { + if f.Recv == nil || len(f.Recv.List) != 1 { + return nil, false, false + } + switch t := f.Recv.List[0].Type.(type) { + case *ast.StarExpr: + identity, ok := t.X.(*ast.Ident) + if !ok { + return nil, false, false + } + return identity, true, true + case *ast.Ident: + return t, false, true + } + return nil, false, false +} + +// dropExistingTypeDeclarations removes any type declaration for which extractFn returns true. The function +// returns true if the entire declaration should be dropped. +func dropExistingTypeDeclarations(decl ast.Decl, extractFn ExtractFunc) bool { + switch t := decl.(type) { + case *ast.GenDecl: + if t.Tok != token.TYPE { + return false + } + specs := []ast.Spec{} + for _, s := range t.Specs { + switch spec := s.(type) { + case *ast.TypeSpec: + if extractFn(spec) { + continue + } + specs = append(specs, spec) + } + } + if len(specs) == 0 { + return true + } + t.Specs = specs + } + return false +} + +// dropEmptyImportDeclarations strips any generated but no-op imports from the generated code +// to prevent generation from being able to define side-effects. The function returns true +// if the entire declaration should be dropped. +func dropEmptyImportDeclarations(decl ast.Decl) bool { + switch t := decl.(type) { + case *ast.GenDecl: + if t.Tok != token.IMPORT { + return false + } + specs := []ast.Spec{} + for _, s := range t.Specs { + switch spec := s.(type) { + case *ast.ImportSpec: + if spec.Name != nil && spec.Name.Name == "_" { + continue + } + specs = append(specs, spec) + } + } + if len(specs) == 0 { + return true + } + t.Specs = specs + } + return false +} + +func RewriteTypesWithProtobufStructTags(name string, structTags map[string]map[string]string) error { + return rewriteFile(name, []byte{}, func(fset *token.FileSet, file *ast.File) error { + allErrs := []error{} + + // set any new struct tags + for _, d := range file.Decls { + if errs := updateStructTags(d, structTags, []string{"protobuf"}); len(errs) > 0 { + allErrs = append(allErrs, errs...) + } + } + + if len(allErrs) > 0 { + var s string + for _, err := range allErrs { + s += err.Error() + "\n" + } + return errors.New(s) + } + return nil + }) +} + +func updateStructTags(decl ast.Decl, structTags map[string]map[string]string, toCopy []string) []error { + var errs []error + t, ok := decl.(*ast.GenDecl) + if !ok { + return nil + } + if t.Tok != token.TYPE { + return nil + } + + for _, s := range t.Specs { + spec, ok := s.(*ast.TypeSpec) + if !ok { + continue + } + typeName := spec.Name.Name + fieldTags, ok := structTags[typeName] + if !ok { + continue + } + st, ok := spec.Type.(*ast.StructType) + if !ok { + continue + } + + for i := range st.Fields.List { + f := st.Fields.List[i] + var name string + if len(f.Names) == 0 { + switch t := f.Type.(type) { + case *ast.Ident: + name = t.Name + case *ast.SelectorExpr: + name = t.Sel.Name + default: + errs = append(errs, fmt.Errorf("unable to get name for tag from struct %q, field %#v", spec.Name.Name, t)) + continue + } + } else { + name = f.Names[0].Name + } + value, ok := fieldTags[name] + if !ok { + continue + } + var tags customreflect.StructTags + if f.Tag != nil { + oldTags, err := customreflect.ParseStructTags(strings.Trim(f.Tag.Value, "`")) + if err != nil { + errs = append(errs, fmt.Errorf("unable to read struct tag from struct %q, field %q: %v", spec.Name.Name, name, err)) + continue + } + tags = oldTags + } + for _, name := range toCopy { + // don't overwrite existing tags + if tags.Has(name) { + continue + } + // append new tags + if v := reflect.StructTag(value).Get(name); len(v) > 0 { + tags = append(tags, customreflect.StructTag{Name: name, Value: v}) + } + } + if len(tags) == 0 { + continue + } + if f.Tag == nil { + f.Tag = &ast.BasicLit{} + } + f.Tag.Value = tags.String() + } + } + return errs +} diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/tags.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/tags.go new file mode 100644 index 0000000000..2dff5b9229 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/tags.go @@ -0,0 +1,33 @@ +/* +Copyright 2016 The Kubernetes 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 protobuf + +import ( + "github.com/golang/glog" + "k8s.io/gengo/types" +) + +// extractBoolTagOrDie gets the comment-tags for the key and asserts that, if +// it exists, the value is boolean. If the tag did not exist, it returns +// false. +func extractBoolTagOrDie(key string, lines []string) bool { + val, err := types.ExtractSingleBoolCommentTag("+", key, false, lines) + if err != nil { + glog.Fatal(err) + } + return val +} diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/BUILD b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/BUILD new file mode 100644 index 0000000000..83383bf6c8 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/BUILD @@ -0,0 +1,38 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "protoc-gen-gogo", + importpath = "k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo", + deps = [ + "//vendor/github.com/gogo/protobuf/gogoproto:go_default_library", + "//vendor/github.com/gogo/protobuf/proto:go_default_library", + "//vendor/github.com/gogo/protobuf/sortkeys:go_default_library", + "//vendor/github.com/gogo/protobuf/vanity/command:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/main.go b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/main.go new file mode 100644 index 0000000000..6e5051dce1 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/main.go @@ -0,0 +1,32 @@ +/* +Copyright 2015 The Kubernetes 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 main defines the protoc-gen-gogo binary we use to generate our proto go files, +// as well as takes dependencies on the correct gogo/protobuf packages for godeps. +package main + +import ( + "github.com/gogo/protobuf/vanity/command" + + // dependencies that are required for our packages + _ "github.com/gogo/protobuf/gogoproto" + _ "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/sortkeys" +) + +func main() { + command.Write(command.Generate(command.Read())) +} diff --git a/vendor/k8s.io/code-generator/cmd/import-boss/.gitignore b/vendor/k8s.io/code-generator/cmd/import-boss/.gitignore new file mode 100644 index 0000000000..a5c47b66f8 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/import-boss/.gitignore @@ -0,0 +1 @@ +import-boss diff --git a/vendor/k8s.io/code-generator/cmd/import-boss/BUILD b/vendor/k8s.io/code-generator/cmd/import-boss/BUILD new file mode 100644 index 0000000000..3e3e3a0356 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/import-boss/BUILD @@ -0,0 +1,37 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "import-boss", + importpath = "k8s.io/code-generator/cmd/import-boss", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/import-boss", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/examples/import-boss/generators:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/import-boss/main.go b/vendor/k8s.io/code-generator/cmd/import-boss/main.go new file mode 100644 index 0000000000..a6fad8efe2 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/import-boss/main.go @@ -0,0 +1,88 @@ +/* +Copyright 2016 The Kubernetes 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. +*/ + +// import-boss enforces import restrictions in a given repository. +// +// When a directory is verified, import-boss looks for a file called +// ".import-restrictions". If this file is not found, parent directories will be +// recursively searched. +// +// If an ".import-restrictions" file is found, then all imports of the package +// are checked against each "rule" in the file. A rule consists of three parts: +// * A SelectorRegexp, to select the import paths that the rule applies to. +// * A list of AllowedPrefixes +// * A list of ForbiddenPrefixes +// An import is allowed if it matches at least one allowed prefix and does not +// match any forbidden prefix. An example file looks like this: +// +// { +// "Rules": [ +// { +// "SelectorRegexp": "k8s[.]io", +// "AllowedPrefixes": [ +// "k8s.io/gengo/examples", +// "k8s.io/kubernetes/third_party" +// ], +// "ForbiddenPrefixes": [ +// "k8s.io/kubernetes/pkg/third_party/deprecated" +// ] +// }, +// { +// "SelectorRegexp": "^unsafe$", +// "AllowedPrefixes": [ +// ], +// "ForbiddenPrefixes": [ +// "" +// ] +// } +// ] +// } +// +// Note the second block explicitly matches the unsafe package, and forbids it +// ("" is a prefix of everything). +package main + +import ( + "os" + "path/filepath" + + "k8s.io/gengo/args" + "k8s.io/gengo/examples/import-boss/generators" + + "github.com/golang/glog" +) + +func main() { + arguments := args.Default() + + // Override defaults. + arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt") + arguments.InputDirs = []string{ + "k8s.io/kubernetes/pkg/...", + "k8s.io/kubernetes/cmd/...", + "k8s.io/kubernetes/plugin/...", + } + + if err := arguments.Execute( + generators.NameSystems(), + generators.DefaultNameSystem(), + generators.Packages, + ); err != nil { + glog.Errorf("Error: %v", err) + os.Exit(1) + } + glog.V(2).Info("Completed successfully.") +} diff --git a/vendor/k8s.io/code-generator/cmd/informer-gen/BUILD b/vendor/k8s.io/code-generator/cmd/informer-gen/BUILD new file mode 100644 index 0000000000..81eeb5c611 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/informer-gen/BUILD @@ -0,0 +1,41 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "informer-gen", + importpath = "k8s.io/code-generator/cmd/informer-gen", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/informer-gen", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/code-generator/cmd/informer-gen/generators:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//staging/src/k8s.io/code-generator/cmd/informer-gen/generators:all-srcs", + ], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/informer-gen/generators/BUILD b/vendor/k8s.io/code-generator/cmd/informer-gen/generators/BUILD new file mode 100644 index 0000000000..5b1de7e77a --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/informer-gen/generators/BUILD @@ -0,0 +1,46 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = [ + "customargs.go", + "factory.go", + "factoryinterface.go", + "generic.go", + "groupinterface.go", + "informer.go", + "packages.go", + "tags.go", + "types.go", + "versioninterface.go", + ], + importpath = "k8s.io/code-generator/cmd/informer-gen/generators", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/generators/util:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/types:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/lister-gen/.import-restrictions b/vendor/k8s.io/code-generator/cmd/lister-gen/.import-restrictions new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/lister-gen/.import-restrictions @@ -0,0 +1 @@ +{} diff --git a/vendor/k8s.io/code-generator/cmd/lister-gen/BUILD b/vendor/k8s.io/code-generator/cmd/lister-gen/BUILD new file mode 100644 index 0000000000..186c410117 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/lister-gen/BUILD @@ -0,0 +1,40 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "lister-gen", + importpath = "k8s.io/code-generator/cmd/lister-gen", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/lister-gen", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/k8s.io/code-generator/cmd/lister-gen/generators:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//staging/src/k8s.io/code-generator/cmd/lister-gen/generators:all-srcs", + ], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/lister-gen/generators/BUILD b/vendor/k8s.io/code-generator/cmd/lister-gen/generators/BUILD new file mode 100644 index 0000000000..aabb98b643 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/lister-gen/generators/BUILD @@ -0,0 +1,38 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = [ + "expansion.go", + "lister.go", + "tags.go", + ], + importpath = "k8s.io/code-generator/cmd/lister-gen/generators", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/generators/util:go_default_library", + "//vendor/k8s.io/code-generator/cmd/client-gen/types:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/generator:go_default_library", + "//vendor/k8s.io/gengo/namer:go_default_library", + "//vendor/k8s.io/gengo/types:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/openapi-gen/BUILD b/vendor/k8s.io/code-generator/cmd/openapi-gen/BUILD new file mode 100644 index 0000000000..bf4a9faef1 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/openapi-gen/BUILD @@ -0,0 +1,37 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "openapi-gen", + importpath = "k8s.io/code-generator/cmd/openapi-gen", + library = ":go_default_library", +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/openapi-gen", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/kube-openapi/pkg/generators:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/openapi-gen/README b/vendor/k8s.io/code-generator/cmd/openapi-gen/README new file mode 100644 index 0000000000..e6dcc85d0d --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/openapi-gen/README @@ -0,0 +1,13 @@ +# Generate OpenAPI definitions + +- To generate definition for a specific type or package add "+k8s:openapi-gen=true" tag to the type/package comment lines. +- To exclude a type or a member from a tagged package/type, add "+k8s:openapi-gen=false" tag to the comment lines. + +# OpenAPI Extensions +OpenAPI spec can have extensions on types. To define one or more extensions on a type or its member +add "+k8s:openapi-gen=x-kubernetes-$NAME:$VALUE" to the comment lines before type/member. A type/member can +have multiple extensions. The rest of the line in the comment will be used as $VALUE so there is no need to +escape or quote the value string. Extensions can be use to pass more information to client generators or +documentation generators. For example a type my have a friendly name to be displayed in documentation or +being used in a client's fluent interface. + diff --git a/vendor/k8s.io/code-generator/cmd/openapi-gen/main.go b/vendor/k8s.io/code-generator/cmd/openapi-gen/main.go new file mode 100644 index 0000000000..67355f8349 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/openapi-gen/main.go @@ -0,0 +1,47 @@ +/* +Copyright 2016 The Kubernetes 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. +*/ + +// This package generates openAPI definition file to be used in open API spec generation on API servers. To generate +// definition for a specific type or package add "+k8s:openapi-gen=true" tag to the type/package comment lines. To +// exclude a type from a tagged package, add "+k8s:openapi-gen=false" tag to the type comment lines. +package main + +import ( + "path/filepath" + + "k8s.io/gengo/args" + "k8s.io/kube-openapi/pkg/generators" + + "github.com/golang/glog" +) + +func main() { + arguments := args.Default() + + // Override defaults. + arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt") + arguments.OutputFileBaseName = "openapi_generated" + + // Run it. + if err := arguments.Execute( + generators.NameSystems(), + generators.DefaultNameSystem(), + generators.Packages, + ); err != nil { + glog.Fatalf("Error: %v", err) + } + glog.V(2).Info("Completed successfully.") +} diff --git a/vendor/k8s.io/code-generator/cmd/set-gen/.gitignore b/vendor/k8s.io/code-generator/cmd/set-gen/.gitignore new file mode 100644 index 0000000000..ffe6458c96 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/set-gen/.gitignore @@ -0,0 +1 @@ +set-gen diff --git a/vendor/k8s.io/code-generator/cmd/set-gen/BUILD b/vendor/k8s.io/code-generator/cmd/set-gen/BUILD new file mode 100644 index 0000000000..74bfefd544 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/set-gen/BUILD @@ -0,0 +1,41 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "set-gen", + importpath = "k8s.io/code-generator/cmd/set-gen", + library = ":go_default_library", +) + +exports_files([ + "types.go", +]) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "k8s.io/code-generator/cmd/set-gen", + deps = [ + "//vendor/github.com/golang/glog:go_default_library", + "//vendor/k8s.io/gengo/args:go_default_library", + "//vendor/k8s.io/gengo/examples/set-gen/generators:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/cmd/set-gen/main.go b/vendor/k8s.io/code-generator/cmd/set-gen/main.go new file mode 100644 index 0000000000..24af2229f9 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/set-gen/main.go @@ -0,0 +1,54 @@ +/* +Copyright 2015 The Kubernetes 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. +*/ + +// set-gen is an example usage of gengo. +// +// Structs in the input directories with the below line in their comments will +// have sets generated for them. +// // +genset +// +// Any builtin type referenced anywhere in the input directories will have a +// set generated for it. +package main + +import ( + "os" + "path/filepath" + + "k8s.io/gengo/args" + "k8s.io/gengo/examples/set-gen/generators" + + "github.com/golang/glog" +) + +func main() { + arguments := args.Default() + + // Override defaults. + arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt") + arguments.InputDirs = []string{"k8s.io/kubernetes/pkg/util/sets/types"} + arguments.OutputPackagePath = "k8s.io/apimachinery/pkg/util/sets" + + if err := arguments.Execute( + generators.NameSystems(), + generators.DefaultNameSystem(), + generators.Packages, + ); err != nil { + glog.Errorf("Error: %v", err) + os.Exit(1) + } + glog.V(2).Info("Completed successfully.") +} diff --git a/vendor/k8s.io/code-generator/generate-groups.sh b/vendor/k8s.io/code-generator/generate-groups.sh new file mode 100755 index 0000000000..145b12400b --- /dev/null +++ b/vendor/k8s.io/code-generator/generate-groups.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# Copyright 2017 The Kubernetes 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. + +set -o errexit +set -o nounset +set -o pipefail + +# generate-groups generates everything for a project with external types only, e.g. a project based +# on CustomResourceDefinitions. + +if [ "$#" -lt 4 ] || [ "${1}" == "--help" ]; then + cat < ... + + the generators comma separated to run (deepcopy,defaulter,client,lister,informer) or "all". + the output package name (e.g. github.com/example/project/pkg/generated). + the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis). + the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative + to . + ... arbitrary flags passed to all generator binaries. + + +Examples: + $(basename $0) all github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1" + $(basename $0) deepcopy,client github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1" +EOF + exit 0 +fi + +GENS="$1" +OUTPUT_PKG="$2" +APIS_PKG="$3" +GROUPS_WITH_VERSIONS="$4" +shift 4 + +go install ./$(dirname "${0}")/cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen} +function codegen::join() { local IFS="$1"; shift; echo "$*"; } + +# enumerate group versions +FQ_APIS=() # e.g. k8s.io/api/apps/v1 +for GVs in ${GROUPS_WITH_VERSIONS}; do + IFS=: read G Vs <<<"${GVs}" + + # enumerate versions + for V in ${Vs//,/ }; do + FQ_APIS+=(${APIS_PKG}/${G}/${V}) + done +done + +if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then + echo "Generating deepcopy funcs" + ${GOPATH}/bin/deepcopy-gen --input-dirs $(codegen::join , "${FQ_APIS[@]}") -O zz_generated.deepcopy --bounding-dirs ${APIS_PKG} "$@" +fi + +if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then + echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/clientset" + ${GOPATH}/bin/client-gen --clientset-name versioned --input-base "" --input $(codegen::join , "${FQ_APIS[@]}") --clientset-path ${OUTPUT_PKG}/clientset "$@" +fi + +if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then + echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers" + ${GOPATH}/bin/lister-gen --input-dirs $(codegen::join , "${FQ_APIS[@]}") --output-package ${OUTPUT_PKG}/listers "$@" +fi + +if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then + echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers" + ${GOPATH}/bin/informer-gen \ + --input-dirs $(codegen::join , "${FQ_APIS[@]}") \ + --versioned-clientset-package ${OUTPUT_PKG}/clientset/versioned \ + --listers-package ${OUTPUT_PKG}/listers \ + --output-package ${OUTPUT_PKG}/informers \ + "$@" +fi diff --git a/vendor/k8s.io/code-generator/generate-internal-groups.sh b/vendor/k8s.io/code-generator/generate-internal-groups.sh new file mode 100755 index 0000000000..b995dd4d56 --- /dev/null +++ b/vendor/k8s.io/code-generator/generate-internal-groups.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash + +# Copyright 2017 The Kubernetes 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. + +set -o errexit +set -o nounset +set -o pipefail + +# generate-internal-groups generates everything for a project with internal types, e.g. an +# user-provided API server based on k8s.io/apiserver. + +if [ "$#" -lt 5 ] || [ "${1}" == "--help" ]; then + cat < ... + + the generators comma separated to run (deepcopy,defaulter,conversion,client,lister,informer) or "all". + the output package name (e.g. github.com/example/project/pkg/generated). + the internal types dir (e.g. github.com/example/project/pkg/apis). + the external types dir (e.g. github.com/example/project/pkg/apis or githubcom/example/apis). + the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative + to . + ... arbitrary flags passed to all generator binaries. + +Examples: + $(basename $0) all github.com/example/project/pkg/client github.com/example/project/pkg/apis github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1" + $(basename $0) deepcopy,defaulter,conversion github.com/example/project/pkg/client github.com/example/project/pkg/apis github.com/example/project/apis "foo:v1 bar:v1alpha1,v1beta1" +EOF + exit 0 +fi + +GENS="$1" +OUTPUT_PKG="$2" +INT_APIS_PKG="$3" +EXT_APIS_PKG="$4" +GROUPS_WITH_VERSIONS="$5" +shift 5 + +go install ./$(dirname "${0}")/cmd/{defaulter-gen,conversion-gen,client-gen,lister-gen,informer-gen,deepcopy-gen} +function codegen::join() { local IFS="$1"; shift; echo "$*"; } + +# enumerate group versions +ALL_FQ_APIS=() # e.g. k8s.io/kubernetes/pkg/apis/apps k8s.io/api/apps/v1 +INT_FQ_APIS=() # e.g. k8s.io/kubernetes/pkg/apis/apps +EXT_FQ_APIS=() # e.g. k8s.io/api/apps/v1 +for GVs in ${GROUPS_WITH_VERSIONS}; do + IFS=: read G Vs <<<"${GVs}" + + if [ -n "${INT_APIS_PKG}" ]; then + ALL_FQ_APIS+=("${INT_APIS_PKG}/${G}") + INT_FQ_APIS+=("${INT_APIS_PKG}/${G}") + fi + + # enumerate versions + for V in ${Vs//,/ }; do + ALL_FQ_APIS+=("${EXT_APIS_PKG}/${G}/${V}") + EXT_FQ_APIS+=("${EXT_APIS_PKG}/${G}/${V}") + done +done + +if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then + echo "Generating deepcopy funcs" + ${GOPATH}/bin/deepcopy-gen --input-dirs $(codegen::join , "${ALL_FQ_APIS[@]}") -O zz_generated.deepcopy --bounding-dirs ${INT_APIS_PKG},${EXT_APIS_PKG} "$@" +fi + +if [ "${GENS}" = "all" ] || grep -qw "defaulter" <<<"${GENS}"; then + echo "Generating defaulters" + ${GOPATH}/bin/defaulter-gen --input-dirs $(codegen::join , "${EXT_FQ_APIS[@]}") -O zz_generated.defaults "$@" +fi + +if [ "${GENS}" = "all" ] || grep -qw "conversion" <<<"${GENS}"; then + echo "Generating conversions" + ${GOPATH}/bin/conversion-gen --input-dirs $(codegen::join , "${ALL_FQ_APIS[@]}") -O zz_generated.conversion "$@" +fi + +if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then + echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/clientset" + if [ -n "${INT_APIS_PKG}" ]; then + ${GOPATH}/bin/client-gen --clientset-name internalversion --input-base "" --input $(codegen::join , $(printf '%s/ ' "${INT_FQ_APIS[@]}")) --clientset-path ${OUTPUT_PKG}/clientset "$@" + fi + ${GOPATH}/bin/client-gen --clientset-name versioned --input-base "" --input $(codegen::join , "${EXT_FQ_APIS[@]}") --clientset-path ${OUTPUT_PKG}/clientset "$@" +fi + +if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then + echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers" + ${GOPATH}/bin/lister-gen --input-dirs $(codegen::join , "${ALL_FQ_APIS[@]}") --output-package ${OUTPUT_PKG}/listers "$@" +fi + +if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then + echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers" + ${GOPATH}/bin/informer-gen \ + --input-dirs $(codegen::join , "${ALL_FQ_APIS[@]}") \ + --versioned-clientset-package ${OUTPUT_PKG}/clientset/versioned \ + --internal-clientset-package ${OUTPUT_PKG}/clientset/internalversion \ + --listers-package ${OUTPUT_PKG}/listers \ + --output-package ${OUTPUT_PKG}/informers \ + "$@" +fi diff --git a/vendor/k8s.io/code-generator/hack/update-codegen.sh b/vendor/k8s.io/code-generator/hack/update-codegen.sh new file mode 100755 index 0000000000..e38a0d92c0 --- /dev/null +++ b/vendor/k8s.io/code-generator/hack/update-codegen.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright 2017 The Kubernetes 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. + +set -o errexit +set -o nounset +set -o pipefail + +# generate the code with: +# - --output-base because this script should also be able to run inside the vendor dir of +# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir +# instead of the $GOPATH directly. For normal projects this can be dropped. +$(dirname ${BASH_SOURCE})/../generate-internal-groups.sh all \ + k8s.io/code-generator/_examples/apiserver k8s.io/code-generator/_examples/apiserver/apis k8s.io/code-generator/_examples/apiserver/apis \ + "example:v1 example2:v1" \ + --output-base "$(dirname ${BASH_SOURCE})/../../.." +$(dirname ${BASH_SOURCE})/../generate-groups.sh all \ + k8s.io/code-generator/_examples/crd k8s.io/code-generator/_examples/crd/apis \ + "example:v1 example2:v1" \ + --output-base "$(dirname ${BASH_SOURCE})/../../.." diff --git a/vendor/k8s.io/code-generator/hack/verify-codegen.sh b/vendor/k8s.io/code-generator/hack/verify-codegen.sh new file mode 100755 index 0000000000..601a76962c --- /dev/null +++ b/vendor/k8s.io/code-generator/hack/verify-codegen.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Copyright 2017 The Kubernetes 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. + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. +SCRIPT_BASE=${SCRIPT_ROOT}/../.. + +DIFFROOT="${SCRIPT_ROOT}/_examples" +TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/_examples" +_tmp="${SCRIPT_ROOT}/_tmp" + +cleanup() { + rm -rf "${_tmp}" +} +trap "cleanup" EXIT SIGINT + +cleanup + +mkdir -p "${TMP_DIFFROOT}" +cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" + +"${SCRIPT_ROOT}/hack/update-codegen.sh" +echo "diffing ${DIFFROOT} against freshly generated codegen" +ret=0 +diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? +cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" +if [[ $ret -eq 0 ]] +then + echo "${DIFFROOT} up to date." +else + echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" + exit 1 +fi + +# smoke test +echo "Smoke testing _example by compiling..." +go build ${SCRIPT_ROOT}/_example/... \ No newline at end of file diff --git a/vendor/k8s.io/code-generator/third_party/forked/golang/reflect/BUILD b/vendor/k8s.io/code-generator/third_party/forked/golang/reflect/BUILD new file mode 100644 index 0000000000..cc2f10c365 --- /dev/null +++ b/vendor/k8s.io/code-generator/third_party/forked/golang/reflect/BUILD @@ -0,0 +1,25 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = ["type.go"], + importpath = "k8s.io/code-generator/third_party/forked/golang/reflect", +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/vendor/k8s.io/code-generator/third_party/forked/golang/reflect/type.go b/vendor/k8s.io/code-generator/third_party/forked/golang/reflect/type.go new file mode 100644 index 0000000000..67957ee33e --- /dev/null +++ b/vendor/k8s.io/code-generator/third_party/forked/golang/reflect/type.go @@ -0,0 +1,91 @@ +//This package is copied from Go library reflect/type.go. +//The struct tag library provides no way to extract the list of struct tags, only +//a specific tag +package reflect + +import ( + "fmt" + + "strconv" + "strings" +) + +type StructTag struct { + Name string + Value string +} + +func (t StructTag) String() string { + return fmt.Sprintf("%s:%q", t.Name, t.Value) +} + +type StructTags []StructTag + +func (tags StructTags) String() string { + s := make([]string, 0, len(tags)) + for _, tag := range tags { + s = append(s, tag.String()) + } + return "`" + strings.Join(s, " ") + "`" +} + +func (tags StructTags) Has(name string) bool { + for i := range tags { + if tags[i].Name == name { + return true + } + } + return false +} + +// ParseStructTags returns the full set of fields in a struct tag in the order they appear in +// the struct tag. +func ParseStructTags(tag string) (StructTags, error) { + tags := StructTags{} + for tag != "" { + // Skip leading space. + i := 0 + for i < len(tag) && tag[i] == ' ' { + i++ + } + tag = tag[i:] + if tag == "" { + break + } + + // Scan to colon. A space, a quote or a control character is a syntax error. + // Strictly speaking, control chars include the range [0x7f, 0x9f], not just + // [0x00, 0x1f], but in practice, we ignore the multi-byte control characters + // as it is simpler to inspect the tag's bytes than the tag's runes. + i = 0 + for i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '"' && tag[i] != 0x7f { + i++ + } + if i == 0 || i+1 >= len(tag) || tag[i] != ':' || tag[i+1] != '"' { + break + } + name := string(tag[:i]) + tag = tag[i+1:] + + // Scan quoted string to find value. + i = 1 + for i < len(tag) && tag[i] != '"' { + if tag[i] == '\\' { + i++ + } + i++ + } + if i >= len(tag) { + break + } + qvalue := string(tag[:i+1]) + tag = tag[i+1:] + + value, err := strconv.Unquote(qvalue) + if err != nil { + return nil, err + } + tags = append(tags, StructTag{Name: name, Value: value}) + } + return tags, nil +} From a2f7215d024e491c05c4e27a752061bade050545 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Mon, 16 Jul 2018 16:50:23 +0100 Subject: [PATCH 04/14] wip --- cmd/wing/cmd/agent.go | 1 - hack/update-client-gen.sh | 38 +-- pkg/apis/wing/register.go | 2 + pkg/apis/wing/types.go | 25 +- pkg/apis/wing/v1alpha1/register.go | 26 ++ pkg/apis/wing/v1alpha1/types.go | 34 ++- .../wing/v1alpha1/zz_generated.conversion.go | 264 ++++++++++++++---- .../wing/v1alpha1/zz_generated.deepcopy.go | 243 +++++++++++++--- pkg/apis/wing/zz_generated.deepcopy.go | 243 +++++++++++++--- pkg/apis/wing/zz_generated.defaults.go | 18 -- .../plugin/instanceinittime/admission.go | 23 +- pkg/wing/apiserver/apiserver.go | 2 + pkg/wing/controller.go | 21 +- pkg/wing/puppet.go | 227 ++++++++------- pkg/wing/registry/wing/wingjob/etcd.go | 34 +++ pkg/wing/registry/wing/wingjob/strategy.go | 85 ++++++ pkg/wing/wing.go | 21 +- 17 files changed, 973 insertions(+), 334 deletions(-) delete mode 100644 pkg/apis/wing/zz_generated.defaults.go create mode 100644 pkg/wing/registry/wing/wingjob/etcd.go create mode 100644 pkg/wing/registry/wing/wingjob/strategy.go diff --git a/cmd/wing/cmd/agent.go b/cmd/wing/cmd/agent.go index 6a632622ba..d676456106 100644 --- a/cmd/wing/cmd/agent.go +++ b/cmd/wing/cmd/agent.go @@ -27,7 +27,6 @@ func init() { agentCmd.Flags().StringVar(&agentFlags.ClusterName, "cluster-name", "myenv-mycluster", "this specifies the cluster name [environment]-[cluster]") agentCmd.Flags().StringVar(&agentFlags.ServerURL, "server-url", "https://localhost:9443", "this specifies the URL to the wing server") - agentCmd.Flags().StringVar(&agentFlags.ManifestURL, "manifest-url", "", "this specifies the URL where the puppet.tar.gz can be found") agentCmd.Flags().StringVar(&agentFlags.InstanceName, "instance-name", instanceName, "this specifies the instance's name") RootCmd.AddCommand(agentCmd) diff --git a/hack/update-client-gen.sh b/hack/update-client-gen.sh index 56676786ab..766f3feeeb 100755 --- a/hack/update-client-gen.sh +++ b/hack/update-client-gen.sh @@ -6,35 +6,11 @@ set -o errexit set -o nounset set -o pipefail -REPO_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/.."; pwd) -BINDIR=${REPO_ROOT}/bin +SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/.. +CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} -# Generate the internal clientset (pkg/client/clientset_generated/internalclientset) -${BINDIR}/client-gen "$@" \ - --go-header-file "${REPO_ROOT}/hack/boilerplate/boilerplate.go.txt" \ - --input-base "github.com/jetstack/tarmak/pkg/apis/" \ - --input "wing" \ - --clientset-path "github.com/jetstack/tarmak/pkg/wing/clients" \ - --clientset-name internalclientset \ -# Generate the versioned clientset (pkg/client/clientset_generated/clientset) -${BINDIR}/client-gen "$@" \ - --go-header-file "${REPO_ROOT}/hack/boilerplate/boilerplate.go.txt" \ - --input-base "github.com/jetstack/tarmak/pkg/apis/" \ - --input "wing/v1alpha1" \ - --clientset-path "github.com/jetstack/tarmak/pkg/wing" \ - --clientset-name "client" \ -# generate lister -${BINDIR}/lister-gen "$@" \ - --go-header-file "${REPO_ROOT}/hack/boilerplate/boilerplate.go.txt" \ - --input-dirs="github.com/jetstack/tarmak/pkg/apis/wing" \ - --input-dirs="github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" \ - --output-package "github.com/jetstack/tarmak/pkg/wing/listers" \ -# generate informer -${BINDIR}/informer-gen "$@" \ - --go-header-file "${REPO_ROOT}/hack/boilerplate/boilerplate.go.txt" \ - --input-dirs="github.com/jetstack/tarmak/pkg/apis/wing" \ - --input-dirs="github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" \ - --internal-clientset-package "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset" \ - --versioned-clientset-package "github.com/jetstack/tarmak/pkg/wing/client" \ - --listers-package "github.com/jetstack/tarmak/pkg/wing/listers" \ - --output-package "github.com/jetstack/tarmak/pkg/wing/informers" +${CODEGEN_PKG}/generate-internal-groups.sh all \ + github.com/jetstack/tarmak/pkg/client github.com/jetstack/tarmak/pkg/apis github.com/jetstack/tarmak/pkg/apis \ + wing:v1alpha1 \ + --output-base "${GOPATH}/src/" \ + --go-header-file ${SCRIPT_ROOT}/hack/boilerplate/boilerplate.go.txt diff --git a/pkg/apis/wing/register.go b/pkg/apis/wing/register.go index ea18a4b08c..10fdfa5a50 100644 --- a/pkg/apis/wing/register.go +++ b/pkg/apis/wing/register.go @@ -31,6 +31,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &Instance{}, &InstanceList{}, + &WingJob{}, + &WingJobList{}, ) return nil } diff --git a/pkg/apis/wing/types.go b/pkg/apis/wing/types.go index eeba56429f..7d86014b9e 100644 --- a/pkg/apis/wing/types.go +++ b/pkg/apis/wing/types.go @@ -21,11 +21,12 @@ type Instance struct { // InstanceSpec defines the desired state of Instance type InstanceSpec struct { - PuppetManifestRef string + PuppetTargetRef string } // InstanceStatus defines the observed state of Instance type InstanceStatus struct { + PuppetTargetRef string } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -44,17 +45,22 @@ type PuppetTarget struct { metav1.TypeMeta metav1.ObjectMeta - Source ManifestSource - Hash string - RequestTimestamp metav1.Time + Source ManifestSource + Hash string } type ManifestSource struct { - S3 *S3ManifestSource + S3 *S3ManifestSource + File *FileManifestSource } type S3ManifestSource struct { BucketName string + Path string +} + +type FileManifestSource struct { + Path string } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -78,15 +84,16 @@ type WingJob struct { } type WingJobSpec struct { - InstanceID string - Source ManifestSource + InstanceName string + PuppetTargetRef string Operation string RequestTimestamp metav1.Time } type WingJobStatus struct { - Messages string - ExitCode int + Messages string + ExitCode int + LastUpdateTimestamp metav1.Time } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/wing/v1alpha1/register.go b/pkg/apis/wing/v1alpha1/register.go index 89e76a9336..b4b9126480 100644 --- a/pkg/apis/wing/v1alpha1/register.go +++ b/pkg/apis/wing/v1alpha1/register.go @@ -2,6 +2,8 @@ package v1alpha1 import ( + "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -24,6 +26,7 @@ func init() { // We only register manually written functions here. The registration of the // generated functions takes place in the generated files. The separation // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes, addConversionFuncs) localSchemeBuilder.Register(addKnownTypes) } @@ -32,8 +35,31 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &Instance{}, &InstanceList{}, + &WingJob{}, + &WingJobList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + + return nil +} + +func addConversionFuncs(scheme *runtime.Scheme) error { + // Add field conversion funcs. + err := scheme.AddFieldLabelConversionFunc("wing.tarmak.io/v1alpha1", "WingJob", + func(label, value string) (string, string, error) { + switch label { + case "metadata.name", + "metadata.namespace", + "spec.instanceName": + return label, value, nil + default: + return "", "", fmt.Errorf("field label not supported: %s", label) + } + }, + ) + if err != nil { + return err + } return nil } diff --git a/pkg/apis/wing/v1alpha1/types.go b/pkg/apis/wing/v1alpha1/types.go index 93aa3e9db3..95b8bcc652 100644 --- a/pkg/apis/wing/v1alpha1/types.go +++ b/pkg/apis/wing/v1alpha1/types.go @@ -5,6 +5,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +const ( + ApplyOperation = "apply" + DryRunOperation = "dry-run" +) + // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -21,11 +26,12 @@ type Instance struct { // InstanceSpec defines the desired state of Instance type InstanceSpec struct { - PuppetManifestRef string `json:"puppetManifestRef"` + PuppetTargetRef string `json:"puppetTargetRef"` } // InstanceStatus defines the observed state of Instance type InstanceStatus struct { + PuppetTargetRef string `json:"puppetTargetRef"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -44,17 +50,22 @@ type PuppetTarget struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Source ManifestSource `json:"source"` - Hash string `json:"hash,omitempty"` // hash of manifests, prefixed with type (eg: sha256:xyz) - RequestTimestamp metav1.Time `json:"requestTimestamp,omitempty"` // timestamp when a converge was requested + Source ManifestSource `json:"source"` + Hash string `json:"hash,omitempty"` // hash of manifests, prefixed with type (eg: sha256:xyz) } type ManifestSource struct { - S3 *S3ManifestSource `json:"s3"` + S3 *S3ManifestSource `json:"s3"` + File *FileManifestSource `json:"file"` } type S3ManifestSource struct { BucketName string `json:"bucketName"` + Path string `json:"path"` +} + +type FileManifestSource struct { + Path string `json:"path"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -78,15 +89,16 @@ type WingJob struct { } type WingJobSpec struct { - InstanceID string `json:"instanceID,omitempty"` - Source ManifestSource `json:"source"` - Operation string `json:"operation"` - RequestTimestamp metav1.Time `json:"requestTimestamp,omitempty"` + InstanceName string `json:"instanceName,omitempty"` + PuppetTargetRef string `json:"puppetTargetRef"` + Operation string `json:"operation"` + RequestTimestamp metav1.Time `json:"requestTimestamp,omitempty"` } type WingJobStatus struct { - Messages string `json:"messages,omitempty"` - ExitCode int `json:"exitCode,omitempty"` + Messages string `json:"messages,omitempty"` + ExitCode int `json:"exitCode,omitempty"` + LastUpdateTimestamp metav1.Time `json:"lastUpdateTimestamp,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go index 284270f80d..79e6eeed4a 100644 --- a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go @@ -21,21 +21,55 @@ func init() { // Public to allow building arbitrary schemes. func RegisterConversions(scheme *runtime.Scheme) error { return scheme.AddGeneratedConversionFuncs( + Convert_v1alpha1_FileManifestSource_To_wing_FileManifestSource, + Convert_wing_FileManifestSource_To_v1alpha1_FileManifestSource, Convert_v1alpha1_Instance_To_wing_Instance, Convert_wing_Instance_To_v1alpha1_Instance, Convert_v1alpha1_InstanceList_To_wing_InstanceList, Convert_wing_InstanceList_To_v1alpha1_InstanceList, Convert_v1alpha1_InstanceSpec_To_wing_InstanceSpec, Convert_wing_InstanceSpec_To_v1alpha1_InstanceSpec, - Convert_v1alpha1_InstanceSpecManifest_To_wing_InstanceSpecManifest, - Convert_wing_InstanceSpecManifest_To_v1alpha1_InstanceSpecManifest, Convert_v1alpha1_InstanceStatus_To_wing_InstanceStatus, Convert_wing_InstanceStatus_To_v1alpha1_InstanceStatus, - Convert_v1alpha1_InstanceStatusManifest_To_wing_InstanceStatusManifest, - Convert_wing_InstanceStatusManifest_To_v1alpha1_InstanceStatusManifest, + Convert_v1alpha1_ManifestSource_To_wing_ManifestSource, + Convert_wing_ManifestSource_To_v1alpha1_ManifestSource, + Convert_v1alpha1_PuppetTarget_To_wing_PuppetTarget, + Convert_wing_PuppetTarget_To_v1alpha1_PuppetTarget, + Convert_v1alpha1_PuppetTargetList_To_wing_PuppetTargetList, + Convert_wing_PuppetTargetList_To_v1alpha1_PuppetTargetList, + Convert_v1alpha1_S3ManifestSource_To_wing_S3ManifestSource, + Convert_wing_S3ManifestSource_To_v1alpha1_S3ManifestSource, + Convert_v1alpha1_WingJob_To_wing_WingJob, + Convert_wing_WingJob_To_v1alpha1_WingJob, + Convert_v1alpha1_WingJobList_To_wing_WingJobList, + Convert_wing_WingJobList_To_v1alpha1_WingJobList, + Convert_v1alpha1_WingJobSpec_To_wing_WingJobSpec, + Convert_wing_WingJobSpec_To_v1alpha1_WingJobSpec, + Convert_v1alpha1_WingJobStatus_To_wing_WingJobStatus, + Convert_wing_WingJobStatus_To_v1alpha1_WingJobStatus, ) } +func autoConvert_v1alpha1_FileManifestSource_To_wing_FileManifestSource(in *FileManifestSource, out *wing.FileManifestSource, s conversion.Scope) error { + out.Path = in.Path + return nil +} + +// Convert_v1alpha1_FileManifestSource_To_wing_FileManifestSource is an autogenerated conversion function. +func Convert_v1alpha1_FileManifestSource_To_wing_FileManifestSource(in *FileManifestSource, out *wing.FileManifestSource, s conversion.Scope) error { + return autoConvert_v1alpha1_FileManifestSource_To_wing_FileManifestSource(in, out, s) +} + +func autoConvert_wing_FileManifestSource_To_v1alpha1_FileManifestSource(in *wing.FileManifestSource, out *FileManifestSource, s conversion.Scope) error { + out.Path = in.Path + return nil +} + +// Convert_wing_FileManifestSource_To_v1alpha1_FileManifestSource is an autogenerated conversion function. +func Convert_wing_FileManifestSource_To_v1alpha1_FileManifestSource(in *wing.FileManifestSource, out *FileManifestSource, s conversion.Scope) error { + return autoConvert_wing_FileManifestSource_To_v1alpha1_FileManifestSource(in, out, s) +} + func autoConvert_v1alpha1_Instance_To_wing_Instance(in *Instance, out *wing.Instance, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.InstanceID = in.InstanceID @@ -87,8 +121,7 @@ func Convert_wing_InstanceList_To_v1alpha1_InstanceList(in *wing.InstanceList, o } func autoConvert_v1alpha1_InstanceSpec_To_wing_InstanceSpec(in *InstanceSpec, out *wing.InstanceSpec, s conversion.Scope) error { - out.Converge = (*wing.InstanceSpecManifest)(unsafe.Pointer(in.Converge)) - out.DryRun = (*wing.InstanceSpecManifest)(unsafe.Pointer(in.DryRun)) + out.PuppetTargetRef = in.PuppetTargetRef return nil } @@ -98,8 +131,7 @@ func Convert_v1alpha1_InstanceSpec_To_wing_InstanceSpec(in *InstanceSpec, out *w } func autoConvert_wing_InstanceSpec_To_v1alpha1_InstanceSpec(in *wing.InstanceSpec, out *InstanceSpec, s conversion.Scope) error { - out.Converge = (*InstanceSpecManifest)(unsafe.Pointer(in.Converge)) - out.DryRun = (*InstanceSpecManifest)(unsafe.Pointer(in.DryRun)) + out.PuppetTargetRef = in.PuppetTargetRef return nil } @@ -108,76 +140,212 @@ func Convert_wing_InstanceSpec_To_v1alpha1_InstanceSpec(in *wing.InstanceSpec, o return autoConvert_wing_InstanceSpec_To_v1alpha1_InstanceSpec(in, out, s) } -func autoConvert_v1alpha1_InstanceSpecManifest_To_wing_InstanceSpecManifest(in *InstanceSpecManifest, out *wing.InstanceSpecManifest, s conversion.Scope) error { - out.Path = in.Path +func autoConvert_v1alpha1_InstanceStatus_To_wing_InstanceStatus(in *InstanceStatus, out *wing.InstanceStatus, s conversion.Scope) error { + out.PuppetTargetRef = in.PuppetTargetRef + return nil +} + +// Convert_v1alpha1_InstanceStatus_To_wing_InstanceStatus is an autogenerated conversion function. +func Convert_v1alpha1_InstanceStatus_To_wing_InstanceStatus(in *InstanceStatus, out *wing.InstanceStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_InstanceStatus_To_wing_InstanceStatus(in, out, s) +} + +func autoConvert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in *wing.InstanceStatus, out *InstanceStatus, s conversion.Scope) error { + out.PuppetTargetRef = in.PuppetTargetRef + return nil +} + +// Convert_wing_InstanceStatus_To_v1alpha1_InstanceStatus is an autogenerated conversion function. +func Convert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in *wing.InstanceStatus, out *InstanceStatus, s conversion.Scope) error { + return autoConvert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in, out, s) +} + +func autoConvert_v1alpha1_ManifestSource_To_wing_ManifestSource(in *ManifestSource, out *wing.ManifestSource, s conversion.Scope) error { + out.S3 = (*wing.S3ManifestSource)(unsafe.Pointer(in.S3)) + out.File = (*wing.FileManifestSource)(unsafe.Pointer(in.File)) + return nil +} + +// Convert_v1alpha1_ManifestSource_To_wing_ManifestSource is an autogenerated conversion function. +func Convert_v1alpha1_ManifestSource_To_wing_ManifestSource(in *ManifestSource, out *wing.ManifestSource, s conversion.Scope) error { + return autoConvert_v1alpha1_ManifestSource_To_wing_ManifestSource(in, out, s) +} + +func autoConvert_wing_ManifestSource_To_v1alpha1_ManifestSource(in *wing.ManifestSource, out *ManifestSource, s conversion.Scope) error { + out.S3 = (*S3ManifestSource)(unsafe.Pointer(in.S3)) + out.File = (*FileManifestSource)(unsafe.Pointer(in.File)) + return nil +} + +// Convert_wing_ManifestSource_To_v1alpha1_ManifestSource is an autogenerated conversion function. +func Convert_wing_ManifestSource_To_v1alpha1_ManifestSource(in *wing.ManifestSource, out *ManifestSource, s conversion.Scope) error { + return autoConvert_wing_ManifestSource_To_v1alpha1_ManifestSource(in, out, s) +} + +func autoConvert_v1alpha1_PuppetTarget_To_wing_PuppetTarget(in *PuppetTarget, out *wing.PuppetTarget, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_ManifestSource_To_wing_ManifestSource(&in.Source, &out.Source, s); err != nil { + return err + } out.Hash = in.Hash - out.RequestTimestamp = in.RequestTimestamp return nil } -// Convert_v1alpha1_InstanceSpecManifest_To_wing_InstanceSpecManifest is an autogenerated conversion function. -func Convert_v1alpha1_InstanceSpecManifest_To_wing_InstanceSpecManifest(in *InstanceSpecManifest, out *wing.InstanceSpecManifest, s conversion.Scope) error { - return autoConvert_v1alpha1_InstanceSpecManifest_To_wing_InstanceSpecManifest(in, out, s) +// Convert_v1alpha1_PuppetTarget_To_wing_PuppetTarget is an autogenerated conversion function. +func Convert_v1alpha1_PuppetTarget_To_wing_PuppetTarget(in *PuppetTarget, out *wing.PuppetTarget, s conversion.Scope) error { + return autoConvert_v1alpha1_PuppetTarget_To_wing_PuppetTarget(in, out, s) } -func autoConvert_wing_InstanceSpecManifest_To_v1alpha1_InstanceSpecManifest(in *wing.InstanceSpecManifest, out *InstanceSpecManifest, s conversion.Scope) error { - out.Path = in.Path +func autoConvert_wing_PuppetTarget_To_v1alpha1_PuppetTarget(in *wing.PuppetTarget, out *PuppetTarget, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_wing_ManifestSource_To_v1alpha1_ManifestSource(&in.Source, &out.Source, s); err != nil { + return err + } out.Hash = in.Hash - out.RequestTimestamp = in.RequestTimestamp return nil } -// Convert_wing_InstanceSpecManifest_To_v1alpha1_InstanceSpecManifest is an autogenerated conversion function. -func Convert_wing_InstanceSpecManifest_To_v1alpha1_InstanceSpecManifest(in *wing.InstanceSpecManifest, out *InstanceSpecManifest, s conversion.Scope) error { - return autoConvert_wing_InstanceSpecManifest_To_v1alpha1_InstanceSpecManifest(in, out, s) +// Convert_wing_PuppetTarget_To_v1alpha1_PuppetTarget is an autogenerated conversion function. +func Convert_wing_PuppetTarget_To_v1alpha1_PuppetTarget(in *wing.PuppetTarget, out *PuppetTarget, s conversion.Scope) error { + return autoConvert_wing_PuppetTarget_To_v1alpha1_PuppetTarget(in, out, s) } -func autoConvert_v1alpha1_InstanceStatus_To_wing_InstanceStatus(in *InstanceStatus, out *wing.InstanceStatus, s conversion.Scope) error { - out.Converge = (*wing.InstanceStatusManifest)(unsafe.Pointer(in.Converge)) - out.DryRun = (*wing.InstanceStatusManifest)(unsafe.Pointer(in.DryRun)) +func autoConvert_v1alpha1_PuppetTargetList_To_wing_PuppetTargetList(in *PuppetTargetList, out *wing.PuppetTargetList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]wing.PuppetTarget)(unsafe.Pointer(&in.Items)) return nil } -// Convert_v1alpha1_InstanceStatus_To_wing_InstanceStatus is an autogenerated conversion function. -func Convert_v1alpha1_InstanceStatus_To_wing_InstanceStatus(in *InstanceStatus, out *wing.InstanceStatus, s conversion.Scope) error { - return autoConvert_v1alpha1_InstanceStatus_To_wing_InstanceStatus(in, out, s) +// Convert_v1alpha1_PuppetTargetList_To_wing_PuppetTargetList is an autogenerated conversion function. +func Convert_v1alpha1_PuppetTargetList_To_wing_PuppetTargetList(in *PuppetTargetList, out *wing.PuppetTargetList, s conversion.Scope) error { + return autoConvert_v1alpha1_PuppetTargetList_To_wing_PuppetTargetList(in, out, s) } -func autoConvert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in *wing.InstanceStatus, out *InstanceStatus, s conversion.Scope) error { - out.Converge = (*InstanceStatusManifest)(unsafe.Pointer(in.Converge)) - out.DryRun = (*InstanceStatusManifest)(unsafe.Pointer(in.DryRun)) +func autoConvert_wing_PuppetTargetList_To_v1alpha1_PuppetTargetList(in *wing.PuppetTargetList, out *PuppetTargetList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]PuppetTarget)(unsafe.Pointer(&in.Items)) return nil } -// Convert_wing_InstanceStatus_To_v1alpha1_InstanceStatus is an autogenerated conversion function. -func Convert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in *wing.InstanceStatus, out *InstanceStatus, s conversion.Scope) error { - return autoConvert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in, out, s) +// Convert_wing_PuppetTargetList_To_v1alpha1_PuppetTargetList is an autogenerated conversion function. +func Convert_wing_PuppetTargetList_To_v1alpha1_PuppetTargetList(in *wing.PuppetTargetList, out *PuppetTargetList, s conversion.Scope) error { + return autoConvert_wing_PuppetTargetList_To_v1alpha1_PuppetTargetList(in, out, s) } -func autoConvert_v1alpha1_InstanceStatusManifest_To_wing_InstanceStatusManifest(in *InstanceStatusManifest, out *wing.InstanceStatusManifest, s conversion.Scope) error { - out.State = wing.InstanceManifestState(in.State) - out.Hash = in.Hash +func autoConvert_v1alpha1_S3ManifestSource_To_wing_S3ManifestSource(in *S3ManifestSource, out *wing.S3ManifestSource, s conversion.Scope) error { + out.BucketName = in.BucketName + out.Path = in.Path + return nil +} + +// Convert_v1alpha1_S3ManifestSource_To_wing_S3ManifestSource is an autogenerated conversion function. +func Convert_v1alpha1_S3ManifestSource_To_wing_S3ManifestSource(in *S3ManifestSource, out *wing.S3ManifestSource, s conversion.Scope) error { + return autoConvert_v1alpha1_S3ManifestSource_To_wing_S3ManifestSource(in, out, s) +} + +func autoConvert_wing_S3ManifestSource_To_v1alpha1_S3ManifestSource(in *wing.S3ManifestSource, out *S3ManifestSource, s conversion.Scope) error { + out.BucketName = in.BucketName + out.Path = in.Path + return nil +} + +// Convert_wing_S3ManifestSource_To_v1alpha1_S3ManifestSource is an autogenerated conversion function. +func Convert_wing_S3ManifestSource_To_v1alpha1_S3ManifestSource(in *wing.S3ManifestSource, out *S3ManifestSource, s conversion.Scope) error { + return autoConvert_wing_S3ManifestSource_To_v1alpha1_S3ManifestSource(in, out, s) +} + +func autoConvert_v1alpha1_WingJob_To_wing_WingJob(in *WingJob, out *wing.WingJob, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Spec = (*wing.WingJobSpec)(unsafe.Pointer(in.Spec)) + out.Status = (*wing.WingJobStatus)(unsafe.Pointer(in.Status)) + return nil +} + +// Convert_v1alpha1_WingJob_To_wing_WingJob is an autogenerated conversion function. +func Convert_v1alpha1_WingJob_To_wing_WingJob(in *WingJob, out *wing.WingJob, s conversion.Scope) error { + return autoConvert_v1alpha1_WingJob_To_wing_WingJob(in, out, s) +} + +func autoConvert_wing_WingJob_To_v1alpha1_WingJob(in *wing.WingJob, out *WingJob, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Spec = (*WingJobSpec)(unsafe.Pointer(in.Spec)) + out.Status = (*WingJobStatus)(unsafe.Pointer(in.Status)) + return nil +} + +// Convert_wing_WingJob_To_v1alpha1_WingJob is an autogenerated conversion function. +func Convert_wing_WingJob_To_v1alpha1_WingJob(in *wing.WingJob, out *WingJob, s conversion.Scope) error { + return autoConvert_wing_WingJob_To_v1alpha1_WingJob(in, out, s) +} + +func autoConvert_v1alpha1_WingJobList_To_wing_WingJobList(in *WingJobList, out *wing.WingJobList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]wing.WingJob)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_WingJobList_To_wing_WingJobList is an autogenerated conversion function. +func Convert_v1alpha1_WingJobList_To_wing_WingJobList(in *WingJobList, out *wing.WingJobList, s conversion.Scope) error { + return autoConvert_v1alpha1_WingJobList_To_wing_WingJobList(in, out, s) +} + +func autoConvert_wing_WingJobList_To_v1alpha1_WingJobList(in *wing.WingJobList, out *WingJobList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]WingJob)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_wing_WingJobList_To_v1alpha1_WingJobList is an autogenerated conversion function. +func Convert_wing_WingJobList_To_v1alpha1_WingJobList(in *wing.WingJobList, out *WingJobList, s conversion.Scope) error { + return autoConvert_wing_WingJobList_To_v1alpha1_WingJobList(in, out, s) +} + +func autoConvert_v1alpha1_WingJobSpec_To_wing_WingJobSpec(in *WingJobSpec, out *wing.WingJobSpec, s conversion.Scope) error { + out.InstanceName = in.InstanceName + out.PuppetTargetRef = in.PuppetTargetRef + out.Operation = in.Operation + out.RequestTimestamp = in.RequestTimestamp + return nil +} + +// Convert_v1alpha1_WingJobSpec_To_wing_WingJobSpec is an autogenerated conversion function. +func Convert_v1alpha1_WingJobSpec_To_wing_WingJobSpec(in *WingJobSpec, out *wing.WingJobSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_WingJobSpec_To_wing_WingJobSpec(in, out, s) +} + +func autoConvert_wing_WingJobSpec_To_v1alpha1_WingJobSpec(in *wing.WingJobSpec, out *WingJobSpec, s conversion.Scope) error { + out.InstanceName = in.InstanceName + out.PuppetTargetRef = in.PuppetTargetRef + out.Operation = in.Operation + out.RequestTimestamp = in.RequestTimestamp + return nil +} + +// Convert_wing_WingJobSpec_To_v1alpha1_WingJobSpec is an autogenerated conversion function. +func Convert_wing_WingJobSpec_To_v1alpha1_WingJobSpec(in *wing.WingJobSpec, out *WingJobSpec, s conversion.Scope) error { + return autoConvert_wing_WingJobSpec_To_v1alpha1_WingJobSpec(in, out, s) +} + +func autoConvert_v1alpha1_WingJobStatus_To_wing_WingJobStatus(in *WingJobStatus, out *wing.WingJobStatus, s conversion.Scope) error { + out.Messages = in.Messages + out.ExitCode = in.ExitCode out.LastUpdateTimestamp = in.LastUpdateTimestamp - out.Messages = *(*[]string)(unsafe.Pointer(&in.Messages)) - out.ExitCodes = *(*[]int)(unsafe.Pointer(&in.ExitCodes)) return nil } -// Convert_v1alpha1_InstanceStatusManifest_To_wing_InstanceStatusManifest is an autogenerated conversion function. -func Convert_v1alpha1_InstanceStatusManifest_To_wing_InstanceStatusManifest(in *InstanceStatusManifest, out *wing.InstanceStatusManifest, s conversion.Scope) error { - return autoConvert_v1alpha1_InstanceStatusManifest_To_wing_InstanceStatusManifest(in, out, s) +// Convert_v1alpha1_WingJobStatus_To_wing_WingJobStatus is an autogenerated conversion function. +func Convert_v1alpha1_WingJobStatus_To_wing_WingJobStatus(in *WingJobStatus, out *wing.WingJobStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_WingJobStatus_To_wing_WingJobStatus(in, out, s) } -func autoConvert_wing_InstanceStatusManifest_To_v1alpha1_InstanceStatusManifest(in *wing.InstanceStatusManifest, out *InstanceStatusManifest, s conversion.Scope) error { - out.State = InstanceManifestState(in.State) - out.Hash = in.Hash +func autoConvert_wing_WingJobStatus_To_v1alpha1_WingJobStatus(in *wing.WingJobStatus, out *WingJobStatus, s conversion.Scope) error { + out.Messages = in.Messages + out.ExitCode = in.ExitCode out.LastUpdateTimestamp = in.LastUpdateTimestamp - out.Messages = *(*[]string)(unsafe.Pointer(&in.Messages)) - out.ExitCodes = *(*[]int)(unsafe.Pointer(&in.ExitCodes)) return nil } -// Convert_wing_InstanceStatusManifest_To_v1alpha1_InstanceStatusManifest is an autogenerated conversion function. -func Convert_wing_InstanceStatusManifest_To_v1alpha1_InstanceStatusManifest(in *wing.InstanceStatusManifest, out *InstanceStatusManifest, s conversion.Scope) error { - return autoConvert_wing_InstanceStatusManifest_To_v1alpha1_InstanceStatusManifest(in, out, s) +// Convert_wing_WingJobStatus_To_v1alpha1_WingJobStatus is an autogenerated conversion function. +func Convert_wing_WingJobStatus_To_v1alpha1_WingJobStatus(in *wing.WingJobStatus, out *WingJobStatus, s conversion.Scope) error { + return autoConvert_wing_WingJobStatus_To_v1alpha1_WingJobStatus(in, out, s) } diff --git a/pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go index 68e3769737..a01fb636b2 100644 --- a/pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go @@ -10,6 +10,22 @@ 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 *FileManifestSource) DeepCopyInto(out *FileManifestSource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FileManifestSource. +func (in *FileManifestSource) DeepCopy() *FileManifestSource { + if in == nil { + return nil + } + out := new(FileManifestSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Instance) DeepCopyInto(out *Instance) { *out = *in @@ -21,7 +37,7 @@ func (in *Instance) DeepCopyInto(out *Instance) { *out = nil } else { *out = new(InstanceSpec) - (*in).DeepCopyInto(*out) + **out = **in } } if in.Status != nil { @@ -30,7 +46,7 @@ func (in *Instance) DeepCopyInto(out *Instance) { *out = nil } else { *out = new(InstanceStatus) - (*in).DeepCopyInto(*out) + **out = **in } } return @@ -92,111 +108,256 @@ func (in *InstanceList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstanceSpec) DeepCopyInto(out *InstanceSpec) { *out = *in - if in.Converge != nil { - in, out := &in.Converge, &out.Converge + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSpec. +func (in *InstanceSpec) DeepCopy() *InstanceSpec { + if in == nil { + return nil + } + out := new(InstanceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceStatus) DeepCopyInto(out *InstanceStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceStatus. +func (in *InstanceStatus) DeepCopy() *InstanceStatus { + if in == nil { + return nil + } + out := new(InstanceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ManifestSource) DeepCopyInto(out *ManifestSource) { + *out = *in + if in.S3 != nil { + in, out := &in.S3, &out.S3 if *in == nil { *out = nil } else { - *out = new(InstanceSpecManifest) - (*in).DeepCopyInto(*out) + *out = new(S3ManifestSource) + **out = **in } } - if in.DryRun != nil { - in, out := &in.DryRun, &out.DryRun + if in.File != nil { + in, out := &in.File, &out.File if *in == nil { *out = nil } else { - *out = new(InstanceSpecManifest) - (*in).DeepCopyInto(*out) + *out = new(FileManifestSource) + **out = **in } } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSpec. -func (in *InstanceSpec) DeepCopy() *InstanceSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManifestSource. +func (in *ManifestSource) DeepCopy() *ManifestSource { if in == nil { return nil } - out := new(InstanceSpec) + out := new(ManifestSource) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InstanceSpecManifest) DeepCopyInto(out *InstanceSpecManifest) { +func (in *PuppetTarget) DeepCopyInto(out *PuppetTarget) { *out = *in - in.RequestTimestamp.DeepCopyInto(&out.RequestTimestamp) + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Source.DeepCopyInto(&out.Source) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSpecManifest. -func (in *InstanceSpecManifest) DeepCopy() *InstanceSpecManifest { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PuppetTarget. +func (in *PuppetTarget) DeepCopy() *PuppetTarget { if in == nil { return nil } - out := new(InstanceSpecManifest) + out := new(PuppetTarget) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PuppetTarget) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InstanceStatus) DeepCopyInto(out *InstanceStatus) { +func (in *PuppetTargetList) DeepCopyInto(out *PuppetTargetList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PuppetTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PuppetTargetList. +func (in *PuppetTargetList) DeepCopy() *PuppetTargetList { + if in == nil { + return nil + } + out := new(PuppetTargetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PuppetTargetList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *S3ManifestSource) DeepCopyInto(out *S3ManifestSource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S3ManifestSource. +func (in *S3ManifestSource) DeepCopy() *S3ManifestSource { + if in == nil { + return nil + } + out := new(S3ManifestSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WingJob) DeepCopyInto(out *WingJob) { *out = *in - if in.Converge != nil { - in, out := &in.Converge, &out.Converge + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Spec != nil { + in, out := &in.Spec, &out.Spec if *in == nil { *out = nil } else { - *out = new(InstanceStatusManifest) + *out = new(WingJobSpec) (*in).DeepCopyInto(*out) } } - if in.DryRun != nil { - in, out := &in.DryRun, &out.DryRun + if in.Status != nil { + in, out := &in.Status, &out.Status if *in == nil { *out = nil } else { - *out = new(InstanceStatusManifest) + *out = new(WingJobStatus) (*in).DeepCopyInto(*out) } } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceStatus. -func (in *InstanceStatus) DeepCopy() *InstanceStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WingJob. +func (in *WingJob) DeepCopy() *WingJob { if in == nil { return nil } - out := new(InstanceStatus) + out := new(WingJob) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WingJob) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InstanceStatusManifest) DeepCopyInto(out *InstanceStatusManifest) { +func (in *WingJobList) DeepCopyInto(out *WingJobList) { *out = *in - in.LastUpdateTimestamp.DeepCopyInto(&out.LastUpdateTimestamp) - if in.Messages != nil { - in, out := &in.Messages, &out.Messages - *out = make([]string, len(*in)) - copy(*out, *in) + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]WingJob, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WingJobList. +func (in *WingJobList) DeepCopy() *WingJobList { + if in == nil { + return nil + } + out := new(WingJobList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WingJobList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil } - if in.ExitCodes != nil { - in, out := &in.ExitCodes, &out.ExitCodes - *out = make([]int, len(*in)) - copy(*out, *in) +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WingJobSpec) DeepCopyInto(out *WingJobSpec) { + *out = *in + in.RequestTimestamp.DeepCopyInto(&out.RequestTimestamp) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WingJobSpec. +func (in *WingJobSpec) DeepCopy() *WingJobSpec { + if in == nil { + return nil } + out := new(WingJobSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WingJobStatus) DeepCopyInto(out *WingJobStatus) { + *out = *in + in.LastUpdateTimestamp.DeepCopyInto(&out.LastUpdateTimestamp) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceStatusManifest. -func (in *InstanceStatusManifest) DeepCopy() *InstanceStatusManifest { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WingJobStatus. +func (in *WingJobStatus) DeepCopy() *WingJobStatus { if in == nil { return nil } - out := new(InstanceStatusManifest) + out := new(WingJobStatus) in.DeepCopyInto(out) return out } diff --git a/pkg/apis/wing/zz_generated.deepcopy.go b/pkg/apis/wing/zz_generated.deepcopy.go index 60477ce627..2003d3fd20 100644 --- a/pkg/apis/wing/zz_generated.deepcopy.go +++ b/pkg/apis/wing/zz_generated.deepcopy.go @@ -10,6 +10,22 @@ 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 *FileManifestSource) DeepCopyInto(out *FileManifestSource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FileManifestSource. +func (in *FileManifestSource) DeepCopy() *FileManifestSource { + if in == nil { + return nil + } + out := new(FileManifestSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Instance) DeepCopyInto(out *Instance) { *out = *in @@ -21,7 +37,7 @@ func (in *Instance) DeepCopyInto(out *Instance) { *out = nil } else { *out = new(InstanceSpec) - (*in).DeepCopyInto(*out) + **out = **in } } if in.Status != nil { @@ -30,7 +46,7 @@ func (in *Instance) DeepCopyInto(out *Instance) { *out = nil } else { *out = new(InstanceStatus) - (*in).DeepCopyInto(*out) + **out = **in } } return @@ -92,111 +108,256 @@ func (in *InstanceList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstanceSpec) DeepCopyInto(out *InstanceSpec) { *out = *in - if in.Converge != nil { - in, out := &in.Converge, &out.Converge + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSpec. +func (in *InstanceSpec) DeepCopy() *InstanceSpec { + if in == nil { + return nil + } + out := new(InstanceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceStatus) DeepCopyInto(out *InstanceStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceStatus. +func (in *InstanceStatus) DeepCopy() *InstanceStatus { + if in == nil { + return nil + } + out := new(InstanceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ManifestSource) DeepCopyInto(out *ManifestSource) { + *out = *in + if in.S3 != nil { + in, out := &in.S3, &out.S3 if *in == nil { *out = nil } else { - *out = new(InstanceSpecManifest) - (*in).DeepCopyInto(*out) + *out = new(S3ManifestSource) + **out = **in } } - if in.DryRun != nil { - in, out := &in.DryRun, &out.DryRun + if in.File != nil { + in, out := &in.File, &out.File if *in == nil { *out = nil } else { - *out = new(InstanceSpecManifest) - (*in).DeepCopyInto(*out) + *out = new(FileManifestSource) + **out = **in } } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSpec. -func (in *InstanceSpec) DeepCopy() *InstanceSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManifestSource. +func (in *ManifestSource) DeepCopy() *ManifestSource { if in == nil { return nil } - out := new(InstanceSpec) + out := new(ManifestSource) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InstanceSpecManifest) DeepCopyInto(out *InstanceSpecManifest) { +func (in *PuppetTarget) DeepCopyInto(out *PuppetTarget) { *out = *in - in.RequestTimestamp.DeepCopyInto(&out.RequestTimestamp) + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Source.DeepCopyInto(&out.Source) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSpecManifest. -func (in *InstanceSpecManifest) DeepCopy() *InstanceSpecManifest { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PuppetTarget. +func (in *PuppetTarget) DeepCopy() *PuppetTarget { if in == nil { return nil } - out := new(InstanceSpecManifest) + out := new(PuppetTarget) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PuppetTarget) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InstanceStatus) DeepCopyInto(out *InstanceStatus) { +func (in *PuppetTargetList) DeepCopyInto(out *PuppetTargetList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PuppetTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PuppetTargetList. +func (in *PuppetTargetList) DeepCopy() *PuppetTargetList { + if in == nil { + return nil + } + out := new(PuppetTargetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PuppetTargetList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *S3ManifestSource) DeepCopyInto(out *S3ManifestSource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S3ManifestSource. +func (in *S3ManifestSource) DeepCopy() *S3ManifestSource { + if in == nil { + return nil + } + out := new(S3ManifestSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WingJob) DeepCopyInto(out *WingJob) { *out = *in - if in.Converge != nil { - in, out := &in.Converge, &out.Converge + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Spec != nil { + in, out := &in.Spec, &out.Spec if *in == nil { *out = nil } else { - *out = new(InstanceStatusManifest) + *out = new(WingJobSpec) (*in).DeepCopyInto(*out) } } - if in.DryRun != nil { - in, out := &in.DryRun, &out.DryRun + if in.Status != nil { + in, out := &in.Status, &out.Status if *in == nil { *out = nil } else { - *out = new(InstanceStatusManifest) + *out = new(WingJobStatus) (*in).DeepCopyInto(*out) } } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceStatus. -func (in *InstanceStatus) DeepCopy() *InstanceStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WingJob. +func (in *WingJob) DeepCopy() *WingJob { if in == nil { return nil } - out := new(InstanceStatus) + out := new(WingJob) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WingJob) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InstanceStatusManifest) DeepCopyInto(out *InstanceStatusManifest) { +func (in *WingJobList) DeepCopyInto(out *WingJobList) { *out = *in - in.LastUpdateTimestamp.DeepCopyInto(&out.LastUpdateTimestamp) - if in.Messages != nil { - in, out := &in.Messages, &out.Messages - *out = make([]string, len(*in)) - copy(*out, *in) + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]WingJob, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WingJobList. +func (in *WingJobList) DeepCopy() *WingJobList { + if in == nil { + return nil + } + out := new(WingJobList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WingJobList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil } - if in.ExitCodes != nil { - in, out := &in.ExitCodes, &out.ExitCodes - *out = make([]int, len(*in)) - copy(*out, *in) +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WingJobSpec) DeepCopyInto(out *WingJobSpec) { + *out = *in + in.RequestTimestamp.DeepCopyInto(&out.RequestTimestamp) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WingJobSpec. +func (in *WingJobSpec) DeepCopy() *WingJobSpec { + if in == nil { + return nil } + out := new(WingJobSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WingJobStatus) DeepCopyInto(out *WingJobStatus) { + *out = *in + in.LastUpdateTimestamp.DeepCopyInto(&out.LastUpdateTimestamp) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceStatusManifest. -func (in *InstanceStatusManifest) DeepCopy() *InstanceStatusManifest { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WingJobStatus. +func (in *WingJobStatus) DeepCopy() *WingJobStatus { if in == nil { return nil } - out := new(InstanceStatusManifest) + out := new(WingJobStatus) in.DeepCopyInto(out) return out } diff --git a/pkg/apis/wing/zz_generated.defaults.go b/pkg/apis/wing/zz_generated.defaults.go deleted file mode 100644 index 36b8d95f06..0000000000 --- a/pkg/apis/wing/zz_generated.defaults.go +++ /dev/null @@ -1,18 +0,0 @@ -// +build !ignore_autogenerated - -// Copyright Jetstack Ltd. See LICENSE for details. - -// This file was autogenerated by defaulter-gen. Do not edit it manually! - -package wing - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// RegisterDefaults adds defaulters functions to the given scheme. -// Public to allow building arbitrary schemes. -// All generated defaulters are covering - they call all nested defaulters. -func RegisterDefaults(scheme *runtime.Scheme) error { - return nil -} diff --git a/pkg/wing/admission/plugin/instanceinittime/admission.go b/pkg/wing/admission/plugin/instanceinittime/admission.go index 353b4cbad0..96695844b1 100644 --- a/pkg/wing/admission/plugin/instanceinittime/admission.go +++ b/pkg/wing/admission/plugin/instanceinittime/admission.go @@ -28,30 +28,19 @@ type instanceInitTime struct { // In addition checks that the Name is not on the banned list. // The list is stored in Fischers API objects. func (d *instanceInitTime) Admit(a admission.Attributes) error { - // we are only interested in instances - if a.GetKind().GroupKind() != wing.Kind("Instance") { + // we are only interested in WingJobs + if a.GetKind().GroupKind() != wing.Kind("WingJob") { return nil } - instance, ok := a.GetObject().(*wing.Instance) + job, ok := a.GetObject().(*wing.WingJob) if !ok { return errors.New("unexpected object time") } - if instance.Status != nil { - if instance.Status.Converge != nil && instance.Status.Converge.LastUpdateTimestamp.IsZero() { - instance.Status.Converge.LastUpdateTimestamp.Time = time.Now() - } - if instance.Status.DryRun != nil && instance.Status.DryRun.LastUpdateTimestamp.IsZero() { - instance.Status.DryRun.LastUpdateTimestamp.Time = time.Now() - } - } - if instance.Spec != nil { - if instance.Spec.Converge != nil && instance.Spec.Converge.RequestTimestamp.IsZero() { - instance.Spec.Converge.RequestTimestamp.Time = time.Now() - } - if instance.Spec.DryRun != nil && instance.Spec.DryRun.RequestTimestamp.IsZero() { - instance.Spec.DryRun.RequestTimestamp.Time = time.Now() + if job.Spec != nil { + if job.Spec.RequestTimestamp.IsZero() { + job.Spec.RequestTimestamp.Time = time.Now() } } diff --git a/pkg/wing/apiserver/apiserver.go b/pkg/wing/apiserver/apiserver.go index 17b6754e30..fe451db664 100644 --- a/pkg/wing/apiserver/apiserver.go +++ b/pkg/wing/apiserver/apiserver.go @@ -18,6 +18,7 @@ import ( "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" wingregistry "github.com/jetstack/tarmak/pkg/wing/registry" instancestorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/instance" + wingjobstorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/wingjob" ) var ( @@ -92,6 +93,7 @@ func (c completedConfig) New() (*WingServer, error) { apiGroupInfo.GroupMeta.GroupVersion = v1alpha1.SchemeGroupVersion v1alpha1storage := map[string]rest.Storage{} v1alpha1storage["instances"] = wingregistry.RESTInPeace(instancestorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) + v1alpha1storage["wingjobs"] = wingregistry.RESTInPeace(wingjobstorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil { diff --git a/pkg/wing/controller.go b/pkg/wing/controller.go index ab0cbd3d3a..413537c987 100644 --- a/pkg/wing/controller.go +++ b/pkg/wing/controller.go @@ -44,16 +44,13 @@ func (c *Controller) processNextItem() bool { defer c.queue.Done(key) // Invoke the method containing the business logic - err := c.syncToStdout(key.(string)) + err := c.syncWingJob(key.(string)) // Handle the error if something went wrong during the execution of the business logic c.handleErr(err, key) return true } -// syncToStdout is the business logic of the controller. In this controller it simply prints -// information about the instance to stdout. In case an error happened, it has to simply return the error. -// The retry logic should not be part of the business logic. -func (c *Controller) syncToStdout(key string) error { +func (c *Controller) syncWingJob(key string) error { // ensure only one converge at a time c.wing.convergeWG.Wait() @@ -70,12 +67,16 @@ func (c *Controller) syncToStdout(key string) error { } else { // Note that you also have to check the uid if you have a local controlled resource, which // is dependent on the actual instance, to detect that a Instance was recreated with the same name - instance := obj.(*v1alpha1.Instance) + job, ok := obj.(*v1alpha1.WingJob) + if !ok { + c.log.Error("couldn't cast to WingJob") + return nil + } // trigger converge if status time is older or not existing - if instance.Spec != nil && instance.Spec.Converge != nil && !instance.Spec.Converge.RequestTimestamp.Time.IsZero() { - if instance.Status != nil && instance.Status.Converge != nil && !instance.Status.Converge.LastUpdateTimestamp.Time.IsZero() { - if instance.Status.Converge.LastUpdateTimestamp.Time.After(instance.Spec.Converge.RequestTimestamp.Time) { + if job.Spec != nil && !job.Spec.RequestTimestamp.Time.IsZero() { + if job.Status != nil && !job.Status.LastUpdateTimestamp.Time.IsZero() { + if job.Status.LastUpdateTimestamp.Time.After(job.Spec.RequestTimestamp.Time) { c.log.Debug("no converge neccessary, last update was after request") return nil } @@ -89,7 +90,7 @@ func (c *Controller) syncToStdout(key string) error { } c.log.Infof("running converge") - c.wing.converge() + c.wing.converge(job) } return nil } diff --git a/pkg/wing/puppet.go b/pkg/wing/puppet.go index d50b9005b0..0a965abd7b 100644 --- a/pkg/wing/puppet.go +++ b/pkg/wing/puppet.go @@ -12,7 +12,6 @@ import ( "os" "os/exec" "path/filepath" - "strings" "sync" "syscall" "time" @@ -29,32 +28,31 @@ import ( ) // This make sure puppet is converged when neccessary -func (w *Wing) runPuppet() (*v1alpha1.InstanceStatus, error) { - // start converging mainfest - status := &v1alpha1.InstanceStatus{ - Converge: &v1alpha1.InstanceStatusManifest{ - State: v1alpha1.InstanceManifestStateConverging, - }, - } +func (w *Wing) runPuppet(job *v1alpha1.WingJob) error { + targetAPI := w.clientset.WingV1alpha1().PuppetTargets(w.flags.ClusterName) + target, err := targetAPI.Get( + job.Spec.PuppetTargetRef, + metav1.GetOptions{}, + ) - err := w.reportStatus(status) - if err != nil { - w.log.Warn("reporting status failed: ", err) + noop := true + if job.Spec.Operation == v1alpha1.ApplyOperation { + noop = false } - originalReader, err := w.getManifests(w.flags.ManifestURL) + originalReader, err := w.getManifests(target) if err != nil { - return status, err + return err } // buffer file locally buf, err := ioutil.ReadAll(originalReader) if err != nil { - return status, err + return err } err = originalReader.Close() if err != nil { - return status, err + return err } // create reader from buffer reader := bytes.NewReader(buf) @@ -62,9 +60,9 @@ func (w *Wing) runPuppet() (*v1alpha1.InstanceStatus, error) { // build hash over puppet.tar.gz hash := sha256.New() if _, err := io.Copy(hash, reader); err != nil { - return status, err + return err } - hashString := fmt.Sprintf("sha256:%x", hash.Sum(nil)) + //hashString := fmt.Sprintf("sha256:%x", hash.Sum(nil)) // roll back reader reader.Seek(0, 0) @@ -72,26 +70,23 @@ func (w *Wing) runPuppet() (*v1alpha1.InstanceStatus, error) { // read tar in tarReader, err := gzip.NewReader(reader) if err != nil { - return status, err + return err } dir, err := ioutil.TempDir("", "wing-puppet-tar-gz") if err != nil { - return status, err + return err } defer os.RemoveAll(dir) // clean up err = archive.Unpack(tarReader, dir, &archive.TarOptions{}) if err != nil { - return status, err + return err } tarReader.Close() - var puppetMessages []string - var puppetRetCodes []int - puppetApplyCmd := func() error { - output, retCode, err := w.puppetApply(dir) + output, retCode, err := w.puppetApply(dir, noop) if err == nil && retCode != 0 { err = fmt.Errorf("puppet apply has not converged yet (return code %d)", retCode) @@ -101,21 +96,11 @@ func (w *Wing) runPuppet() (*v1alpha1.InstanceStatus, error) { output = fmt.Sprintf("puppet apply error: %s\n%s", err, output) } - puppetMessages = append(puppetMessages, output) - puppetRetCodes = append(puppetRetCodes, retCode) - // start converging mainfest - status = &v1alpha1.InstanceStatus{ - Converge: &v1alpha1.InstanceStatusManifest{ - State: v1alpha1.InstanceManifestStateConverging, - Messages: puppetMessages, - ExitCodes: puppetRetCodes, - Hash: hashString, - }, - } - statusErr := w.reportStatus(status) - if statusErr != nil { - w.log.Warn("reporting status failed: ", statusErr) + job.Status = &v1alpha1.WingJobStatus{ + Messages: output, + ExitCode: retCode, + //Hash: hashString, } return err @@ -151,56 +136,120 @@ func (w *Wing) runPuppet() (*v1alpha1.InstanceStatus, error) { w.log.Error("error applying puppet:", err) } - return status, nil + return nil } -func (w *Wing) converge() { +func (w *Wing) convergeInstance() error { + instanceAPI := w.clientset.WingV1alpha1().Instances(w.flags.ClusterName) + instance, err := instanceAPI.Get( + w.flags.InstanceName, + metav1.GetOptions{}, + ) + if err != nil { + if kerr, ok := err.(*apierrors.StatusError); ok && kerr.ErrStatus.Reason == metav1.StatusReasonNotFound { + instance = &v1alpha1.Instance{ + ObjectMeta: metav1.ObjectMeta{ + Name: w.flags.InstanceName, + }, + Status: &v1alpha1.InstanceStatus{}, + } + _, err := instanceAPI.Create(instance) + if err != nil { + return fmt.Errorf("error creating instance: %s", err) + } + return nil + } + return fmt.Errorf("error get existing instance: %s", err) + } + + puppetTarget := instance.Spec.PuppetTargetRef + if puppetTarget == "" { + w.log.Warn("no puppet target for instance: ", instance.Name) + return nil + } + + // FIXME: this shouldn't be done on the wing agent + jobName := fmt.Sprintf("%s-%s", w.flags.InstanceName, puppetTarget) + jobsAPI := w.clientset.WingV1alpha1().WingJobs(w.flags.ClusterName) + job, err := jobsAPI.Get( + jobName, + metav1.GetOptions{}, + ) + if err != nil { + if kerr, ok := err.(*apierrors.StatusError); ok && kerr.ErrStatus.Reason == metav1.StatusReasonNotFound { + job = &v1alpha1.WingJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: jobName, + }, + Spec: &v1alpha1.WingJobSpec{ + InstanceName: instance.Name, + PuppetTargetRef: puppetTarget, + Operation: "apply", + RequestTimestamp: metav1.Now(), + }, + Status: &v1alpha1.WingJobStatus{}, + } + _, err := jobsAPI.Create(job) + if err != nil { + return fmt.Errorf("error creating WingJob: %s", err) + } + return nil + } + return fmt.Errorf("error get existing WingJob: %s", err) + } + + return nil +} + +func (w *Wing) converge(job *v1alpha1.WingJob) { w.convergeWG.Add(1) defer w.convergeWG.Done() + jobCopy := job.DeepCopy() + // run puppet - status, err := w.runPuppet() - if err != nil { - status.Converge.State = v1alpha1.InstanceManifestStateError - status.Converge.Messages = append(status.Converge.Messages, err.Error()) - w.log.Error(err) - } else { - status.Converge.State = v1alpha1.InstanceManifestStateConverged - } + err := w.runPuppet(jobCopy) // feedback puppet status to apiserver - err = w.reportStatus(status) + err = w.reportStatus(job) if err != nil { w.log.Warn("reporting status failed: ", err) } } -func (w *Wing) puppetCommand(dir string) Command { +func (w *Wing) puppetCommand(dir string, noop bool) Command { if w.puppetCommandOverride != nil { return w.puppetCommandOverride } + args := []string{"apply"} + + if noop { + args = append(args, "--noop") + } + + args = append(args, []string{ + "--detailed-exitcodes", + "--color", + "no", + "--environment", + "production", + "--hiera_config", + filepath.Join(dir, "hiera.yaml"), + "--modulepath", + filepath.Join(dir, "modules"), + filepath.Join(dir, "manifests/site.pp"), + }..., + ) + return &execCommand{ - Cmd: exec.Command( - "puppet", - "apply", - "--detailed-exitcodes", - "--color", - "no", - "--environment", - "production", - "--hiera_config", - filepath.Join(dir, "hiera.yaml"), - "--modulepath", - filepath.Join(dir, "modules"), - filepath.Join(dir, "manifests/site.pp"), - ), + Cmd: exec.Command("puppet", args...), } } // apply puppet code in a specific directory -func (w *Wing) puppetApply(dir string) (output string, retCode int, err error) { - puppetCmd := w.puppetCommand(dir) +func (w *Wing) puppetApply(dir string, noop bool) (output string, retCode int, err error) { + puppetCmd := w.puppetCommand(dir, noop) var mu sync.Mutex var wg sync.WaitGroup @@ -293,44 +342,26 @@ func (w *Wing) puppetApply(dir string) (output string, retCode int, err error) { return output, 0, nil } -// report status to the API server -func (w *Wing) reportStatus(status *v1alpha1.InstanceStatus) error { - instanceAPI := w.clientset.WingV1alpha1().Instances(w.flags.ClusterName) - instance, err := instanceAPI.Get( - w.flags.InstanceName, - metav1.GetOptions{}, - ) - if err != nil { - if kerr, ok := err.(*apierrors.StatusError); ok && kerr.ErrStatus.Reason == metav1.StatusReasonNotFound { - instance = &v1alpha1.Instance{ - ObjectMeta: metav1.ObjectMeta{ - Name: w.flags.InstanceName, - }, - Status: status.DeepCopy(), - } - _, err := instanceAPI.Create(instance) - if err != nil { - return fmt.Errorf("error creating instance: %s", err) - } - return nil - } - return fmt.Errorf("error get existing instance: %s", err) - } +func (w *Wing) reportStatus(job *v1alpha1.WingJob) error { + jobAPI := w.clientset.WingV1alpha1().WingJobs(w.flags.ClusterName) + + _, err := jobAPI.UpdateStatus(job) - instance.Status = status.DeepCopy() - _, err = instanceAPI.Update(instance) if err != nil { - return fmt.Errorf("error updating existing instance: %s", err) - // TODO: handle race for update + return fmt.Errorf("error updating job status: %s", err) } return nil - } -func (w *Wing) getManifests(manifestURL string) (io.ReadCloser, error) { - if strings.HasPrefix(manifestURL, "s3://") { - return s3.New(w.log).GetManifest(manifestURL) +func (w *Wing) getManifests(target *v1alpha1.PuppetTarget) (io.ReadCloser, error) { + if target.Source.S3 != nil { + return s3.New(w.log).GetManifest(fmt.Sprintf("s3://%s/%s", target.Source.S3.BucketName, target.Source.S3.Path)) } - return file.New(w.log).GetManifest(manifestURL) + + if target.Source.File != nil { + return file.New(w.log).GetManifest(target.Source.File.Path) + } + + return nil, fmt.Errorf("unknown source type") } diff --git a/pkg/wing/registry/wing/wingjob/etcd.go b/pkg/wing/registry/wing/wingjob/etcd.go new file mode 100644 index 0000000000..7bb0b9b6a2 --- /dev/null +++ b/pkg/wing/registry/wing/wingjob/etcd.go @@ -0,0 +1,34 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package wingjob + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + + "github.com/jetstack/tarmak/pkg/apis/wing" + "github.com/jetstack/tarmak/pkg/wing/registry" +) + +// NewREST returns a RESTStorage object that will work against API services. +func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*registry.REST, error) { + strategy := NewStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { return &wing.WingJob{} }, + NewListFunc: func() runtime.Object { return &wing.WingJobList{} }, + PredicateFunc: MatchWingJob, + DefaultQualifiedResource: wing.Resource("wingjobs"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + } + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return nil, err + } + return ®istry.REST{ + Store: store, + }, nil +} diff --git a/pkg/wing/registry/wing/wingjob/strategy.go b/pkg/wing/registry/wing/wingjob/strategy.go new file mode 100644 index 0000000000..005988ac3b --- /dev/null +++ b/pkg/wing/registry/wing/wingjob/strategy.go @@ -0,0 +1,85 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package wingjob + +import ( + "fmt" + + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + + "github.com/jetstack/tarmak/pkg/apis/wing" + genericapirequest "k8s.io/apiserver/pkg/endpoints/request" +) + +func NewStrategy(typer runtime.ObjectTyper) wingJobStrategy { + return wingJobStrategy{typer, names.SimpleNameGenerator} +} + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) { + apiserver, ok := obj.(*wing.WingJob) + if !ok { + return nil, nil, false, fmt.Errorf("given object is not a WingJob.") + } + return labels.Set(apiserver.ObjectMeta.Labels), WingJobToSelectableFields(apiserver), apiserver.Initializers != nil, nil +} + +// MatchWingJob is the filter used by the generic etcd backend to watch events +// from etcd to clients of the apiserver only interested in specific labels/fields. +func MatchWingJob(label labels.Selector, field fields.Selector) storage.SelectionPredicate { + return storage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +// WingJobToSelectableFields returns a field set that represents the object. +func WingJobToSelectableFields(obj *wing.WingJob) fields.Set { + return generic.MergeFieldsSets( + generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true), + fields.Set{ + "spec.instanceName": obj.Spec.InstanceName, + }, + ) +} + +type wingJobStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func (wingJobStrategy) NamespaceScoped() bool { + return true +} + +func (wingJobStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { + // TODO: update all none timestamp to now() +} + +func (wingJobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { + // TODO: update all none timestamp to now() +} + +func (wingJobStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { + return field.ErrorList{} +} + +func (wingJobStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (wingJobStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (wingJobStrategy) Canonicalize(obj runtime.Object) { +} + +func (wingJobStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { + return field.ErrorList{} +} diff --git a/pkg/wing/wing.go b/pkg/wing/wing.go index e2a8ee0829..ff48b8df36 100644 --- a/pkg/wing/wing.go +++ b/pkg/wing/wing.go @@ -64,9 +64,7 @@ func (w *Wing) Run(args []string) error { if w.flags.InstanceName == "" { errors = append(errors, fmt.Errorf("--instance-name flag cannot be empty")) } - if w.flags.ManifestURL == "" { - errors = append(errors, fmt.Errorf("--manifest-url flag cannot be empty")) - } + if err := utilerrors.NewAggregate(errors); err != nil { return err } @@ -89,8 +87,8 @@ func (w *Wing) Run(args []string) error { signal.Notify(signalCh, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP) w.signalHandler(signalCh) - // run converge loop after first start - go w.converge() + // run converge on instance after first start + go w.convergeInstance() // start watching for API server events that trigger applies w.watchForNotifications() @@ -112,8 +110,13 @@ func (w *Wing) Must(err error) *Wing { func (w *Wing) watchForNotifications() { - // create the instance watcher - instanceListWatcher := cache.NewListWatchFromClient(w.clientset.WingV1alpha1().RESTClient(), "instances", w.flags.ClusterName, fields.ParseSelectorOrDie(fmt.Sprintf("metadata.name=%s", w.flags.InstanceName))) + // create the job watcher + jobListWatcher := cache.NewListWatchFromClient( + w.clientset.WingV1alpha1().RESTClient(), + "wingjobs", + w.flags.ClusterName, + fields.ParseSelectorOrDie(fmt.Sprintf("spec.instanceName=%s", w.flags.InstanceName)), + ) // create the workqueue queue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) @@ -122,7 +125,7 @@ func (w *Wing) watchForNotifications() { // whenever the cache is updated, the pod key is added to the workqueue. // Note that when we finally process the item from the workqueue, we might see a newer version // of the Pod than the version which was responsible for triggering the update. - indexer, informer := cache.NewIndexerInformer(instanceListWatcher, &v1alpha1.Instance{}, 0, cache.ResourceEventHandlerFuncs{ + indexer, informer := cache.NewIndexerInformer(jobListWatcher, &v1alpha1.WingJob{}, 0, cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { key, err := cache.MetaNamespaceKeyFunc(obj) if err == nil { @@ -169,7 +172,7 @@ func (w *Wing) signalHandler(ch chan os.Signal) { // create new converge stop channel and run converge w.convergeStopCh = make(chan struct{}) - w.converge() + w.convergeInstance() case syscall.SIGINT: w.log.Infof("wing received SIGINT") From 4552c697ab18fb663f10a719d9a72eed1ecfa551 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Tue, 17 Jul 2018 16:56:42 +0100 Subject: [PATCH 05/14] Check for completed jobs --- pkg/apis/wing/types.go | 2 + pkg/apis/wing/v1alpha1/types.go | 2 + .../wing/v1alpha1/zz_generated.conversion.go | 4 ++ pkg/tarmak/cluster/configuration.go | 28 ++++---- pkg/tarmak/cluster/wing.go | 68 ++++++++++++++++++- pkg/wing/puppet.go | 21 +++++- 6 files changed, 107 insertions(+), 18 deletions(-) diff --git a/pkg/apis/wing/types.go b/pkg/apis/wing/types.go index 7d86014b9e..1b37c37c07 100644 --- a/pkg/apis/wing/types.go +++ b/pkg/apis/wing/types.go @@ -27,6 +27,7 @@ type InstanceSpec struct { // InstanceStatus defines the observed state of Instance type InstanceStatus struct { PuppetTargetRef string + Converged bool } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -93,6 +94,7 @@ type WingJobSpec struct { type WingJobStatus struct { Messages string ExitCode int + Completed bool LastUpdateTimestamp metav1.Time } diff --git a/pkg/apis/wing/v1alpha1/types.go b/pkg/apis/wing/v1alpha1/types.go index 95b8bcc652..bdb022c97c 100644 --- a/pkg/apis/wing/v1alpha1/types.go +++ b/pkg/apis/wing/v1alpha1/types.go @@ -32,6 +32,7 @@ type InstanceSpec struct { // InstanceStatus defines the observed state of Instance type InstanceStatus struct { PuppetTargetRef string `json:"puppetTargetRef"` + Converged bool `json:"converged"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -98,6 +99,7 @@ type WingJobSpec struct { type WingJobStatus struct { Messages string `json:"messages,omitempty"` ExitCode int `json:"exitCode,omitempty"` + Completed bool `json:"completed"` LastUpdateTimestamp metav1.Time `json:"lastUpdateTimestamp,omitempty"` } diff --git a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go index 79e6eeed4a..69ecf75dc4 100644 --- a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go @@ -142,6 +142,7 @@ func Convert_wing_InstanceSpec_To_v1alpha1_InstanceSpec(in *wing.InstanceSpec, o func autoConvert_v1alpha1_InstanceStatus_To_wing_InstanceStatus(in *InstanceStatus, out *wing.InstanceStatus, s conversion.Scope) error { out.PuppetTargetRef = in.PuppetTargetRef + out.Converged = in.Converged return nil } @@ -152,6 +153,7 @@ func Convert_v1alpha1_InstanceStatus_To_wing_InstanceStatus(in *InstanceStatus, func autoConvert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in *wing.InstanceStatus, out *InstanceStatus, s conversion.Scope) error { out.PuppetTargetRef = in.PuppetTargetRef + out.Converged = in.Converged return nil } @@ -329,6 +331,7 @@ func Convert_wing_WingJobSpec_To_v1alpha1_WingJobSpec(in *wing.WingJobSpec, out func autoConvert_v1alpha1_WingJobStatus_To_wing_WingJobStatus(in *WingJobStatus, out *wing.WingJobStatus, s conversion.Scope) error { out.Messages = in.Messages out.ExitCode = in.ExitCode + out.Completed = in.Completed out.LastUpdateTimestamp = in.LastUpdateTimestamp return nil } @@ -341,6 +344,7 @@ func Convert_v1alpha1_WingJobStatus_To_wing_WingJobStatus(in *WingJobStatus, out func autoConvert_wing_WingJobStatus_To_v1alpha1_WingJobStatus(in *wing.WingJobStatus, out *WingJobStatus, s conversion.Scope) error { out.Messages = in.Messages out.ExitCode = in.ExitCode + out.Completed = in.Completed out.LastUpdateTimestamp = in.LastUpdateTimestamp return nil } diff --git a/pkg/tarmak/cluster/configuration.go b/pkg/tarmak/cluster/configuration.go index 0d77435dd4..3199be1f06 100644 --- a/pkg/tarmak/cluster/configuration.go +++ b/pkg/tarmak/cluster/configuration.go @@ -6,6 +6,8 @@ import ( "fmt" "time" + utilerrors "k8s.io/apimachinery/pkg/util/errors" + wingv1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" ) @@ -54,7 +56,7 @@ func (c *Cluster) ReapplyConfiguration() error { if instance.Spec == nil { instance.Spec = &wingv1alpha1.InstanceSpec{} } - instance.Spec.Converge = &wingv1alpha1.InstanceSpecManifest{} + instance.Status.Converged = false if _, err := client.Update(instance); err != nil { c.log.Warnf("error updating instance %s in wing API: %s", instance.Name, err) @@ -78,33 +80,33 @@ func (c *Cluster) WaitForConvergance() error { return fmt.Errorf("failed to list instances: %s", err) } - instanceByState := make(map[wingv1alpha1.InstanceManifestState][]*wingv1alpha1.Instance) + errors := []error{} for pos, _ := range instances { instance := instances[pos] // index by instance convergance state - if instance.Status == nil || instance.Status.Converge == nil || instance.Status.Converge.State == "" { + if instance.Status == nil || instance.Status.Converged == false { continue } - state := instance.Status.Converge.State - if _, ok := instanceByState[state]; !ok { - instanceByState[state] = []*wingv1alpha1.Instance{} + jobs, err := c.listJobsForInstance(instance) + if err != nil { + return err + } + + err = c.checkAllJobsCompleted(jobs) + if err != nil { + errors = append(errors, err) } - instanceByState[state] = append( - instanceByState[state], - instance, - ) } - err = c.checkAllInstancesConverged(instanceByState) - if err == nil { + if len(errors) == 0 { c.log.Info("all instances converged") return nil } else { - c.log.Debug(err) + c.log.Debug(utilerrors.NewAggregate(errors)) } retries-- diff --git a/pkg/tarmak/cluster/wing.go b/pkg/tarmak/cluster/wing.go index c98b087a0b..d9d7cdcbdd 100644 --- a/pkg/tarmak/cluster/wing.go +++ b/pkg/tarmak/cluster/wing.go @@ -15,7 +15,7 @@ import ( wingclientv1alpha1 "github.com/jetstack/tarmak/pkg/wing/client/typed/wing/v1alpha1" ) -func (c *Cluster) wingInstanceClient() (wingclientv1alpha1.InstanceInterface, error) { +func (c *Cluster) ensureWingClientset() error { var err error if c.wingClientset == nil { @@ -37,14 +37,31 @@ func (c *Cluster) wingInstanceClient() (wingclientv1alpha1.InstanceInterface, er b := backoff.WithContext(expBackoff, context.Background()) if err := backoff.Retry(wingClientsetTry, b); err != nil { - return nil, err + return err } + } + + return nil +} +func (c *Cluster) wingInstanceClient() (wingclientv1alpha1.InstanceInterface, error) { + err := c.ensureWingClientset() + if err != nil { + return nil, err } return c.wingClientset.WingV1alpha1().Instances(c.ClusterName()), nil } +func (c *Cluster) wingJobClient() (wingclientv1alpha1.WingJobInterface, error) { + err := c.ensureWingClientset() + if err != nil { + return nil, err + } + + return c.wingClientset.WingV1alpha1().WingJobs(c.ClusterName()), nil +} + func (c *Cluster) listInstances() (instances []*wingv1alpha1.Instance, err error) { // connect to wing client, err := c.wingInstanceClient() @@ -107,6 +124,23 @@ func (c *Cluster) checkAllInstancesConverged(byState map[wingv1alpha1.InstanceMa return nil } +func (c *Cluster) checkAllJobsCompleted(jobs []wingv1alpha1.WingJob) error { + jobsNotCompleted := []wingv1alpha1.WingJob{} + for _, job := range jobs { + if !job.Status.Completed { + jobsNotCompleted = append(jobsNotCompleted, job) + } + } + + c.Log().Debugf("%d jobs not completed: %s", len(jobs), outputWingJobs(jobs)) + + if len(jobsNotCompleted) > 0 { + return fmt.Errorf("not all jobs have completed yet %s", outputWingJobs(jobsNotCompleted)) + } + + return nil +} + func outputInstances(instances []*wingv1alpha1.Instance) string { var output []string for _, instance := range instances { @@ -114,3 +148,33 @@ func outputInstances(instances []*wingv1alpha1.Instance) string { } return strings.Join(output, ", ") } + +func outputWingJobs(jobs []wingv1alpha1.WingJob) string { + var output []string + for _, job := range jobs { + output = append(output, job.Name) + } + return strings.Join(output, ", ") +} + +func (c *Cluster) listJobsForInstance(instance *wingv1alpha1.Instance) ([]wingv1alpha1.WingJob, error) { + err := c.ensureWingClientset() + if err != nil { + return nil, err + } + + client, err := c.wingJobClient() + if err != nil { + return nil, err + } + + list, err := client.List(metav1.ListOptions{ + FieldSelector: fmt.Sprintf("spec.instanceName=%s", instance.Name), + }) + + if err != nil { + return nil, err + } + + return list.Items, err +} diff --git a/pkg/wing/puppet.go b/pkg/wing/puppet.go index 0a965abd7b..b7b27dabcf 100644 --- a/pkg/wing/puppet.go +++ b/pkg/wing/puppet.go @@ -98,8 +98,9 @@ func (w *Wing) runPuppet(job *v1alpha1.WingJob) error { // start converging mainfest job.Status = &v1alpha1.WingJobStatus{ - Messages: output, - ExitCode: retCode, + Messages: output, + ExitCode: retCode, + Completed: true, //Hash: hashString, } @@ -151,7 +152,9 @@ func (w *Wing) convergeInstance() error { ObjectMeta: metav1.ObjectMeta{ Name: w.flags.InstanceName, }, - Status: &v1alpha1.InstanceStatus{}, + Status: &v1alpha1.InstanceStatus{ + Converged: false, + }, } _, err := instanceAPI.Create(instance) if err != nil { @@ -162,6 +165,11 @@ func (w *Wing) convergeInstance() error { return fmt.Errorf("error get existing instance: %s", err) } + if instance.Status.Converged { + w.log.Infof("Instance already converged: ", instance.Name) + return nil + } + puppetTarget := instance.Spec.PuppetTargetRef if puppetTarget == "" { w.log.Warn("no puppet target for instance: ", instance.Name) @@ -198,6 +206,13 @@ func (w *Wing) convergeInstance() error { return fmt.Errorf("error get existing WingJob: %s", err) } + instanceCopy := instance.DeepCopy() + instanceCopy.Status.Converged = true + _, err = instanceAPI.Update(instanceCopy) + if err != nil { + return err + } + return nil } From baf5e1eff178511c509c42ae6e2d4ef178e33f99 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Wed, 18 Jul 2018 15:00:08 +0100 Subject: [PATCH 06/14] Start adding upload support --- pkg/tarmak/cluster/configuration.go | 7 +++++++ pkg/tarmak/interfaces/interfaces.go | 2 +- pkg/tarmak/provider/amazon/upload_config.go | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/tarmak/cluster/configuration.go b/pkg/tarmak/cluster/configuration.go index 3199be1f06..787deaca31 100644 --- a/pkg/tarmak/cluster/configuration.go +++ b/pkg/tarmak/cluster/configuration.go @@ -3,6 +3,8 @@ package cluster import ( "bytes" + "crypto/sha256" + "encoding/hex" "fmt" "time" @@ -26,11 +28,16 @@ func (c *Cluster) UploadConfiguration() error { return err } + hash := sha256.New() + hash.Write(buffer.Bytes()) + name := hex.EncodeToString(hash.Sum(nil)) + // build reader from config reader := bytes.NewReader(buffer.Bytes()) return c.Environment().Provider().UploadConfiguration( c, + name, reader, ) } diff --git a/pkg/tarmak/interfaces/interfaces.go b/pkg/tarmak/interfaces/interfaces.go index eca167a810..37a2681a90 100644 --- a/pkg/tarmak/interfaces/interfaces.go +++ b/pkg/tarmak/interfaces/interfaces.go @@ -126,7 +126,7 @@ type Provider interface { String() string AskEnvironmentLocation(Initialize) (string, error) AskInstancePoolZones(Initialize) (zones []string, err error) - UploadConfiguration(Cluster, io.ReadSeeker) error + UploadConfiguration(Cluster, string, io.ReadSeeker) error VerifyInstanceTypes(intstancePools []InstancePool) error } diff --git a/pkg/tarmak/provider/amazon/upload_config.go b/pkg/tarmak/provider/amazon/upload_config.go index 8894e666ab..5101afab8d 100644 --- a/pkg/tarmak/provider/amazon/upload_config.go +++ b/pkg/tarmak/provider/amazon/upload_config.go @@ -13,7 +13,7 @@ import ( ) // This uploads the main configuration to the S3 bucket -func (a *Amazon) UploadConfiguration(cluster interfaces.Cluster, configReader io.ReadSeeker) error { +func (a *Amazon) UploadConfiguration(cluster interfaces.Cluster, path string, configReader io.ReadSeeker) error { svc, err := a.S3() if err != nil { return err From 12fe2cf962ab8f69e09921ab5ad6c7568eb4a070 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Mon, 23 Jul 2018 12:17:10 +0100 Subject: [PATCH 07/14] Enable puppettarget in api --- pkg/apis/wing/register.go | 2 ++ pkg/apis/wing/v1alpha1/register.go | 2 ++ pkg/wing/apiserver/apiserver.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/pkg/apis/wing/register.go b/pkg/apis/wing/register.go index 10fdfa5a50..69ae3ba7c1 100644 --- a/pkg/apis/wing/register.go +++ b/pkg/apis/wing/register.go @@ -33,6 +33,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &InstanceList{}, &WingJob{}, &WingJobList{}, + &PuppetTarget{}, + &PuppetTargetList{}, ) return nil } diff --git a/pkg/apis/wing/v1alpha1/register.go b/pkg/apis/wing/v1alpha1/register.go index b4b9126480..a39b0bf85d 100644 --- a/pkg/apis/wing/v1alpha1/register.go +++ b/pkg/apis/wing/v1alpha1/register.go @@ -37,6 +37,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &InstanceList{}, &WingJob{}, &WingJobList{}, + &PuppetTarget{}, + &PuppetTargetList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/pkg/wing/apiserver/apiserver.go b/pkg/wing/apiserver/apiserver.go index fe451db664..9aaeb2f014 100644 --- a/pkg/wing/apiserver/apiserver.go +++ b/pkg/wing/apiserver/apiserver.go @@ -18,6 +18,7 @@ import ( "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" wingregistry "github.com/jetstack/tarmak/pkg/wing/registry" instancestorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/instance" + puppettargetstorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/puppettarget" wingjobstorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/wingjob" ) @@ -94,6 +95,7 @@ func (c completedConfig) New() (*WingServer, error) { v1alpha1storage := map[string]rest.Storage{} v1alpha1storage["instances"] = wingregistry.RESTInPeace(instancestorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) v1alpha1storage["wingjobs"] = wingregistry.RESTInPeace(wingjobstorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) + v1alpha1storage["puppettargets"] = wingregistry.RESTInPeace(puppettargetstorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil { From 1d24b0df5007eeff0b2bbaab2f35513a23e228e2 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Mon, 23 Jul 2018 15:40:52 +0100 Subject: [PATCH 08/14] Add puppettarget registry --- pkg/wing/registry/wing/puppettarget/etcd.go | 34 ++++++++ .../registry/wing/puppettarget/strategy.go | 80 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 pkg/wing/registry/wing/puppettarget/etcd.go create mode 100644 pkg/wing/registry/wing/puppettarget/strategy.go diff --git a/pkg/wing/registry/wing/puppettarget/etcd.go b/pkg/wing/registry/wing/puppettarget/etcd.go new file mode 100644 index 0000000000..f441471f06 --- /dev/null +++ b/pkg/wing/registry/wing/puppettarget/etcd.go @@ -0,0 +1,34 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package puppettarget + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + + "github.com/jetstack/tarmak/pkg/apis/wing" + "github.com/jetstack/tarmak/pkg/wing/registry" +) + +// NewREST returns a RESTStorage object that will work against API services. +func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*registry.REST, error) { + strategy := NewStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { return &wing.PuppetTarget{} }, + NewListFunc: func() runtime.Object { return &wing.PuppetTargetList{} }, + PredicateFunc: MatchPuppetTarget, + DefaultQualifiedResource: wing.Resource("puppettargets"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + } + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return nil, err + } + return ®istry.REST{ + Store: store, + }, nil +} diff --git a/pkg/wing/registry/wing/puppettarget/strategy.go b/pkg/wing/registry/wing/puppettarget/strategy.go new file mode 100644 index 0000000000..8956f43758 --- /dev/null +++ b/pkg/wing/registry/wing/puppettarget/strategy.go @@ -0,0 +1,80 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package puppettarget + +import ( + "fmt" + + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + + "github.com/jetstack/tarmak/pkg/apis/wing" + genericapirequest "k8s.io/apiserver/pkg/endpoints/request" +) + +func NewStrategy(typer runtime.ObjectTyper) puppetTargetStrategy { + return puppetTargetStrategy{typer, names.SimpleNameGenerator} +} + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) { + apiserver, ok := obj.(*wing.PuppetTarget) + if !ok { + return nil, nil, false, fmt.Errorf("given object is not a PuppetTarget.") + } + return labels.Set(apiserver.ObjectMeta.Labels), PuppetTargetToSelectableFields(apiserver), apiserver.Initializers != nil, nil +} + +// MatchPuppetTarget is the filter used by the generic etcd backend to watch events +// from etcd to clients of the apiserver only interested in specific labels/fields. +func MatchPuppetTarget(label labels.Selector, field fields.Selector) storage.SelectionPredicate { + return storage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +// PuppetTargetToSelectableFields returns a field set that represents the object. +func PuppetTargetToSelectableFields(obj *wing.PuppetTarget) fields.Set { + return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true) +} + +type puppetTargetStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func (puppetTargetStrategy) NamespaceScoped() bool { + return true +} + +func (puppetTargetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { + // TODO: update all none timestamp to now() +} + +func (puppetTargetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { + // TODO: update all none timestamp to now() +} + +func (puppetTargetStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { + return field.ErrorList{} +} + +func (puppetTargetStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (puppetTargetStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (puppetTargetStrategy) Canonicalize(obj runtime.Object) { +} + +func (puppetTargetStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { + return field.ErrorList{} +} From 216caf0f3d1f2a40067e9818405875320ee291b5 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Mon, 23 Jul 2018 15:41:40 +0100 Subject: [PATCH 09/14] Add region to s3 --- pkg/apis/wing/types.go | 1 + pkg/apis/wing/v1alpha1/types.go | 1 + .../wing/v1alpha1/zz_generated.conversion.go | 2 ++ pkg/wing/controller.go | 4 +-- pkg/wing/provider/s3/s3.go | 8 +++-- pkg/wing/puppet.go | 31 +++++++++++++++---- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/pkg/apis/wing/types.go b/pkg/apis/wing/types.go index 1b37c37c07..42fc499ef6 100644 --- a/pkg/apis/wing/types.go +++ b/pkg/apis/wing/types.go @@ -58,6 +58,7 @@ type ManifestSource struct { type S3ManifestSource struct { BucketName string Path string + Region string } type FileManifestSource struct { diff --git a/pkg/apis/wing/v1alpha1/types.go b/pkg/apis/wing/v1alpha1/types.go index bdb022c97c..1397257c8d 100644 --- a/pkg/apis/wing/v1alpha1/types.go +++ b/pkg/apis/wing/v1alpha1/types.go @@ -63,6 +63,7 @@ type ManifestSource struct { type S3ManifestSource struct { BucketName string `json:"bucketName"` Path string `json:"path"` + Region string `json:"region"` } type FileManifestSource struct { diff --git a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go index 69ecf75dc4..2073160a79 100644 --- a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go @@ -237,6 +237,7 @@ func Convert_wing_PuppetTargetList_To_v1alpha1_PuppetTargetList(in *wing.PuppetT func autoConvert_v1alpha1_S3ManifestSource_To_wing_S3ManifestSource(in *S3ManifestSource, out *wing.S3ManifestSource, s conversion.Scope) error { out.BucketName = in.BucketName out.Path = in.Path + out.Region = in.Region return nil } @@ -248,6 +249,7 @@ func Convert_v1alpha1_S3ManifestSource_To_wing_S3ManifestSource(in *S3ManifestSo func autoConvert_wing_S3ManifestSource_To_v1alpha1_S3ManifestSource(in *wing.S3ManifestSource, out *S3ManifestSource, s conversion.Scope) error { out.BucketName = in.BucketName out.Path = in.Path + out.Region = in.Region return nil } diff --git a/pkg/wing/controller.go b/pkg/wing/controller.go index 413537c987..cfd759a70f 100644 --- a/pkg/wing/controller.go +++ b/pkg/wing/controller.go @@ -80,10 +80,10 @@ func (c *Controller) syncWingJob(key string) error { c.log.Debug("no converge neccessary, last update was after request") return nil } - } else { + } /* else { c.log.Debug("no converge neccessary, no status section found or update timestamp zero") return nil - } + }*/ } else { c.log.Debug("no converge neccessary, no spec section found or request timestamp zero") return nil diff --git a/pkg/wing/provider/s3/s3.go b/pkg/wing/provider/s3/s3.go index 8f69df0694..80a3b64ac1 100644 --- a/pkg/wing/provider/s3/s3.go +++ b/pkg/wing/provider/s3/s3.go @@ -22,7 +22,7 @@ func New(log *logrus.Entry) *S3 { } } -func (s *S3) GetManifest(manifestString string) (io.ReadCloser, error) { +func (s *S3) GetManifest(manifestString string, region string) (io.ReadCloser, error) { manifestURL, err := url.Parse(manifestString) if err != nil { return nil, err @@ -32,7 +32,11 @@ func (s *S3) GetManifest(manifestString string) (io.ReadCloser, error) { key := manifestURL.Path cfg := aws.NewConfig() - awsSession := session.New(cfg) + awsSession := session.New(cfg, + &aws.Config{ + Region: aws.String(region), + }, + ) s3Service := s3.New(awsSession) result, err := s3Service.GetObject(&s3.GetObjectInput{ diff --git a/pkg/wing/puppet.go b/pkg/wing/puppet.go index b7b27dabcf..fe85f587a4 100644 --- a/pkg/wing/puppet.go +++ b/pkg/wing/puppet.go @@ -88,6 +88,8 @@ func (w *Wing) runPuppet(job *v1alpha1.WingJob) error { puppetApplyCmd := func() error { output, retCode, err := w.puppetApply(dir, noop) + w.log.Infof("puppet output: %s", output) + if err == nil && retCode != 0 { err = fmt.Errorf("puppet apply has not converged yet (return code %d)", retCode) } @@ -98,9 +100,10 @@ func (w *Wing) runPuppet(job *v1alpha1.WingJob) error { // start converging mainfest job.Status = &v1alpha1.WingJobStatus{ - Messages: output, - ExitCode: retCode, - Completed: true, + Messages: output, + ExitCode: retCode, + LastUpdateTimestamp: metav1.Now(), + Completed: true, //Hash: hashString, } @@ -170,6 +173,11 @@ func (w *Wing) convergeInstance() error { return nil } + if instance.Spec == nil { + w.log.Warnf("instance %s has empty spec field", instance.Name) + return nil + } + puppetTarget := instance.Spec.PuppetTargetRef if puppetTarget == "" { w.log.Warn("no puppet target for instance: ", instance.Name) @@ -224,9 +232,12 @@ func (w *Wing) converge(job *v1alpha1.WingJob) { // run puppet err := w.runPuppet(jobCopy) + if err != nil { + w.log.Warn("running puppet failed: ", err) + } // feedback puppet status to apiserver - err = w.reportStatus(job) + err = w.reportStatus(jobCopy) if err != nil { w.log.Warn("reporting status failed: ", err) } @@ -264,6 +275,8 @@ func (w *Wing) puppetCommand(dir string, noop bool) Command { // apply puppet code in a specific directory func (w *Wing) puppetApply(dir string, noop bool) (output string, retCode int, err error) { + w.log.Infof("Running puppet in %s", dir) + puppetCmd := w.puppetCommand(dir, noop) var mu sync.Mutex @@ -360,7 +373,7 @@ func (w *Wing) puppetApply(dir string, noop bool) (output string, retCode int, e func (w *Wing) reportStatus(job *v1alpha1.WingJob) error { jobAPI := w.clientset.WingV1alpha1().WingJobs(w.flags.ClusterName) - _, err := jobAPI.UpdateStatus(job) + _, err := jobAPI.Update(job) if err != nil { return fmt.Errorf("error updating job status: %s", err) @@ -371,7 +384,13 @@ func (w *Wing) reportStatus(job *v1alpha1.WingJob) error { func (w *Wing) getManifests(target *v1alpha1.PuppetTarget) (io.ReadCloser, error) { if target.Source.S3 != nil { - return s3.New(w.log).GetManifest(fmt.Sprintf("s3://%s/%s", target.Source.S3.BucketName, target.Source.S3.Path)) + + manifestStr := fmt.Sprintf("s3://%s/%s", target.Source.S3.BucketName, target.Source.S3.Path) + w.log.Infof("Getting manifests from S3: %s", manifestStr) + return s3.New(w.log).GetManifest( + manifestStr, + target.Source.S3.Region, + ) } if target.Source.File != nil { From 71f772154d22f98497a8bc93fb0d608b7d75422a Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Tue, 24 Jul 2018 11:01:13 +0100 Subject: [PATCH 10/14] Add instance controller --- pkg/wing/controller.go | 6 +- pkg/wing/instancecontroller.go | 134 +++++++++++++++++++++++++++++++++ pkg/wing/puppet.go | 4 + pkg/wing/wing.go | 46 ++++++++++- 4 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 pkg/wing/instancecontroller.go diff --git a/pkg/wing/controller.go b/pkg/wing/controller.go index cfd759a70f..f71a77082a 100644 --- a/pkg/wing/controller.go +++ b/pkg/wing/controller.go @@ -63,7 +63,7 @@ func (c *Controller) syncWingJob(key string) error { if !exists { // Below we will warm up our cache with a Instance, so that we will see a delete for one instance - fmt.Printf("Instance %s does not exist anymore\n", key) + fmt.Printf("WingJob %s does not exist anymore\n", key) } else { // Note that you also have to check the uid if you have a local controlled resource, which // is dependent on the actual instance, to detect that a Instance was recreated with the same name @@ -126,7 +126,7 @@ func (c *Controller) Run(threadiness int, stopCh chan struct{}) { // Let the workers stop when we are done defer c.queue.ShutDown() - c.log.Info("Starting Instance controller") + c.log.Info("Starting WingJob controller") go c.informer.Run(stopCh) @@ -141,7 +141,7 @@ func (c *Controller) Run(threadiness int, stopCh chan struct{}) { } <-stopCh - c.log.Info("Stopping Instance controller") + c.log.Info("Stopping WingJob controller") } func (c *Controller) runWorker() { diff --git a/pkg/wing/instancecontroller.go b/pkg/wing/instancecontroller.go new file mode 100644 index 0000000000..43e017f070 --- /dev/null +++ b/pkg/wing/instancecontroller.go @@ -0,0 +1,134 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package wing + +import ( + "fmt" + "time" + + "github.com/sirupsen/logrus" + "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/workqueue" + + "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" +) + +type InstanceController struct { + indexer cache.Indexer + queue workqueue.RateLimitingInterface + informer cache.Controller + log *logrus.Entry + wing *Wing +} + +func NewInstanceController(queue workqueue.RateLimitingInterface, indexer cache.Indexer, informer cache.Controller, wing *Wing) *InstanceController { + return &InstanceController{ + informer: informer, + indexer: indexer, + queue: queue, + log: wing.log.WithField("tier", "InstanceController"), + wing: wing, + } +} + +func (c *InstanceController) processNextItem() bool { + // Wait until there is a new item in the working queue + key, quit := c.queue.Get() + if quit { + return false + } + // Tell the queue that we are done with processing this key. This unblocks the key for other workers + // This allows safe parallel processing because two instances with the same key are never processed in + // parallel. + defer c.queue.Done(key) + + // Invoke the method containing the business logic + err := c.syncInstance(key.(string)) + // Handle the error if something went wrong during the execution of the business logic + c.handleErr(err, key) + return true +} + +func (c *InstanceController) syncInstance(key string) error { + + // ensure only one converge at a time + c.wing.convergeWG.Wait() + + obj, exists, err := c.indexer.GetByKey(key) + if err != nil { + c.log.Errorf("Fetching object with key %s from store failed with %v", key, err) + return err + } + + if !exists { + // Below we will warm up our cache with a Instance, so that we will see a delete for one instance + fmt.Printf("Instance %s does not exist anymore\n", key) + } else { + // Note that you also have to check the uid if you have a local controlled resource, which + // is dependent on the actual instance, to detect that a Instance was recreated with the same name + _, ok := obj.(*v1alpha1.Instance) + if !ok { + c.log.Error("couldn't cast to Instance") + return nil + } + + c.log.Infof("running converge") + c.wing.convergeInstance() + } + return nil +} + +// handleErr checks if an error happened and makes sure we will retry later. +func (c *InstanceController) handleErr(err error, key interface{}) { + if err == nil { + // Forget about the #AddRateLimited history of the key on every successful synchronization. + // This ensures that future processing of updates for this key is not delayed because of + // an outdated error history. + c.queue.Forget(key) + return + } + + // This controller retries 5 times if something goes wrong. After that, it stops trying. + if c.queue.NumRequeues(key) < 5 { + c.log.Infof("Error syncing instance %v: %v", key, err) + + // Re-enqueue the key rate limited. Based on the rate limiter on the + // queue and the re-enqueue history, the key will be processed later again. + c.queue.AddRateLimited(key) + return + } + + c.queue.Forget(key) + // Report to an external entity that, even after several retries, we could not successfully process this key + runtime.HandleError(err) + c.log.Infof("Dropping instance %q out of the queue: %v", key, err) +} + +func (c *InstanceController) Run(threadiness int, stopCh chan struct{}) { + defer runtime.HandleCrash() + + // Let the workers stop when we are done + defer c.queue.ShutDown() + c.log.Info("Starting Instance controller") + + go c.informer.Run(stopCh) + + // Wait for all involved caches to be synced, before processing items from the queue is started + if !cache.WaitForCacheSync(stopCh, c.informer.HasSynced) { + runtime.HandleError(fmt.Errorf("Timed out waiting for caches to sync")) + return + } + + for i := 0; i < threadiness; i++ { + go wait.Until(c.runWorker, time.Second, stopCh) + } + + <-stopCh + c.log.Info("Stopping Instance controller") +} + +func (c *InstanceController) runWorker() { + for c.processNextItem() { + } +} diff --git a/pkg/wing/puppet.go b/pkg/wing/puppet.go index fe85f587a4..729cb65a67 100644 --- a/pkg/wing/puppet.go +++ b/pkg/wing/puppet.go @@ -268,6 +268,10 @@ func (w *Wing) puppetCommand(dir string, noop bool) Command { }..., ) + return &execCommand{ + Cmd: exec.Command("git", "status"), + } + return &execCommand{ Cmd: exec.Command("puppet", args...), } diff --git a/pkg/wing/wing.go b/pkg/wing/wing.go index ff48b8df36..2563c15564 100644 --- a/pkg/wing/wing.go +++ b/pkg/wing/wing.go @@ -32,7 +32,8 @@ type Wing struct { convergeWG sync.WaitGroup // wait group for converge runs // controller loop - controller *Controller + controller *Controller + instanceController *InstanceController // allows overriding puppet command for testing puppetCommandOverride Command @@ -115,6 +116,7 @@ func (w *Wing) watchForNotifications() { w.clientset.WingV1alpha1().RESTClient(), "wingjobs", w.flags.ClusterName, + //fields.Everything(), fields.ParseSelectorOrDie(fmt.Sprintf("spec.instanceName=%s", w.flags.InstanceName)), ) @@ -153,6 +155,48 @@ func (w *Wing) watchForNotifications() { // Now let's start the controller go w.controller.Run(1, w.stopCh) + instanceListWatcher := cache.NewListWatchFromClient( + w.clientset.WingV1alpha1().RESTClient(), + "instances", w.flags.ClusterName, + fields.ParseSelectorOrDie(fmt.Sprintf("metadata.name=%s", + w.flags.InstanceName)), + ) + + // create the workqueue + instanceQueue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) + + // Bind the workqueue to a cache with the help of an informer. This way we make sure that + // whenever the cache is updated, the pod key is added to the workqueue. + // Note that when we finally process the item from the workqueue, we might see a newer version + // of the Pod than the version which was responsible for triggering the update. + instanceIndexer, instanceInformer := cache.NewIndexerInformer(instanceListWatcher, &v1alpha1.Instance{}, 0, cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { + key, err := cache.MetaNamespaceKeyFunc(obj) + if err == nil { + instanceQueue.AddAfter(key, 2*time.Second) + } + }, + UpdateFunc: func(old interface{}, new interface{}) { + key, err := cache.MetaNamespaceKeyFunc(new) + if err == nil { + instanceQueue.AddAfter(key, 2*time.Second) + } + }, + DeleteFunc: func(obj interface{}) { + // IndexerInformer uses a delta queue, therefore for deletes we have to use this + // key function. + key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) + if err == nil { + instanceQueue.AddAfter(key, 2*time.Second) + } + }, + }, cache.Indexers{}) + + w.instanceController = NewInstanceController(instanceQueue, instanceIndexer, instanceInformer, w) + + // Now let's start the controller + go w.instanceController.Run(1, w.stopCh) + } func (w *Wing) signalHandler(ch chan os.Signal) { From fe30e01497bdc4c6e08c81bd9ef97516ad7a42d3 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Tue, 24 Jul 2018 15:23:26 +0100 Subject: [PATCH 11/14] Add machine types from cluster-api --- .../cluster/v1alpha1/zz_generated.deepcopy.go | 310 +++++++++++++++++- .../tarmak/v1alpha1/zz_generated.deepcopy.go | 5 + pkg/apis/wing/clustercommon/consts.go | 131 ++++++++ pkg/apis/wing/machine_types.go | 163 +++++++++ pkg/apis/wing/provider_config.go | 43 +++ pkg/apis/wing/register.go | 4 +- pkg/apis/wing/v1alpha1/machine_types.go | 163 +++++++++ pkg/apis/wing/v1alpha1/provider_config.go | 43 +++ pkg/apis/wing/v1alpha1/register.go | 4 +- .../wing/v1alpha1/zz_generated.conversion.go | 202 ++++++++++++ .../wing/v1alpha1/zz_generated.deepcopy.go | 238 ++++++++++++++ pkg/apis/wing/zz_generated.deepcopy.go | 238 ++++++++++++++ pkg/wing/apiserver/apiserver.go | 4 +- .../typed/wing/v1alpha1/fake/fake_machine.go | 123 +++++++ .../wing/v1alpha1/fake/fake_wing_client.go | 4 + .../wing/v1alpha1/generated_expansion.go | 2 + .../client/typed/wing/v1alpha1/machine.go | 157 +++++++++ .../client/typed/wing/v1alpha1/wing_client.go | 5 + .../wing/internalversion/fake/fake_machine.go | 123 +++++++ .../internalversion/fake/fake_wing_client.go | 4 + .../internalversion/generated_expansion.go | 2 + .../typed/wing/internalversion/machine.go | 157 +++++++++ .../typed/wing/internalversion/wing_client.go | 5 + .../externalversions/apis/interface.go | 32 ++ .../informers/externalversions/factory.go | 6 + .../informers/externalversions/generic.go | 15 +- .../wing/v1alpha1/interface.go | 7 + .../externalversions/wing/v1alpha1/machine.go | 74 +++++ pkg/wing/informers/internalversion/generic.go | 2 + .../wing/internalversion/interface.go | 7 + .../wing/internalversion/machine.go | 74 +++++ .../internalversion/expansion_generated.go | 8 + .../listers/wing/internalversion/machine.go | 80 +++++ .../wing/v1alpha1/expansion_generated.go | 8 + pkg/wing/listers/wing/v1alpha1/machine.go | 80 +++++ pkg/wing/registry/wing/machine/etcd.go | 34 ++ pkg/wing/registry/wing/machine/strategy.go | 80 +++++ 37 files changed, 2629 insertions(+), 8 deletions(-) create mode 100644 pkg/apis/wing/clustercommon/consts.go create mode 100644 pkg/apis/wing/machine_types.go create mode 100644 pkg/apis/wing/provider_config.go create mode 100644 pkg/apis/wing/v1alpha1/machine_types.go create mode 100644 pkg/apis/wing/v1alpha1/provider_config.go create mode 100644 pkg/wing/client/typed/wing/v1alpha1/fake/fake_machine.go create mode 100644 pkg/wing/client/typed/wing/v1alpha1/machine.go create mode 100644 pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_machine.go create mode 100644 pkg/wing/clients/internalclientset/typed/wing/internalversion/machine.go create mode 100644 pkg/wing/informers/externalversions/apis/interface.go create mode 100644 pkg/wing/informers/externalversions/wing/v1alpha1/machine.go create mode 100644 pkg/wing/informers/internalversion/wing/internalversion/machine.go create mode 100644 pkg/wing/listers/wing/internalversion/machine.go create mode 100644 pkg/wing/listers/wing/v1alpha1/machine.go create mode 100644 pkg/wing/registry/wing/machine/etcd.go create mode 100644 pkg/wing/registry/wing/machine/strategy.go diff --git a/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go index f5fb546041..486a3a3e41 100644 --- a/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go @@ -11,6 +11,22 @@ 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 *AmazonESProxy) DeepCopyInto(out *AmazonESProxy) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AmazonESProxy. +func (in *AmazonESProxy) DeepCopy() *AmazonESProxy { + if in == nil { + return nil + } + out := new(AmazonESProxy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Cluster) DeepCopyInto(out *Cluster) { *out = *in @@ -32,6 +48,18 @@ func (in *Cluster) DeepCopyInto(out *Cluster) { (*in).DeepCopyInto(*out) } } + if in.LoggingSinks != nil { + in, out := &in.LoggingSinks, &out.LoggingSinks + *out = make([]*LoggingSink, len(*in)) + for i := range *in { + if (*in)[i] == nil { + (*out)[i] = nil + } else { + (*out)[i] = new(LoggingSink) + (*in)[i].DeepCopyInto((*out)[i]) + } + } + } if in.Values != nil { in, out := &in.Values, &out.Values if *in == nil { @@ -59,6 +87,15 @@ func (in *Cluster) DeepCopyInto(out *Cluster) { (*in).DeepCopyInto(*out) } } + if in.Amazon != nil { + in, out := &in.Amazon, &out.Amazon + if *in == nil { + *out = nil + } else { + *out = new(ClusterAmazon) + (*in).DeepCopyInto(*out) + } + } return } @@ -81,6 +118,27 @@ func (in *Cluster) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterAmazon) DeepCopyInto(out *ClusterAmazon) { + *out = *in + if in.AdditionalIAMPolicies != nil { + in, out := &in.AdditionalIAMPolicies, &out.AdditionalIAMPolicies + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterAmazon. +func (in *ClusterAmazon) DeepCopy() *ClusterAmazon { + if in == nil { + return nil + } + out := new(ClusterAmazon) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterKubernetes) DeepCopyInto(out *ClusterKubernetes) { *out = *in @@ -90,7 +148,7 @@ func (in *ClusterKubernetes) DeepCopyInto(out *ClusterKubernetes) { *out = nil } else { *out = new(ClusterKubernetesClusterAutoscaler) - **out = **in + (*in).DeepCopyInto(*out) } } if in.Tiller != nil { @@ -111,6 +169,33 @@ func (in *ClusterKubernetes) DeepCopyInto(out *ClusterKubernetes) { **out = **in } } + if in.APIServer != nil { + in, out := &in.APIServer, &out.APIServer + if *in == nil { + *out = nil + } else { + *out = new(ClusterKubernetesAPIServer) + (*in).DeepCopyInto(*out) + } + } + if in.PodSecurityPolicy != nil { + in, out := &in.PodSecurityPolicy, &out.PodSecurityPolicy + if *in == nil { + *out = nil + } else { + *out = new(ClusterPodSecurityPolicy) + **out = **in + } + } + if in.Prometheus != nil { + in, out := &in.Prometheus, &out.Prometheus + if *in == nil { + *out = nil + } else { + *out = new(ClusterKubernetesPrometheus) + **out = **in + } + } return } @@ -124,9 +209,69 @@ func (in *ClusterKubernetes) DeepCopy() *ClusterKubernetes { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterKubernetesAPIServer) DeepCopyInto(out *ClusterKubernetesAPIServer) { + *out = *in + if in.AllowCIDRs != nil { + in, out := &in.AllowCIDRs, &out.AllowCIDRs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.OIDC != nil { + in, out := &in.OIDC, &out.OIDC + if *in == nil { + *out = nil + } else { + *out = new(ClusterKubernetesAPIServerOIDC) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterKubernetesAPIServer. +func (in *ClusterKubernetesAPIServer) DeepCopy() *ClusterKubernetesAPIServer { + if in == nil { + return nil + } + out := new(ClusterKubernetesAPIServer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterKubernetesAPIServerOIDC) DeepCopyInto(out *ClusterKubernetesAPIServerOIDC) { + *out = *in + if in.SigningAlgs != nil { + in, out := &in.SigningAlgs, &out.SigningAlgs + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterKubernetesAPIServerOIDC. +func (in *ClusterKubernetesAPIServerOIDC) DeepCopy() *ClusterKubernetesAPIServerOIDC { + if in == nil { + return nil + } + out := new(ClusterKubernetesAPIServerOIDC) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterKubernetesClusterAutoscaler) DeepCopyInto(out *ClusterKubernetesClusterAutoscaler) { *out = *in + if in.Overprovisioning != nil { + in, out := &in.Overprovisioning, &out.Overprovisioning + if *in == nil { + *out = nil + } else { + *out = new(ClusterKubernetesClusterAutoscalerOverprovisioning) + **out = **in + } + } return } @@ -140,6 +285,22 @@ func (in *ClusterKubernetesClusterAutoscaler) DeepCopy() *ClusterKubernetesClust return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterKubernetesClusterAutoscalerOverprovisioning) DeepCopyInto(out *ClusterKubernetesClusterAutoscalerOverprovisioning) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterKubernetesClusterAutoscalerOverprovisioning. +func (in *ClusterKubernetesClusterAutoscalerOverprovisioning) DeepCopy() *ClusterKubernetesClusterAutoscalerOverprovisioning { + if in == nil { + return nil + } + out := new(ClusterKubernetesClusterAutoscalerOverprovisioning) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterKubernetesDashboard) DeepCopyInto(out *ClusterKubernetesDashboard) { *out = *in @@ -156,6 +317,22 @@ func (in *ClusterKubernetesDashboard) DeepCopy() *ClusterKubernetesDashboard { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterKubernetesPrometheus) DeepCopyInto(out *ClusterKubernetesPrometheus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterKubernetesPrometheus. +func (in *ClusterKubernetesPrometheus) DeepCopy() *ClusterKubernetesPrometheus { + if in == nil { + return nil + } + out := new(ClusterKubernetesPrometheus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterKubernetesTiller) DeepCopyInto(out *ClusterKubernetesTiller) { *out = *in @@ -206,6 +383,22 @@ func (in *ClusterList) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterPodSecurityPolicy) DeepCopyInto(out *ClusterPodSecurityPolicy) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPodSecurityPolicy. +func (in *ClusterPodSecurityPolicy) DeepCopy() *ClusterPodSecurityPolicy { + if in == nil { + return nil + } + out := new(ClusterPodSecurityPolicy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EgressRule) DeepCopyInto(out *EgressRule) { *out = *in @@ -265,6 +458,22 @@ func (in *Firewall) DeepCopy() *Firewall { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPBasicAuth) DeepCopyInto(out *HTTPBasicAuth) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPBasicAuth. +func (in *HTTPBasicAuth) DeepCopy() *HTTPBasicAuth { + if in == nil { + return nil + } + out := new(HTTPBasicAuth) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IngressRule) DeepCopyInto(out *IngressRule) { *out = *in @@ -332,6 +541,20 @@ func (in *InstancePool) DeepCopyInto(out *InstancePool) { **out = **in } } + if in.AllowCIDRs != nil { + in, out := &in.AllowCIDRs, &out.AllowCIDRs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Amazon != nil { + in, out := &in.Amazon, &out.Amazon + if *in == nil { + *out = nil + } else { + *out = new(InstancePoolAmazon) + (*in).DeepCopyInto(*out) + } + } return } @@ -354,6 +577,27 @@ func (in *InstancePool) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstancePoolAmazon) DeepCopyInto(out *InstancePoolAmazon) { + *out = *in + if in.AdditionalIAMPolicies != nil { + in, out := &in.AdditionalIAMPolicies, &out.AdditionalIAMPolicies + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstancePoolAmazon. +func (in *InstancePoolAmazon) DeepCopy() *InstancePoolAmazon { + if in == nil { + return nil + } + out := new(InstancePoolAmazon) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstancePoolKubernetes) DeepCopyInto(out *InstancePoolKubernetes) { *out = *in @@ -406,6 +650,70 @@ func (in *KubernetesAPI) DeepCopy() *KubernetesAPI { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoggingSink) DeepCopyInto(out *LoggingSink) { + *out = *in + if in.ElasticSearch != nil { + in, out := &in.ElasticSearch, &out.ElasticSearch + if *in == nil { + *out = nil + } else { + *out = new(LoggingSinkElasticSearch) + (*in).DeepCopyInto(*out) + } + } + if in.Types != nil { + in, out := &in.Types, &out.Types + *out = make([]LoggingSinkType, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingSink. +func (in *LoggingSink) DeepCopy() *LoggingSink { + if in == nil { + return nil + } + out := new(LoggingSink) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoggingSinkElasticSearch) DeepCopyInto(out *LoggingSinkElasticSearch) { + *out = *in + if in.HTTPBasicAuth != nil { + in, out := &in.HTTPBasicAuth, &out.HTTPBasicAuth + if *in == nil { + *out = nil + } else { + *out = new(HTTPBasicAuth) + **out = **in + } + } + if in.AmazonESProxy != nil { + in, out := &in.AmazonESProxy, &out.AmazonESProxy + if *in == nil { + *out = nil + } else { + *out = new(AmazonESProxy) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingSinkElasticSearch. +func (in *LoggingSinkElasticSearch) DeepCopy() *LoggingSinkElasticSearch { + if in == nil { + return nil + } + out := new(LoggingSinkElasticSearch) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Network) DeepCopyInto(out *Network) { *out = *in diff --git a/pkg/apis/tarmak/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/tarmak/v1alpha1/zz_generated.deepcopy.go index 692d691e79..7361206ec2 100644 --- a/pkg/apis/tarmak/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/tarmak/v1alpha1/zz_generated.deepcopy.go @@ -167,6 +167,11 @@ func (in *Environment) DeepCopyInto(out *Environment) { (*in).DeepCopyInto(*out) } } + if in.AdminCIDRs != nil { + in, out := &in.AdminCIDRs, &out.AdminCIDRs + *out = make([]string, len(*in)) + copy(*out, *in) + } return } diff --git a/pkg/apis/wing/clustercommon/consts.go b/pkg/apis/wing/clustercommon/consts.go new file mode 100644 index 0000000000..e458de5768 --- /dev/null +++ b/pkg/apis/wing/clustercommon/consts.go @@ -0,0 +1,131 @@ +/* +Copyright 2018 The Kubernetes 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 common + +// Constants aren't automatically generated for unversioned packages. +// Instead share the same constant for all versioned packages +type MachineStatusError string + +const ( + // Represents that the combination of configuration in the MachineSpec + // is not supported by this cluster. This is not a transient error, but + // indicates a state that must be fixed before progress can be made. + // + // Example: the ProviderConfig specifies an instance type that doesn't exist, + InvalidConfigurationMachineError MachineStatusError = "InvalidConfiguration" + + // This indicates that the MachineSpec has been updated in a way that + // is not supported for reconciliation on this cluster. The spec may be + // completely valid from a configuration standpoint, but the controller + // does not support changing the real world state to match the new + // spec. + // + // Example: the responsible controller is not capable of changing the + // container runtime from docker to rkt. + UnsupportedChangeMachineError MachineStatusError = "UnsupportedChange" + + // This generally refers to exceeding one's quota in a cloud provider, + // or running out of physical machines in an on-premise environment. + InsufficientResourcesMachineError MachineStatusError = "InsufficientResources" + + // There was an error while trying to create a Node to match this + // Machine. This may indicate a transient problem that will be fixed + // automatically with time, such as a service outage, or a terminal + // error during creation that doesn't match a more specific + // MachineStatusError value. + // + // Example: timeout trying to connect to GCE. + CreateMachineError MachineStatusError = "CreateError" + + // An error was encountered while trying to delete the Node that this + // Machine represents. This could be a transient or terminal error, but + // will only be observable if the provider's Machine controller has + // added a finalizer to the object to more gracefully handle deletions. + // + // Example: cannot resolve EC2 IP address. + DeleteMachineError MachineStatusError = "DeleteError" +) + +type ClusterStatusError string + +const ( + // InvalidConfigurationClusterError indicates that the cluster + // configuration is invalid. + InvalidConfigurationClusterError ClusterStatusError = "InvalidConfiguration" + + // UnsupportedChangeClusterError indicates that the cluster + // spec has been updated in an unsupported way. That cannot be + // reconciled. + UnsupportedChangeClusterError ClusterStatusError = "UnsupportedChange" + + // CreateClusterError indicates that an error was encountered + // when trying to create the cluster. + CreateClusterError ClusterStatusError = "CreateError" + + // UpdateClusterError indicates that an error was encountered + // when trying to update the cluster. + UpdateClusterError ClusterStatusError = "UpdateError" + + // DeleteClusterError indicates that an error was encountered + // when trying to delete the cluster. + DeleteClusterError ClusterStatusError = "DeleteError" +) + +// The MachineRole indicates the purpose of the Machine, and will determine +// what software and configuration will be used when provisioning and managing +// the Machine. A single Machine may have more than one role, and the list and +// definitions of supported roles is expected to evolve over time. +// +// Currently, only two roles are supported: Master and Node. In the future, we +// expect user needs to drive the evolution and granularity of these roles, +// with new additions accommodating common cluster patterns, like dedicated +// etcd Machines. +// +// +-----------------------+------------------------+ +// | Master present | Master absent | +// +---------------+-----------------------+------------------------| +// | Node present: | Install control plane | Join the cluster as | +// | | and be schedulable | just a node | +// |---------------+-----------------------+------------------------| +// | Node absent: | Install control plane | Invalid configuration | +// | | and be unscheduleable | | +// +---------------+-----------------------+------------------------+ +type MachineRole string + +const ( + MasterRole MachineRole = "Master" + NodeRole MachineRole = "Node" +) + +type MachineSetStatusError string + +const ( + // Represents that the combination of configuration in the MachineTemplateSpec + // is not supported by this cluster. This is not a transient error, but + // indicates a state that must be fixed before progress can be made. + // + // Example: the ProviderConfig specifies an instance type that doesn't exist. + InvalidConfigurationMachineSetError MachineSetStatusError = "InvalidConfiguration" +) + +type MachineDeploymentStrategyType string + +const ( + // Replace the old MachineSet by new one using rolling update + // i.e gradually scale down the old MachineSet and scale up the new one. + RollingUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "RollingUpdate" +) diff --git a/pkg/apis/wing/machine_types.go b/pkg/apis/wing/machine_types.go new file mode 100644 index 0000000000..702b7e9734 --- /dev/null +++ b/pkg/apis/wing/machine_types.go @@ -0,0 +1,163 @@ +/* +Copyright 2018 The Kubernetes 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 wing + +import ( + clustercommon "github.com/jetstack/tarmak/pkg/apis/wing/clustercommon" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// Finalizer is set on PreareForCreate callback +const MachineFinalizer string = "machine.cluster.k8s.io" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Machine +// +k8s:openapi-gen=true +// +resource:path=machines,strategy=MachineStrategy +type Machine struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec MachineSpec `json:"spec,omitempty"` + Status MachineStatus `json:"status,omitempty"` +} + +// MachineSpec defines the desired state of Machine +type MachineSpec struct { + // This ObjectMeta will autopopulate the Node created. Use this to + // indicate what labels, annotations, name prefix, etc., should be used + // when creating the Node. + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // The full, authoritative list of taints to apply to the corresponding + // Node. This list will overwrite any modifications made to the Node on + // an ongoing basis. + // +optional + Taints []corev1.Taint `json:"taints,omitempty"` + + // Provider-specific configuration to use during node creation. + // +optional + ProviderConfig ProviderConfig `json:"providerConfig"` + + // A list of roles for this Machine to use. + Roles []clustercommon.MachineRole `json:"roles,omitempty"` + + // Versions of key software to use. This field is optional at cluster + // creation time, and omitting the field indicates that the cluster + // installation tool should select defaults for the user. These + // defaults may differ based on the cluster installer, but the tool + // should populate the values it uses when persisting Machine objects. + // A Machine spec missing this field at runtime is invalid. + // +optional + Versions MachineVersionInfo `json:"versions,omitempty"` + + // To populate in the associated Node for dynamic kubelet config. This + // field already exists in Node, so any updates to it in the Machine + // spec will be automatially copied to the linked NodeRef from the + // status. The rest of dynamic kubelet config support should then work + // as-is. + // +optional + ConfigSource *corev1.NodeConfigSource `json:"configSource,omitempty"` +} + +// MachineStatus defines the observed state of Machine +type MachineStatus struct { + // If the corresponding Node exists, this will point to its object. + // +optional + NodeRef *corev1.ObjectReference `json:"nodeRef,omitempty"` + + // When was this status last observed + // +optional + LastUpdated metav1.Time `json:"lastUpdated,omitempty"` + + // The current versions of software on the corresponding Node (if it + // exists). This is provided for a few reasons: + // + // 1) It is more convenient than checking the NodeRef, traversing it to + // the Node, and finding the appropriate field in Node.Status.NodeInfo + // (which uses different field names and formatting). + // 2) It removes some of the dependency on the structure of the Node, + // so that if the structure of Node.Status.NodeInfo changes, only + // machine controllers need to be updated, rather than every client + // of the Machines API. + // 3) There is no other way simple way to check the ControlPlane + // version. A client would have to connect directly to the apiserver + // running on the target node in order to find out its version. + // +optional + Versions *MachineVersionInfo `json:"versions,omitempty"` + + // In the event that there is a terminal problem reconciling the + // Machine, both ErrorReason and ErrorMessage will be set. ErrorReason + // will be populated with a succinct value suitable for machine + // interpretation, while ErrorMessage will contain a more verbose + // string suitable for logging and human consumption. + // + // These fields should not be set for transitive errors that a + // controller faces that are expected to be fixed automatically over + // time (like service outages), but instead indicate that something is + // fundamentally wrong with the Machine's spec or the configuration of + // the controller, and that manual intervention is required. Examples + // of terminal errors would be invalid combinations of settings in the + // spec, values that are unsupported by the controller, or the + // responsible controller itself being critically misconfigured. + // + // Any transient errors that occur during the reconcilation of Machines + // can be added as events to the Machine object and/or logged in the + // controller's output. + // +optional + ErrorReason *clustercommon.MachineStatusError `json:"errorReason,omitempty"` + // +optional + ErrorMessage *string `json:"errorMessage,omitempty"` + + // Provider-specific status. + // It is recommended that providers maintain their + // own versioned API types that should be + // serialized/deserialized from this field. + ProviderStatus *runtime.RawExtension `json:"providerStatus"` + + // Addresses is a list of addresses assigned to the machine. Queried from cloud provider, if available. + // +optional + Addresses []corev1.NodeAddress `json:"addresses,omitempty"` + + // FIXME(kragniz): remove this field + Converged bool `json:"converged"` +} + +type MachineVersionInfo struct { + // Semantic version of kubelet to run + Kubelet string `json:"kubelet"` + + // Semantic version of the Kubernetes control plane to + // run. This should only be populated when the machine is a + // master. + // +optional + ControlPlane string `json:"controlPlane,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type MachineList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []Machine `json:"items"` +} diff --git a/pkg/apis/wing/provider_config.go b/pkg/apis/wing/provider_config.go new file mode 100644 index 0000000000..25f5b626b7 --- /dev/null +++ b/pkg/apis/wing/provider_config.go @@ -0,0 +1,43 @@ +/* +Copyright 2018 The Kubernetes 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 wing + +import runtime "k8s.io/apimachinery/pkg/runtime" + +// ProviderConfig defines the configuration to use during node creation. +type ProviderConfig struct { + + // No more than one of the following may be specified. + + // Value is an inlined, serialized representation of the resource + // configuration. It is recommended that providers maintain their own + // versioned API types that should be serialized/deserialized from this + // field, akin to component config. + // +optional + Value *runtime.RawExtension `json:"value,omitempty"` + + // Source for the provider configuration. Cannot be used if value is + // not empty. + // +optional + ValueFrom *ProviderConfigSource `json:valueFrom,omitempty` +} + +// ProviderConfigSource represents a source for the provider-specific +// resource configuration. +type ProviderConfigSource struct { + // TODO(roberthbailey): Fill these in later +} diff --git a/pkg/apis/wing/register.go b/pkg/apis/wing/register.go index 69ae3ba7c1..baad6d8c91 100644 --- a/pkg/apis/wing/register.go +++ b/pkg/apis/wing/register.go @@ -29,8 +29,8 @@ var ( // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &Instance{}, - &InstanceList{}, + &Machine{}, + &MachineList{}, &WingJob{}, &WingJobList{}, &PuppetTarget{}, diff --git a/pkg/apis/wing/v1alpha1/machine_types.go b/pkg/apis/wing/v1alpha1/machine_types.go new file mode 100644 index 0000000000..a28334fa4f --- /dev/null +++ b/pkg/apis/wing/v1alpha1/machine_types.go @@ -0,0 +1,163 @@ +/* +Copyright 2018 The Kubernetes 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 ( + clustercommon "github.com/jetstack/tarmak/pkg/apis/wing/clustercommon" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// Finalizer is set on PreareForCreate callback +const MachineFinalizer string = "machine.cluster.k8s.io" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Machine +// +k8s:openapi-gen=true +// +resource:path=machines,strategy=MachineStrategy +type Machine struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec MachineSpec `json:"spec,omitempty"` + Status MachineStatus `json:"status,omitempty"` +} + +// MachineSpec defines the desired state of Machine +type MachineSpec struct { + // This ObjectMeta will autopopulate the Node created. Use this to + // indicate what labels, annotations, name prefix, etc., should be used + // when creating the Node. + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // The full, authoritative list of taints to apply to the corresponding + // Node. This list will overwrite any modifications made to the Node on + // an ongoing basis. + // +optional + Taints []corev1.Taint `json:"taints,omitempty"` + + // Provider-specific configuration to use during node creation. + // +optional + ProviderConfig ProviderConfig `json:"providerConfig"` + + // A list of roles for this Machine to use. + Roles []clustercommon.MachineRole `json:"roles,omitempty"` + + // Versions of key software to use. This field is optional at cluster + // creation time, and omitting the field indicates that the cluster + // installation tool should select defaults for the user. These + // defaults may differ based on the cluster installer, but the tool + // should populate the values it uses when persisting Machine objects. + // A Machine spec missing this field at runtime is invalid. + // +optional + Versions MachineVersionInfo `json:"versions,omitempty"` + + // To populate in the associated Node for dynamic kubelet config. This + // field already exists in Node, so any updates to it in the Machine + // spec will be automatially copied to the linked NodeRef from the + // status. The rest of dynamic kubelet config support should then work + // as-is. + // +optional + ConfigSource *corev1.NodeConfigSource `json:"configSource,omitempty"` +} + +// MachineStatus defines the observed state of Machine +type MachineStatus struct { + // If the corresponding Node exists, this will point to its object. + // +optional + NodeRef *corev1.ObjectReference `json:"nodeRef,omitempty"` + + // When was this status last observed + // +optional + LastUpdated metav1.Time `json:"lastUpdated,omitempty"` + + // The current versions of software on the corresponding Node (if it + // exists). This is provided for a few reasons: + // + // 1) It is more convenient than checking the NodeRef, traversing it to + // the Node, and finding the appropriate field in Node.Status.NodeInfo + // (which uses different field names and formatting). + // 2) It removes some of the dependency on the structure of the Node, + // so that if the structure of Node.Status.NodeInfo changes, only + // machine controllers need to be updated, rather than every client + // of the Machines API. + // 3) There is no other way simple way to check the ControlPlane + // version. A client would have to connect directly to the apiserver + // running on the target node in order to find out its version. + // +optional + Versions *MachineVersionInfo `json:"versions,omitempty"` + + // In the event that there is a terminal problem reconciling the + // Machine, both ErrorReason and ErrorMessage will be set. ErrorReason + // will be populated with a succinct value suitable for machine + // interpretation, while ErrorMessage will contain a more verbose + // string suitable for logging and human consumption. + // + // These fields should not be set for transitive errors that a + // controller faces that are expected to be fixed automatically over + // time (like service outages), but instead indicate that something is + // fundamentally wrong with the Machine's spec or the configuration of + // the controller, and that manual intervention is required. Examples + // of terminal errors would be invalid combinations of settings in the + // spec, values that are unsupported by the controller, or the + // responsible controller itself being critically misconfigured. + // + // Any transient errors that occur during the reconcilation of Machines + // can be added as events to the Machine object and/or logged in the + // controller's output. + // +optional + ErrorReason *clustercommon.MachineStatusError `json:"errorReason,omitempty"` + // +optional + ErrorMessage *string `json:"errorMessage,omitempty"` + + // Provider-specific status. + // It is recommended that providers maintain their + // own versioned API types that should be + // serialized/deserialized from this field. + ProviderStatus *runtime.RawExtension `json:"providerStatus"` + + // Addresses is a list of addresses assigned to the machine. Queried from cloud provider, if available. + // +optional + Addresses []corev1.NodeAddress `json:"addresses,omitempty"` + + // FIXME(kragniz): remove this field + Converged bool `json:"converged"` +} + +type MachineVersionInfo struct { + // Semantic version of kubelet to run + Kubelet string `json:"kubelet"` + + // Semantic version of the Kubernetes control plane to + // run. This should only be populated when the machine is a + // master. + // +optional + ControlPlane string `json:"controlPlane,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type MachineList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []Machine `json:"items"` +} diff --git a/pkg/apis/wing/v1alpha1/provider_config.go b/pkg/apis/wing/v1alpha1/provider_config.go new file mode 100644 index 0000000000..0ed2658f05 --- /dev/null +++ b/pkg/apis/wing/v1alpha1/provider_config.go @@ -0,0 +1,43 @@ +/* +Copyright 2018 The Kubernetes 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 runtime "k8s.io/apimachinery/pkg/runtime" + +// ProviderConfig defines the configuration to use during node creation. +type ProviderConfig struct { + + // No more than one of the following may be specified. + + // Value is an inlined, serialized representation of the resource + // configuration. It is recommended that providers maintain their own + // versioned API types that should be serialized/deserialized from this + // field, akin to component config. + // +optional + Value *runtime.RawExtension `json:"value,omitempty"` + + // Source for the provider configuration. Cannot be used if value is + // not empty. + // +optional + ValueFrom *ProviderConfigSource `json:valueFrom,omitempty` +} + +// ProviderConfigSource represents a source for the provider-specific +// resource configuration. +type ProviderConfigSource struct { + // TODO(roberthbailey): Fill these in later +} diff --git a/pkg/apis/wing/v1alpha1/register.go b/pkg/apis/wing/v1alpha1/register.go index a39b0bf85d..497099c7cb 100644 --- a/pkg/apis/wing/v1alpha1/register.go +++ b/pkg/apis/wing/v1alpha1/register.go @@ -33,8 +33,8 @@ func init() { // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &Instance{}, - &InstanceList{}, + &Machine{}, + &MachineList{}, &WingJob{}, &WingJobList{}, &PuppetTarget{}, diff --git a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go index 2073160a79..bab69151f9 100644 --- a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go @@ -8,6 +8,8 @@ package v1alpha1 import ( wing "github.com/jetstack/tarmak/pkg/apis/wing" + clustercommon "github.com/jetstack/tarmak/pkg/apis/wing/clustercommon" + v1 "k8s.io/api/core/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" unsafe "unsafe" @@ -31,8 +33,22 @@ func RegisterConversions(scheme *runtime.Scheme) error { Convert_wing_InstanceSpec_To_v1alpha1_InstanceSpec, Convert_v1alpha1_InstanceStatus_To_wing_InstanceStatus, Convert_wing_InstanceStatus_To_v1alpha1_InstanceStatus, + Convert_v1alpha1_Machine_To_wing_Machine, + Convert_wing_Machine_To_v1alpha1_Machine, + Convert_v1alpha1_MachineList_To_wing_MachineList, + Convert_wing_MachineList_To_v1alpha1_MachineList, + Convert_v1alpha1_MachineSpec_To_wing_MachineSpec, + Convert_wing_MachineSpec_To_v1alpha1_MachineSpec, + Convert_v1alpha1_MachineStatus_To_wing_MachineStatus, + Convert_wing_MachineStatus_To_v1alpha1_MachineStatus, + Convert_v1alpha1_MachineVersionInfo_To_wing_MachineVersionInfo, + Convert_wing_MachineVersionInfo_To_v1alpha1_MachineVersionInfo, Convert_v1alpha1_ManifestSource_To_wing_ManifestSource, Convert_wing_ManifestSource_To_v1alpha1_ManifestSource, + Convert_v1alpha1_ProviderConfig_To_wing_ProviderConfig, + Convert_wing_ProviderConfig_To_v1alpha1_ProviderConfig, + Convert_v1alpha1_ProviderConfigSource_To_wing_ProviderConfigSource, + Convert_wing_ProviderConfigSource_To_v1alpha1_ProviderConfigSource, Convert_v1alpha1_PuppetTarget_To_wing_PuppetTarget, Convert_wing_PuppetTarget_To_v1alpha1_PuppetTarget, Convert_v1alpha1_PuppetTargetList_To_wing_PuppetTargetList, @@ -162,6 +178,152 @@ func Convert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in *wing.InstanceSta return autoConvert_wing_InstanceStatus_To_v1alpha1_InstanceStatus(in, out, s) } +func autoConvert_v1alpha1_Machine_To_wing_Machine(in *Machine, out *wing.Machine, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_MachineSpec_To_wing_MachineSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_MachineStatus_To_wing_MachineStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_Machine_To_wing_Machine is an autogenerated conversion function. +func Convert_v1alpha1_Machine_To_wing_Machine(in *Machine, out *wing.Machine, s conversion.Scope) error { + return autoConvert_v1alpha1_Machine_To_wing_Machine(in, out, s) +} + +func autoConvert_wing_Machine_To_v1alpha1_Machine(in *wing.Machine, out *Machine, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_wing_MachineSpec_To_v1alpha1_MachineSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_wing_MachineStatus_To_v1alpha1_MachineStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_wing_Machine_To_v1alpha1_Machine is an autogenerated conversion function. +func Convert_wing_Machine_To_v1alpha1_Machine(in *wing.Machine, out *Machine, s conversion.Scope) error { + return autoConvert_wing_Machine_To_v1alpha1_Machine(in, out, s) +} + +func autoConvert_v1alpha1_MachineList_To_wing_MachineList(in *MachineList, out *wing.MachineList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]wing.Machine)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_MachineList_To_wing_MachineList is an autogenerated conversion function. +func Convert_v1alpha1_MachineList_To_wing_MachineList(in *MachineList, out *wing.MachineList, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineList_To_wing_MachineList(in, out, s) +} + +func autoConvert_wing_MachineList_To_v1alpha1_MachineList(in *wing.MachineList, out *MachineList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]Machine)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_wing_MachineList_To_v1alpha1_MachineList is an autogenerated conversion function. +func Convert_wing_MachineList_To_v1alpha1_MachineList(in *wing.MachineList, out *MachineList, s conversion.Scope) error { + return autoConvert_wing_MachineList_To_v1alpha1_MachineList(in, out, s) +} + +func autoConvert_v1alpha1_MachineSpec_To_wing_MachineSpec(in *MachineSpec, out *wing.MachineSpec, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Taints = *(*[]v1.Taint)(unsafe.Pointer(&in.Taints)) + if err := Convert_v1alpha1_ProviderConfig_To_wing_ProviderConfig(&in.ProviderConfig, &out.ProviderConfig, s); err != nil { + return err + } + out.Roles = *(*[]clustercommon.MachineRole)(unsafe.Pointer(&in.Roles)) + if err := Convert_v1alpha1_MachineVersionInfo_To_wing_MachineVersionInfo(&in.Versions, &out.Versions, s); err != nil { + return err + } + out.ConfigSource = (*v1.NodeConfigSource)(unsafe.Pointer(in.ConfigSource)) + return nil +} + +// Convert_v1alpha1_MachineSpec_To_wing_MachineSpec is an autogenerated conversion function. +func Convert_v1alpha1_MachineSpec_To_wing_MachineSpec(in *MachineSpec, out *wing.MachineSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineSpec_To_wing_MachineSpec(in, out, s) +} + +func autoConvert_wing_MachineSpec_To_v1alpha1_MachineSpec(in *wing.MachineSpec, out *MachineSpec, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Taints = *(*[]v1.Taint)(unsafe.Pointer(&in.Taints)) + if err := Convert_wing_ProviderConfig_To_v1alpha1_ProviderConfig(&in.ProviderConfig, &out.ProviderConfig, s); err != nil { + return err + } + out.Roles = *(*[]clustercommon.MachineRole)(unsafe.Pointer(&in.Roles)) + if err := Convert_wing_MachineVersionInfo_To_v1alpha1_MachineVersionInfo(&in.Versions, &out.Versions, s); err != nil { + return err + } + out.ConfigSource = (*v1.NodeConfigSource)(unsafe.Pointer(in.ConfigSource)) + return nil +} + +// Convert_wing_MachineSpec_To_v1alpha1_MachineSpec is an autogenerated conversion function. +func Convert_wing_MachineSpec_To_v1alpha1_MachineSpec(in *wing.MachineSpec, out *MachineSpec, s conversion.Scope) error { + return autoConvert_wing_MachineSpec_To_v1alpha1_MachineSpec(in, out, s) +} + +func autoConvert_v1alpha1_MachineStatus_To_wing_MachineStatus(in *MachineStatus, out *wing.MachineStatus, s conversion.Scope) error { + out.NodeRef = (*v1.ObjectReference)(unsafe.Pointer(in.NodeRef)) + out.LastUpdated = in.LastUpdated + out.Versions = (*wing.MachineVersionInfo)(unsafe.Pointer(in.Versions)) + out.ErrorReason = (*clustercommon.MachineStatusError)(unsafe.Pointer(in.ErrorReason)) + out.ErrorMessage = (*string)(unsafe.Pointer(in.ErrorMessage)) + out.ProviderStatus = (*runtime.RawExtension)(unsafe.Pointer(in.ProviderStatus)) + out.Addresses = *(*[]v1.NodeAddress)(unsafe.Pointer(&in.Addresses)) + return nil +} + +// Convert_v1alpha1_MachineStatus_To_wing_MachineStatus is an autogenerated conversion function. +func Convert_v1alpha1_MachineStatus_To_wing_MachineStatus(in *MachineStatus, out *wing.MachineStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineStatus_To_wing_MachineStatus(in, out, s) +} + +func autoConvert_wing_MachineStatus_To_v1alpha1_MachineStatus(in *wing.MachineStatus, out *MachineStatus, s conversion.Scope) error { + out.NodeRef = (*v1.ObjectReference)(unsafe.Pointer(in.NodeRef)) + out.LastUpdated = in.LastUpdated + out.Versions = (*MachineVersionInfo)(unsafe.Pointer(in.Versions)) + out.ErrorReason = (*clustercommon.MachineStatusError)(unsafe.Pointer(in.ErrorReason)) + out.ErrorMessage = (*string)(unsafe.Pointer(in.ErrorMessage)) + out.ProviderStatus = (*runtime.RawExtension)(unsafe.Pointer(in.ProviderStatus)) + out.Addresses = *(*[]v1.NodeAddress)(unsafe.Pointer(&in.Addresses)) + return nil +} + +// Convert_wing_MachineStatus_To_v1alpha1_MachineStatus is an autogenerated conversion function. +func Convert_wing_MachineStatus_To_v1alpha1_MachineStatus(in *wing.MachineStatus, out *MachineStatus, s conversion.Scope) error { + return autoConvert_wing_MachineStatus_To_v1alpha1_MachineStatus(in, out, s) +} + +func autoConvert_v1alpha1_MachineVersionInfo_To_wing_MachineVersionInfo(in *MachineVersionInfo, out *wing.MachineVersionInfo, s conversion.Scope) error { + out.Kubelet = in.Kubelet + out.ControlPlane = in.ControlPlane + return nil +} + +// Convert_v1alpha1_MachineVersionInfo_To_wing_MachineVersionInfo is an autogenerated conversion function. +func Convert_v1alpha1_MachineVersionInfo_To_wing_MachineVersionInfo(in *MachineVersionInfo, out *wing.MachineVersionInfo, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineVersionInfo_To_wing_MachineVersionInfo(in, out, s) +} + +func autoConvert_wing_MachineVersionInfo_To_v1alpha1_MachineVersionInfo(in *wing.MachineVersionInfo, out *MachineVersionInfo, s conversion.Scope) error { + out.Kubelet = in.Kubelet + out.ControlPlane = in.ControlPlane + return nil +} + +// Convert_wing_MachineVersionInfo_To_v1alpha1_MachineVersionInfo is an autogenerated conversion function. +func Convert_wing_MachineVersionInfo_To_v1alpha1_MachineVersionInfo(in *wing.MachineVersionInfo, out *MachineVersionInfo, s conversion.Scope) error { + return autoConvert_wing_MachineVersionInfo_To_v1alpha1_MachineVersionInfo(in, out, s) +} + func autoConvert_v1alpha1_ManifestSource_To_wing_ManifestSource(in *ManifestSource, out *wing.ManifestSource, s conversion.Scope) error { out.S3 = (*wing.S3ManifestSource)(unsafe.Pointer(in.S3)) out.File = (*wing.FileManifestSource)(unsafe.Pointer(in.File)) @@ -184,6 +346,46 @@ func Convert_wing_ManifestSource_To_v1alpha1_ManifestSource(in *wing.ManifestSou return autoConvert_wing_ManifestSource_To_v1alpha1_ManifestSource(in, out, s) } +func autoConvert_v1alpha1_ProviderConfig_To_wing_ProviderConfig(in *ProviderConfig, out *wing.ProviderConfig, s conversion.Scope) error { + out.Value = (*runtime.RawExtension)(unsafe.Pointer(in.Value)) + out.ValueFrom = (*wing.ProviderConfigSource)(unsafe.Pointer(in.ValueFrom)) + return nil +} + +// Convert_v1alpha1_ProviderConfig_To_wing_ProviderConfig is an autogenerated conversion function. +func Convert_v1alpha1_ProviderConfig_To_wing_ProviderConfig(in *ProviderConfig, out *wing.ProviderConfig, s conversion.Scope) error { + return autoConvert_v1alpha1_ProviderConfig_To_wing_ProviderConfig(in, out, s) +} + +func autoConvert_wing_ProviderConfig_To_v1alpha1_ProviderConfig(in *wing.ProviderConfig, out *ProviderConfig, s conversion.Scope) error { + out.Value = (*runtime.RawExtension)(unsafe.Pointer(in.Value)) + out.ValueFrom = (*ProviderConfigSource)(unsafe.Pointer(in.ValueFrom)) + return nil +} + +// Convert_wing_ProviderConfig_To_v1alpha1_ProviderConfig is an autogenerated conversion function. +func Convert_wing_ProviderConfig_To_v1alpha1_ProviderConfig(in *wing.ProviderConfig, out *ProviderConfig, s conversion.Scope) error { + return autoConvert_wing_ProviderConfig_To_v1alpha1_ProviderConfig(in, out, s) +} + +func autoConvert_v1alpha1_ProviderConfigSource_To_wing_ProviderConfigSource(in *ProviderConfigSource, out *wing.ProviderConfigSource, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_ProviderConfigSource_To_wing_ProviderConfigSource is an autogenerated conversion function. +func Convert_v1alpha1_ProviderConfigSource_To_wing_ProviderConfigSource(in *ProviderConfigSource, out *wing.ProviderConfigSource, s conversion.Scope) error { + return autoConvert_v1alpha1_ProviderConfigSource_To_wing_ProviderConfigSource(in, out, s) +} + +func autoConvert_wing_ProviderConfigSource_To_v1alpha1_ProviderConfigSource(in *wing.ProviderConfigSource, out *ProviderConfigSource, s conversion.Scope) error { + return nil +} + +// Convert_wing_ProviderConfigSource_To_v1alpha1_ProviderConfigSource is an autogenerated conversion function. +func Convert_wing_ProviderConfigSource_To_v1alpha1_ProviderConfigSource(in *wing.ProviderConfigSource, out *ProviderConfigSource, s conversion.Scope) error { + return autoConvert_wing_ProviderConfigSource_To_v1alpha1_ProviderConfigSource(in, out, s) +} + func autoConvert_v1alpha1_PuppetTarget_To_wing_PuppetTarget(in *PuppetTarget, out *wing.PuppetTarget, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha1_ManifestSource_To_wing_ManifestSource(&in.Source, &out.Source, s); err != nil { diff --git a/pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go index a01fb636b2..3e11c20081 100644 --- a/pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go @@ -7,6 +7,8 @@ package v1alpha1 import ( + clustercommon "github.com/jetstack/tarmak/pkg/apis/wing/clustercommon" + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -137,6 +139,192 @@ func (in *InstanceStatus) DeepCopy() *InstanceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Machine) DeepCopyInto(out *Machine) { + *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 Machine. +func (in *Machine) DeepCopy() *Machine { + if in == nil { + return nil + } + out := new(Machine) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Machine) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineList) DeepCopyInto(out *MachineList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Machine, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineList. +func (in *MachineList) DeepCopy() *MachineList { + if in == nil { + return nil + } + out := new(MachineList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MachineList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineSpec) DeepCopyInto(out *MachineSpec) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Taints != nil { + in, out := &in.Taints, &out.Taints + *out = make([]v1.Taint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.ProviderConfig.DeepCopyInto(&out.ProviderConfig) + if in.Roles != nil { + in, out := &in.Roles, &out.Roles + *out = make([]clustercommon.MachineRole, len(*in)) + copy(*out, *in) + } + out.Versions = in.Versions + if in.ConfigSource != nil { + in, out := &in.ConfigSource, &out.ConfigSource + if *in == nil { + *out = nil + } else { + *out = new(v1.NodeConfigSource) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineSpec. +func (in *MachineSpec) DeepCopy() *MachineSpec { + if in == nil { + return nil + } + out := new(MachineSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineStatus) DeepCopyInto(out *MachineStatus) { + *out = *in + if in.NodeRef != nil { + in, out := &in.NodeRef, &out.NodeRef + if *in == nil { + *out = nil + } else { + *out = new(v1.ObjectReference) + **out = **in + } + } + in.LastUpdated.DeepCopyInto(&out.LastUpdated) + if in.Versions != nil { + in, out := &in.Versions, &out.Versions + if *in == nil { + *out = nil + } else { + *out = new(MachineVersionInfo) + **out = **in + } + } + if in.ErrorReason != nil { + in, out := &in.ErrorReason, &out.ErrorReason + if *in == nil { + *out = nil + } else { + *out = new(clustercommon.MachineStatusError) + **out = **in + } + } + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + if *in == nil { + *out = nil + } else { + *out = new(string) + **out = **in + } + } + if in.ProviderStatus != nil { + in, out := &in.ProviderStatus, &out.ProviderStatus + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.Addresses != nil { + in, out := &in.Addresses, &out.Addresses + *out = make([]v1.NodeAddress, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineStatus. +func (in *MachineStatus) DeepCopy() *MachineStatus { + if in == nil { + return nil + } + out := new(MachineStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineVersionInfo) DeepCopyInto(out *MachineVersionInfo) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineVersionInfo. +func (in *MachineVersionInfo) DeepCopy() *MachineVersionInfo { + if in == nil { + return nil + } + out := new(MachineVersionInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ManifestSource) DeepCopyInto(out *ManifestSource) { *out = *in @@ -171,6 +359,56 @@ func (in *ManifestSource) DeepCopy() *ManifestSource { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProviderConfig) DeepCopyInto(out *ProviderConfig) { + *out = *in + if in.Value != nil { + in, out := &in.Value, &out.Value + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.ValueFrom != nil { + in, out := &in.ValueFrom, &out.ValueFrom + if *in == nil { + *out = nil + } else { + *out = new(ProviderConfigSource) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderConfig. +func (in *ProviderConfig) DeepCopy() *ProviderConfig { + if in == nil { + return nil + } + out := new(ProviderConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProviderConfigSource) DeepCopyInto(out *ProviderConfigSource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderConfigSource. +func (in *ProviderConfigSource) DeepCopy() *ProviderConfigSource { + if in == nil { + return nil + } + out := new(ProviderConfigSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PuppetTarget) DeepCopyInto(out *PuppetTarget) { *out = *in diff --git a/pkg/apis/wing/zz_generated.deepcopy.go b/pkg/apis/wing/zz_generated.deepcopy.go index 2003d3fd20..c8c4c7391f 100644 --- a/pkg/apis/wing/zz_generated.deepcopy.go +++ b/pkg/apis/wing/zz_generated.deepcopy.go @@ -7,6 +7,8 @@ package wing import ( + clustercommon "github.com/jetstack/tarmak/pkg/apis/wing/clustercommon" + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -137,6 +139,192 @@ func (in *InstanceStatus) DeepCopy() *InstanceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Machine) DeepCopyInto(out *Machine) { + *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 Machine. +func (in *Machine) DeepCopy() *Machine { + if in == nil { + return nil + } + out := new(Machine) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Machine) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineList) DeepCopyInto(out *MachineList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Machine, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineList. +func (in *MachineList) DeepCopy() *MachineList { + if in == nil { + return nil + } + out := new(MachineList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MachineList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineSpec) DeepCopyInto(out *MachineSpec) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Taints != nil { + in, out := &in.Taints, &out.Taints + *out = make([]v1.Taint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.ProviderConfig.DeepCopyInto(&out.ProviderConfig) + if in.Roles != nil { + in, out := &in.Roles, &out.Roles + *out = make([]clustercommon.MachineRole, len(*in)) + copy(*out, *in) + } + out.Versions = in.Versions + if in.ConfigSource != nil { + in, out := &in.ConfigSource, &out.ConfigSource + if *in == nil { + *out = nil + } else { + *out = new(v1.NodeConfigSource) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineSpec. +func (in *MachineSpec) DeepCopy() *MachineSpec { + if in == nil { + return nil + } + out := new(MachineSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineStatus) DeepCopyInto(out *MachineStatus) { + *out = *in + if in.NodeRef != nil { + in, out := &in.NodeRef, &out.NodeRef + if *in == nil { + *out = nil + } else { + *out = new(v1.ObjectReference) + **out = **in + } + } + in.LastUpdated.DeepCopyInto(&out.LastUpdated) + if in.Versions != nil { + in, out := &in.Versions, &out.Versions + if *in == nil { + *out = nil + } else { + *out = new(MachineVersionInfo) + **out = **in + } + } + if in.ErrorReason != nil { + in, out := &in.ErrorReason, &out.ErrorReason + if *in == nil { + *out = nil + } else { + *out = new(clustercommon.MachineStatusError) + **out = **in + } + } + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + if *in == nil { + *out = nil + } else { + *out = new(string) + **out = **in + } + } + if in.ProviderStatus != nil { + in, out := &in.ProviderStatus, &out.ProviderStatus + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.Addresses != nil { + in, out := &in.Addresses, &out.Addresses + *out = make([]v1.NodeAddress, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineStatus. +func (in *MachineStatus) DeepCopy() *MachineStatus { + if in == nil { + return nil + } + out := new(MachineStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineVersionInfo) DeepCopyInto(out *MachineVersionInfo) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineVersionInfo. +func (in *MachineVersionInfo) DeepCopy() *MachineVersionInfo { + if in == nil { + return nil + } + out := new(MachineVersionInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ManifestSource) DeepCopyInto(out *ManifestSource) { *out = *in @@ -171,6 +359,56 @@ func (in *ManifestSource) DeepCopy() *ManifestSource { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProviderConfig) DeepCopyInto(out *ProviderConfig) { + *out = *in + if in.Value != nil { + in, out := &in.Value, &out.Value + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.ValueFrom != nil { + in, out := &in.ValueFrom, &out.ValueFrom + if *in == nil { + *out = nil + } else { + *out = new(ProviderConfigSource) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderConfig. +func (in *ProviderConfig) DeepCopy() *ProviderConfig { + if in == nil { + return nil + } + out := new(ProviderConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProviderConfigSource) DeepCopyInto(out *ProviderConfigSource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderConfigSource. +func (in *ProviderConfigSource) DeepCopy() *ProviderConfigSource { + if in == nil { + return nil + } + out := new(ProviderConfigSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PuppetTarget) DeepCopyInto(out *PuppetTarget) { *out = *in diff --git a/pkg/wing/apiserver/apiserver.go b/pkg/wing/apiserver/apiserver.go index 9aaeb2f014..d48b08cd51 100644 --- a/pkg/wing/apiserver/apiserver.go +++ b/pkg/wing/apiserver/apiserver.go @@ -17,7 +17,7 @@ import ( "github.com/jetstack/tarmak/pkg/apis/wing/install" "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" wingregistry "github.com/jetstack/tarmak/pkg/wing/registry" - instancestorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/instance" + machinestorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/machine" puppettargetstorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/puppettarget" wingjobstorage "github.com/jetstack/tarmak/pkg/wing/registry/wing/wingjob" ) @@ -93,7 +93,7 @@ func (c completedConfig) New() (*WingServer, error) { apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(wing.GroupName, registry, Scheme, metav1.ParameterCodec, Codecs) apiGroupInfo.GroupMeta.GroupVersion = v1alpha1.SchemeGroupVersion v1alpha1storage := map[string]rest.Storage{} - v1alpha1storage["instances"] = wingregistry.RESTInPeace(instancestorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) + v1alpha1storage["machines"] = wingregistry.RESTInPeace(machinestorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) v1alpha1storage["wingjobs"] = wingregistry.RESTInPeace(wingjobstorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) v1alpha1storage["puppettargets"] = wingregistry.RESTInPeace(puppettargetstorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage diff --git a/pkg/wing/client/typed/wing/v1alpha1/fake/fake_machine.go b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_machine.go new file mode 100644 index 0000000000..8fcdc10a40 --- /dev/null +++ b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_machine.go @@ -0,0 +1,123 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package fake + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/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" +) + +// FakeMachines implements MachineInterface +type FakeMachines struct { + Fake *FakeWingV1alpha1 + ns string +} + +var machinesResource = schema.GroupVersionResource{Group: "wing.tarmak.io", Version: "v1alpha1", Resource: "machines"} + +var machinesKind = schema.GroupVersionKind{Group: "wing.tarmak.io", Version: "v1alpha1", Kind: "Machine"} + +// Get takes name of the machine, and returns the corresponding machine object, and an error if there is any. +func (c *FakeMachines) Get(name string, options v1.GetOptions) (result *v1alpha1.Machine, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(machinesResource, c.ns, name), &v1alpha1.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Machine), err +} + +// List takes label and field selectors, and returns the list of Machines that match those selectors. +func (c *FakeMachines) List(opts v1.ListOptions) (result *v1alpha1.MachineList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(machinesResource, machinesKind, c.ns, opts), &v1alpha1.MachineList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.MachineList{} + for _, item := range obj.(*v1alpha1.MachineList).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 machines. +func (c *FakeMachines) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(machinesResource, c.ns, opts)) + +} + +// Create takes the representation of a machine and creates it. Returns the server's representation of the machine, and an error, if there is any. +func (c *FakeMachines) Create(machine *v1alpha1.Machine) (result *v1alpha1.Machine, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(machinesResource, c.ns, machine), &v1alpha1.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Machine), err +} + +// Update takes the representation of a machine and updates it. Returns the server's representation of the machine, and an error, if there is any. +func (c *FakeMachines) Update(machine *v1alpha1.Machine) (result *v1alpha1.Machine, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(machinesResource, c.ns, machine), &v1alpha1.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Machine), 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 *FakeMachines) UpdateStatus(machine *v1alpha1.Machine) (*v1alpha1.Machine, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(machinesResource, "status", c.ns, machine), &v1alpha1.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Machine), err +} + +// Delete takes name of the machine and deletes it. Returns an error if one occurs. +func (c *FakeMachines) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(machinesResource, c.ns, name), &v1alpha1.Machine{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMachines) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(machinesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.MachineList{}) + return err +} + +// Patch applies the patch and returns the patched machine. +func (c *FakeMachines) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Machine, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(machinesResource, c.ns, name, data, subresources...), &v1alpha1.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Machine), err +} diff --git a/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wing_client.go b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wing_client.go index 46d5b7ee24..862f58162c 100644 --- a/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wing_client.go +++ b/pkg/wing/client/typed/wing/v1alpha1/fake/fake_wing_client.go @@ -15,6 +15,10 @@ func (c *FakeWingV1alpha1) Instances(namespace string) v1alpha1.InstanceInterfac return &FakeInstances{c, namespace} } +func (c *FakeWingV1alpha1) Machines(namespace string) v1alpha1.MachineInterface { + return &FakeMachines{c, namespace} +} + func (c *FakeWingV1alpha1) PuppetTargets(namespace string) v1alpha1.PuppetTargetInterface { return &FakePuppetTargets{c, namespace} } diff --git a/pkg/wing/client/typed/wing/v1alpha1/generated_expansion.go b/pkg/wing/client/typed/wing/v1alpha1/generated_expansion.go index e928046b23..9e51e58d37 100644 --- a/pkg/wing/client/typed/wing/v1alpha1/generated_expansion.go +++ b/pkg/wing/client/typed/wing/v1alpha1/generated_expansion.go @@ -3,6 +3,8 @@ package v1alpha1 type InstanceExpansion interface{} +type MachineExpansion interface{} + type PuppetTargetExpansion interface{} type WingJobExpansion interface{} diff --git a/pkg/wing/client/typed/wing/v1alpha1/machine.go b/pkg/wing/client/typed/wing/v1alpha1/machine.go new file mode 100644 index 0000000000..d3cd176a20 --- /dev/null +++ b/pkg/wing/client/typed/wing/v1alpha1/machine.go @@ -0,0 +1,157 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package v1alpha1 + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + scheme "github.com/jetstack/tarmak/pkg/wing/client/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" +) + +// MachinesGetter has a method to return a MachineInterface. +// A group's client should implement this interface. +type MachinesGetter interface { + Machines(namespace string) MachineInterface +} + +// MachineInterface has methods to work with Machine resources. +type MachineInterface interface { + Create(*v1alpha1.Machine) (*v1alpha1.Machine, error) + Update(*v1alpha1.Machine) (*v1alpha1.Machine, error) + UpdateStatus(*v1alpha1.Machine) (*v1alpha1.Machine, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Machine, error) + List(opts v1.ListOptions) (*v1alpha1.MachineList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Machine, err error) + MachineExpansion +} + +// machines implements MachineInterface +type machines struct { + client rest.Interface + ns string +} + +// newMachines returns a Machines +func newMachines(c *WingV1alpha1Client, namespace string) *machines { + return &machines{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the machine, and returns the corresponding machine object, and an error if there is any. +func (c *machines) Get(name string, options v1.GetOptions) (result *v1alpha1.Machine, err error) { + result = &v1alpha1.Machine{} + err = c.client.Get(). + Namespace(c.ns). + Resource("machines"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Machines that match those selectors. +func (c *machines) List(opts v1.ListOptions) (result *v1alpha1.MachineList, err error) { + result = &v1alpha1.MachineList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("machines"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested machines. +func (c *machines) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("machines"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a machine and creates it. Returns the server's representation of the machine, and an error, if there is any. +func (c *machines) Create(machine *v1alpha1.Machine) (result *v1alpha1.Machine, err error) { + result = &v1alpha1.Machine{} + err = c.client.Post(). + Namespace(c.ns). + Resource("machines"). + Body(machine). + Do(). + Into(result) + return +} + +// Update takes the representation of a machine and updates it. Returns the server's representation of the machine, and an error, if there is any. +func (c *machines) Update(machine *v1alpha1.Machine) (result *v1alpha1.Machine, err error) { + result = &v1alpha1.Machine{} + err = c.client.Put(). + Namespace(c.ns). + Resource("machines"). + Name(machine.Name). + Body(machine). + 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 *machines) UpdateStatus(machine *v1alpha1.Machine) (result *v1alpha1.Machine, err error) { + result = &v1alpha1.Machine{} + err = c.client.Put(). + Namespace(c.ns). + Resource("machines"). + Name(machine.Name). + SubResource("status"). + Body(machine). + Do(). + Into(result) + return +} + +// Delete takes name of the machine and deletes it. Returns an error if one occurs. +func (c *machines) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("machines"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *machines) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("machines"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched machine. +func (c *machines) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Machine, err error) { + result = &v1alpha1.Machine{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("machines"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/wing/client/typed/wing/v1alpha1/wing_client.go b/pkg/wing/client/typed/wing/v1alpha1/wing_client.go index 4bb319c657..a2b055c7ca 100644 --- a/pkg/wing/client/typed/wing/v1alpha1/wing_client.go +++ b/pkg/wing/client/typed/wing/v1alpha1/wing_client.go @@ -11,6 +11,7 @@ import ( type WingV1alpha1Interface interface { RESTClient() rest.Interface InstancesGetter + MachinesGetter PuppetTargetsGetter WingJobsGetter } @@ -24,6 +25,10 @@ func (c *WingV1alpha1Client) Instances(namespace string) InstanceInterface { return newInstances(c, namespace) } +func (c *WingV1alpha1Client) Machines(namespace string) MachineInterface { + return newMachines(c, namespace) +} + func (c *WingV1alpha1Client) PuppetTargets(namespace string) PuppetTargetInterface { return newPuppetTargets(c, namespace) } diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_machine.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_machine.go new file mode 100644 index 0000000000..81a29e7396 --- /dev/null +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_machine.go @@ -0,0 +1,123 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package fake + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + 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" +) + +// FakeMachines implements MachineInterface +type FakeMachines struct { + Fake *FakeWing + ns string +} + +var machinesResource = schema.GroupVersionResource{Group: "wing.tarmak.io", Version: "", Resource: "machines"} + +var machinesKind = schema.GroupVersionKind{Group: "wing.tarmak.io", Version: "", Kind: "Machine"} + +// Get takes name of the machine, and returns the corresponding machine object, and an error if there is any. +func (c *FakeMachines) Get(name string, options v1.GetOptions) (result *wing.Machine, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(machinesResource, c.ns, name), &wing.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.Machine), err +} + +// List takes label and field selectors, and returns the list of Machines that match those selectors. +func (c *FakeMachines) List(opts v1.ListOptions) (result *wing.MachineList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(machinesResource, machinesKind, c.ns, opts), &wing.MachineList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &wing.MachineList{} + for _, item := range obj.(*wing.MachineList).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 machines. +func (c *FakeMachines) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(machinesResource, c.ns, opts)) + +} + +// Create takes the representation of a machine and creates it. Returns the server's representation of the machine, and an error, if there is any. +func (c *FakeMachines) Create(machine *wing.Machine) (result *wing.Machine, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(machinesResource, c.ns, machine), &wing.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.Machine), err +} + +// Update takes the representation of a machine and updates it. Returns the server's representation of the machine, and an error, if there is any. +func (c *FakeMachines) Update(machine *wing.Machine) (result *wing.Machine, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(machinesResource, c.ns, machine), &wing.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.Machine), 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 *FakeMachines) UpdateStatus(machine *wing.Machine) (*wing.Machine, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(machinesResource, "status", c.ns, machine), &wing.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.Machine), err +} + +// Delete takes name of the machine and deletes it. Returns an error if one occurs. +func (c *FakeMachines) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(machinesResource, c.ns, name), &wing.Machine{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMachines) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(machinesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &wing.MachineList{}) + return err +} + +// Patch applies the patch and returns the patched machine. +func (c *FakeMachines) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.Machine, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(machinesResource, c.ns, name, data, subresources...), &wing.Machine{}) + + if obj == nil { + return nil, err + } + return obj.(*wing.Machine), err +} diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wing_client.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wing_client.go index 7680d27f60..967e7c3b7d 100644 --- a/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wing_client.go +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/fake/fake_wing_client.go @@ -15,6 +15,10 @@ func (c *FakeWing) Instances(namespace string) internalversion.InstanceInterface return &FakeInstances{c, namespace} } +func (c *FakeWing) Machines(namespace string) internalversion.MachineInterface { + return &FakeMachines{c, namespace} +} + func (c *FakeWing) PuppetTargets(namespace string) internalversion.PuppetTargetInterface { return &FakePuppetTargets{c, namespace} } diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/generated_expansion.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/generated_expansion.go index 8684f6f1ce..3f2ca777c8 100644 --- a/pkg/wing/clients/internalclientset/typed/wing/internalversion/generated_expansion.go +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/generated_expansion.go @@ -3,6 +3,8 @@ package internalversion type InstanceExpansion interface{} +type MachineExpansion interface{} + type PuppetTargetExpansion interface{} type WingJobExpansion interface{} diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/machine.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/machine.go new file mode 100644 index 0000000000..8ad11999f7 --- /dev/null +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/machine.go @@ -0,0 +1,157 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + scheme "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset/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" +) + +// MachinesGetter has a method to return a MachineInterface. +// A group's client should implement this interface. +type MachinesGetter interface { + Machines(namespace string) MachineInterface +} + +// MachineInterface has methods to work with Machine resources. +type MachineInterface interface { + Create(*wing.Machine) (*wing.Machine, error) + Update(*wing.Machine) (*wing.Machine, error) + UpdateStatus(*wing.Machine) (*wing.Machine, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*wing.Machine, error) + List(opts v1.ListOptions) (*wing.MachineList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.Machine, err error) + MachineExpansion +} + +// machines implements MachineInterface +type machines struct { + client rest.Interface + ns string +} + +// newMachines returns a Machines +func newMachines(c *WingClient, namespace string) *machines { + return &machines{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the machine, and returns the corresponding machine object, and an error if there is any. +func (c *machines) Get(name string, options v1.GetOptions) (result *wing.Machine, err error) { + result = &wing.Machine{} + err = c.client.Get(). + Namespace(c.ns). + Resource("machines"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Machines that match those selectors. +func (c *machines) List(opts v1.ListOptions) (result *wing.MachineList, err error) { + result = &wing.MachineList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("machines"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested machines. +func (c *machines) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("machines"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a machine and creates it. Returns the server's representation of the machine, and an error, if there is any. +func (c *machines) Create(machine *wing.Machine) (result *wing.Machine, err error) { + result = &wing.Machine{} + err = c.client.Post(). + Namespace(c.ns). + Resource("machines"). + Body(machine). + Do(). + Into(result) + return +} + +// Update takes the representation of a machine and updates it. Returns the server's representation of the machine, and an error, if there is any. +func (c *machines) Update(machine *wing.Machine) (result *wing.Machine, err error) { + result = &wing.Machine{} + err = c.client.Put(). + Namespace(c.ns). + Resource("machines"). + Name(machine.Name). + Body(machine). + 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 *machines) UpdateStatus(machine *wing.Machine) (result *wing.Machine, err error) { + result = &wing.Machine{} + err = c.client.Put(). + Namespace(c.ns). + Resource("machines"). + Name(machine.Name). + SubResource("status"). + Body(machine). + Do(). + Into(result) + return +} + +// Delete takes name of the machine and deletes it. Returns an error if one occurs. +func (c *machines) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("machines"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *machines) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("machines"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched machine. +func (c *machines) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *wing.Machine, err error) { + result = &wing.Machine{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("machines"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/wing/clients/internalclientset/typed/wing/internalversion/wing_client.go b/pkg/wing/clients/internalclientset/typed/wing/internalversion/wing_client.go index 0cb4e4fd4c..d60b533d70 100644 --- a/pkg/wing/clients/internalclientset/typed/wing/internalversion/wing_client.go +++ b/pkg/wing/clients/internalclientset/typed/wing/internalversion/wing_client.go @@ -9,6 +9,7 @@ import ( type WingInterface interface { RESTClient() rest.Interface InstancesGetter + MachinesGetter PuppetTargetsGetter WingJobsGetter } @@ -22,6 +23,10 @@ func (c *WingClient) Instances(namespace string) InstanceInterface { return newInstances(c, namespace) } +func (c *WingClient) Machines(namespace string) MachineInterface { + return newMachines(c, namespace) +} + func (c *WingClient) PuppetTargets(namespace string) PuppetTargetInterface { return newPuppetTargets(c, namespace) } diff --git a/pkg/wing/informers/externalversions/apis/interface.go b/pkg/wing/informers/externalversions/apis/interface.go new file mode 100644 index 0000000000..3e4527d89a --- /dev/null +++ b/pkg/wing/informers/externalversions/apis/interface.go @@ -0,0 +1,32 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by informer-gen + +package wing + +import ( + wing "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/apis/wing" + internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // Wing provides access to shared informers for resources in Wing. + Wing() wing.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Wing returns a new wing.Interface. +func (g *group) Wing() wing.Interface { + return wing.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/wing/informers/externalversions/factory.go b/pkg/wing/informers/externalversions/factory.go index 8a18235eca..73e99683bc 100644 --- a/pkg/wing/informers/externalversions/factory.go +++ b/pkg/wing/informers/externalversions/factory.go @@ -6,6 +6,7 @@ package externalversions import ( client "github.com/jetstack/tarmak/pkg/wing/client" + apis "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/apis" internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/internalinterfaces" wing "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/wing" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -108,9 +109,14 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + Wing() apis.Interface Wing() wing.Interface } +func (f *sharedInformerFactory) Wing() apis.Interface { + return apis.New(f, f.namespace, f.tweakListOptions) +} + func (f *sharedInformerFactory) Wing() wing.Interface { return wing.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/wing/informers/externalversions/generic.go b/pkg/wing/informers/externalversions/generic.go index 78b15575b0..95fb53ea2a 100644 --- a/pkg/wing/informers/externalversions/generic.go +++ b/pkg/wing/informers/externalversions/generic.go @@ -6,6 +6,7 @@ package externalversions import ( "fmt" + wing "github.com/jetstack/tarmak/pkg/apis/wing" v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" @@ -37,9 +38,21 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=wing.tarmak.io, Version=v1alpha1 + // Group=wing.tarmak.io, Version=wing + case wing.SchemeGroupVersion.WithResource("instances"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().Wing().Instances().Informer()}, nil + case wing.SchemeGroupVersion.WithResource("machines"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().Wing().Machines().Informer()}, nil + case wing.SchemeGroupVersion.WithResource("puppettargets"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().Wing().PuppetTargets().Informer()}, nil + case wing.SchemeGroupVersion.WithResource("wingjobs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().Wing().WingJobs().Informer()}, nil + + // Group=wing.tarmak.io, Version=v1alpha1 case v1alpha1.SchemeGroupVersion.WithResource("instances"): return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().V1alpha1().Instances().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("machines"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().V1alpha1().Machines().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("puppettargets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().V1alpha1().PuppetTargets().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("wingjobs"): diff --git a/pkg/wing/informers/externalversions/wing/v1alpha1/interface.go b/pkg/wing/informers/externalversions/wing/v1alpha1/interface.go index 57bdac5c1c..48d6863b73 100644 --- a/pkg/wing/informers/externalversions/wing/v1alpha1/interface.go +++ b/pkg/wing/informers/externalversions/wing/v1alpha1/interface.go @@ -12,6 +12,8 @@ import ( type Interface interface { // Instances returns a InstanceInformer. Instances() InstanceInformer + // Machines returns a MachineInformer. + Machines() MachineInformer // PuppetTargets returns a PuppetTargetInformer. PuppetTargets() PuppetTargetInformer // WingJobs returns a WingJobInformer. @@ -34,6 +36,11 @@ func (v *version) Instances() InstanceInformer { return &instanceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// Machines returns a MachineInformer. +func (v *version) Machines() MachineInformer { + return &machineInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // PuppetTargets returns a PuppetTargetInformer. func (v *version) PuppetTargets() PuppetTargetInformer { return &puppetTargetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/wing/informers/externalversions/wing/v1alpha1/machine.go b/pkg/wing/informers/externalversions/wing/v1alpha1/machine.go new file mode 100644 index 0000000000..02ba6978de --- /dev/null +++ b/pkg/wing/informers/externalversions/wing/v1alpha1/machine.go @@ -0,0 +1,74 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by informer-gen + +package v1alpha1 + +import ( + wing_v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + client "github.com/jetstack/tarmak/pkg/wing/client" + internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/jetstack/tarmak/pkg/wing/listers/wing/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" + time "time" +) + +// MachineInformer provides access to a shared informer and lister for +// Machines. +type MachineInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.MachineLister +} + +type machineInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewMachineInformer constructs a new informer for Machine 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 NewMachineInformer(client client.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredMachineInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredMachineInformer constructs a new informer for Machine 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 NewFilteredMachineInformer(client client.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.WingV1alpha1().Machines(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.WingV1alpha1().Machines(namespace).Watch(options) + }, + }, + &wing_v1alpha1.Machine{}, + resyncPeriod, + indexers, + ) +} + +func (f *machineInformer) defaultInformer(client client.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredMachineInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *machineInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&wing_v1alpha1.Machine{}, f.defaultInformer) +} + +func (f *machineInformer) Lister() v1alpha1.MachineLister { + return v1alpha1.NewMachineLister(f.Informer().GetIndexer()) +} diff --git a/pkg/wing/informers/internalversion/generic.go b/pkg/wing/informers/internalversion/generic.go index 27a673f67d..d52a2386c5 100644 --- a/pkg/wing/informers/internalversion/generic.go +++ b/pkg/wing/informers/internalversion/generic.go @@ -40,6 +40,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=wing.tarmak.io, Version=internalVersion case wing.SchemeGroupVersion.WithResource("instances"): return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().InternalVersion().Instances().Informer()}, nil + case wing.SchemeGroupVersion.WithResource("machines"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().InternalVersion().Machines().Informer()}, nil case wing.SchemeGroupVersion.WithResource("puppettargets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().InternalVersion().PuppetTargets().Informer()}, nil case wing.SchemeGroupVersion.WithResource("wingjobs"): diff --git a/pkg/wing/informers/internalversion/wing/internalversion/interface.go b/pkg/wing/informers/internalversion/wing/internalversion/interface.go index 7e0b0a1359..6557d800ea 100644 --- a/pkg/wing/informers/internalversion/wing/internalversion/interface.go +++ b/pkg/wing/informers/internalversion/wing/internalversion/interface.go @@ -12,6 +12,8 @@ import ( type Interface interface { // Instances returns a InstanceInformer. Instances() InstanceInformer + // Machines returns a MachineInformer. + Machines() MachineInformer // PuppetTargets returns a PuppetTargetInformer. PuppetTargets() PuppetTargetInformer // WingJobs returns a WingJobInformer. @@ -34,6 +36,11 @@ func (v *version) Instances() InstanceInformer { return &instanceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// Machines returns a MachineInformer. +func (v *version) Machines() MachineInformer { + return &machineInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // PuppetTargets returns a PuppetTargetInformer. func (v *version) PuppetTargets() PuppetTargetInformer { return &puppetTargetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/wing/informers/internalversion/wing/internalversion/machine.go b/pkg/wing/informers/internalversion/wing/internalversion/machine.go new file mode 100644 index 0000000000..aa0d5f606d --- /dev/null +++ b/pkg/wing/informers/internalversion/wing/internalversion/machine.go @@ -0,0 +1,74 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by informer-gen + +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + internalclientset "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset" + internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/internalversion/internalinterfaces" + internalversion "github.com/jetstack/tarmak/pkg/wing/listers/wing/internalversion" + 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" + time "time" +) + +// MachineInformer provides access to a shared informer and lister for +// Machines. +type MachineInformer interface { + Informer() cache.SharedIndexInformer + Lister() internalversion.MachineLister +} + +type machineInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewMachineInformer constructs a new informer for Machine 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 NewMachineInformer(client internalclientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredMachineInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredMachineInformer constructs a new informer for Machine 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 NewFilteredMachineInformer(client internalclientset.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.Wing().Machines(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.Wing().Machines(namespace).Watch(options) + }, + }, + &wing.Machine{}, + resyncPeriod, + indexers, + ) +} + +func (f *machineInformer) defaultInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredMachineInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *machineInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&wing.Machine{}, f.defaultInformer) +} + +func (f *machineInformer) Lister() internalversion.MachineLister { + return internalversion.NewMachineLister(f.Informer().GetIndexer()) +} diff --git a/pkg/wing/listers/wing/internalversion/expansion_generated.go b/pkg/wing/listers/wing/internalversion/expansion_generated.go index c7d63398b9..5e5f47c766 100644 --- a/pkg/wing/listers/wing/internalversion/expansion_generated.go +++ b/pkg/wing/listers/wing/internalversion/expansion_generated.go @@ -12,6 +12,14 @@ type InstanceListerExpansion interface{} // InstanceNamespaceLister. type InstanceNamespaceListerExpansion interface{} +// MachineListerExpansion allows custom methods to be added to +// MachineLister. +type MachineListerExpansion interface{} + +// MachineNamespaceListerExpansion allows custom methods to be added to +// MachineNamespaceLister. +type MachineNamespaceListerExpansion interface{} + // PuppetTargetListerExpansion allows custom methods to be added to // PuppetTargetLister. type PuppetTargetListerExpansion interface{} diff --git a/pkg/wing/listers/wing/internalversion/machine.go b/pkg/wing/listers/wing/internalversion/machine.go new file mode 100644 index 0000000000..d8d54ab323 --- /dev/null +++ b/pkg/wing/listers/wing/internalversion/machine.go @@ -0,0 +1,80 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by lister-gen + +package internalversion + +import ( + wing "github.com/jetstack/tarmak/pkg/apis/wing" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// MachineLister helps list Machines. +type MachineLister interface { + // List lists all Machines in the indexer. + List(selector labels.Selector) (ret []*wing.Machine, err error) + // Machines returns an object that can list and get Machines. + Machines(namespace string) MachineNamespaceLister + MachineListerExpansion +} + +// machineLister implements the MachineLister interface. +type machineLister struct { + indexer cache.Indexer +} + +// NewMachineLister returns a new MachineLister. +func NewMachineLister(indexer cache.Indexer) MachineLister { + return &machineLister{indexer: indexer} +} + +// List lists all Machines in the indexer. +func (s *machineLister) List(selector labels.Selector) (ret []*wing.Machine, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*wing.Machine)) + }) + return ret, err +} + +// Machines returns an object that can list and get Machines. +func (s *machineLister) Machines(namespace string) MachineNamespaceLister { + return machineNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MachineNamespaceLister helps list and get Machines. +type MachineNamespaceLister interface { + // List lists all Machines in the indexer for a given namespace. + List(selector labels.Selector) (ret []*wing.Machine, err error) + // Get retrieves the Machine from the indexer for a given namespace and name. + Get(name string) (*wing.Machine, error) + MachineNamespaceListerExpansion +} + +// machineNamespaceLister implements the MachineNamespaceLister +// interface. +type machineNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Machines in the indexer for a given namespace. +func (s machineNamespaceLister) List(selector labels.Selector) (ret []*wing.Machine, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*wing.Machine)) + }) + return ret, err +} + +// Get retrieves the Machine from the indexer for a given namespace and name. +func (s machineNamespaceLister) Get(name string) (*wing.Machine, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(wing.Resource("machine"), name) + } + return obj.(*wing.Machine), nil +} diff --git a/pkg/wing/listers/wing/v1alpha1/expansion_generated.go b/pkg/wing/listers/wing/v1alpha1/expansion_generated.go index 7ec86f6a73..4b945f9c86 100644 --- a/pkg/wing/listers/wing/v1alpha1/expansion_generated.go +++ b/pkg/wing/listers/wing/v1alpha1/expansion_generated.go @@ -12,6 +12,14 @@ type InstanceListerExpansion interface{} // InstanceNamespaceLister. type InstanceNamespaceListerExpansion interface{} +// MachineListerExpansion allows custom methods to be added to +// MachineLister. +type MachineListerExpansion interface{} + +// MachineNamespaceListerExpansion allows custom methods to be added to +// MachineNamespaceLister. +type MachineNamespaceListerExpansion interface{} + // PuppetTargetListerExpansion allows custom methods to be added to // PuppetTargetLister. type PuppetTargetListerExpansion interface{} diff --git a/pkg/wing/listers/wing/v1alpha1/machine.go b/pkg/wing/listers/wing/v1alpha1/machine.go new file mode 100644 index 0000000000..6f1bea4000 --- /dev/null +++ b/pkg/wing/listers/wing/v1alpha1/machine.go @@ -0,0 +1,80 @@ +// Copyright Jetstack Ltd. See LICENSE for details. + +// This file was automatically generated by lister-gen + +package v1alpha1 + +import ( + v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// MachineLister helps list Machines. +type MachineLister interface { + // List lists all Machines in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Machine, err error) + // Machines returns an object that can list and get Machines. + Machines(namespace string) MachineNamespaceLister + MachineListerExpansion +} + +// machineLister implements the MachineLister interface. +type machineLister struct { + indexer cache.Indexer +} + +// NewMachineLister returns a new MachineLister. +func NewMachineLister(indexer cache.Indexer) MachineLister { + return &machineLister{indexer: indexer} +} + +// List lists all Machines in the indexer. +func (s *machineLister) List(selector labels.Selector) (ret []*v1alpha1.Machine, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Machine)) + }) + return ret, err +} + +// Machines returns an object that can list and get Machines. +func (s *machineLister) Machines(namespace string) MachineNamespaceLister { + return machineNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MachineNamespaceLister helps list and get Machines. +type MachineNamespaceLister interface { + // List lists all Machines in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Machine, err error) + // Get retrieves the Machine from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Machine, error) + MachineNamespaceListerExpansion +} + +// machineNamespaceLister implements the MachineNamespaceLister +// interface. +type machineNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Machines in the indexer for a given namespace. +func (s machineNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Machine, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Machine)) + }) + return ret, err +} + +// Get retrieves the Machine from the indexer for a given namespace and name. +func (s machineNamespaceLister) Get(name string) (*v1alpha1.Machine, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("machine"), name) + } + return obj.(*v1alpha1.Machine), nil +} diff --git a/pkg/wing/registry/wing/machine/etcd.go b/pkg/wing/registry/wing/machine/etcd.go new file mode 100644 index 0000000000..9ec7a069d3 --- /dev/null +++ b/pkg/wing/registry/wing/machine/etcd.go @@ -0,0 +1,34 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package machine + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + + "github.com/jetstack/tarmak/pkg/apis/wing" + "github.com/jetstack/tarmak/pkg/wing/registry" +) + +// NewREST returns a RESTStorage object that will work against API services. +func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*registry.REST, error) { + strategy := NewStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { return &wing.Machine{} }, + NewListFunc: func() runtime.Object { return &wing.MachineList{} }, + PredicateFunc: MatchMachine, + DefaultQualifiedResource: wing.Resource("machines"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + } + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return nil, err + } + return ®istry.REST{ + Store: store, + }, nil +} diff --git a/pkg/wing/registry/wing/machine/strategy.go b/pkg/wing/registry/wing/machine/strategy.go new file mode 100644 index 0000000000..8a040b869e --- /dev/null +++ b/pkg/wing/registry/wing/machine/strategy.go @@ -0,0 +1,80 @@ +// Copyright Jetstack Ltd. See LICENSE for details. +package machine + +import ( + "fmt" + + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + + "github.com/jetstack/tarmak/pkg/apis/wing" + genericapirequest "k8s.io/apiserver/pkg/endpoints/request" +) + +func NewStrategy(typer runtime.ObjectTyper) machineStrategy { + return machineStrategy{typer, names.SimpleNameGenerator} +} + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) { + apiserver, ok := obj.(*wing.Machine) + if !ok { + return nil, nil, false, fmt.Errorf("given object is not a Machine.") + } + return labels.Set(apiserver.ObjectMeta.Labels), MachineToSelectableFields(apiserver), apiserver.Initializers != nil, nil +} + +// MatchMachine is the filter used by the generic etcd backend to watch events +// from etcd to clients of the apiserver only interested in specific labels/fields. +func MatchMachine(label labels.Selector, field fields.Selector) storage.SelectionPredicate { + return storage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +// MachineToSelectableFields returns a field set that represents the object. +func MachineToSelectableFields(obj *wing.Machine) fields.Set { + return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true) +} + +type machineStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func (machineStrategy) NamespaceScoped() bool { + return true +} + +func (machineStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { + // TODO: update all none timestamp to now() +} + +func (machineStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { + // TODO: update all none timestamp to now() +} + +func (machineStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { + return field.ErrorList{} +} + +func (machineStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (machineStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (machineStrategy) Canonicalize(obj runtime.Object) { +} + +func (machineStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { + return field.ErrorList{} +} From c57bce0d76ea391819f74b1bf8c53470bfa4ae8c Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Tue, 24 Jul 2018 17:04:59 +0100 Subject: [PATCH 12/14] Integrate Machine type --- pkg/apis/wing/machine_types.go | 2 + pkg/apis/wing/v1alpha1/machine_types.go | 2 + .../wing/v1alpha1/zz_generated.conversion.go | 4 ++ .../informers/externalversions/factory.go | 6 --- .../informers/externalversions/generic.go | 13 +------ pkg/wing/instancecontroller.go | 38 +++++++++---------- pkg/wing/puppet.go | 37 ++++++++---------- pkg/wing/wing.go | 26 ++++++------- 8 files changed, 57 insertions(+), 71 deletions(-) diff --git a/pkg/apis/wing/machine_types.go b/pkg/apis/wing/machine_types.go index 702b7e9734..fa75509c2e 100644 --- a/pkg/apis/wing/machine_types.go +++ b/pkg/apis/wing/machine_types.go @@ -77,6 +77,8 @@ type MachineSpec struct { // as-is. // +optional ConfigSource *corev1.NodeConfigSource `json:"configSource,omitempty"` + + PuppetTargetRef string `json:"puppetTargetRef"` } // MachineStatus defines the observed state of Machine diff --git a/pkg/apis/wing/v1alpha1/machine_types.go b/pkg/apis/wing/v1alpha1/machine_types.go index a28334fa4f..0eb823a6eb 100644 --- a/pkg/apis/wing/v1alpha1/machine_types.go +++ b/pkg/apis/wing/v1alpha1/machine_types.go @@ -77,6 +77,8 @@ type MachineSpec struct { // as-is. // +optional ConfigSource *corev1.NodeConfigSource `json:"configSource,omitempty"` + + PuppetTargetRef string `json:"puppetTargetRef"` } // MachineStatus defines the observed state of Machine diff --git a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go index bab69151f9..668b173b16 100644 --- a/pkg/apis/wing/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/wing/v1alpha1/zz_generated.conversion.go @@ -243,6 +243,7 @@ func autoConvert_v1alpha1_MachineSpec_To_wing_MachineSpec(in *MachineSpec, out * return err } out.ConfigSource = (*v1.NodeConfigSource)(unsafe.Pointer(in.ConfigSource)) + out.PuppetTargetRef = in.PuppetTargetRef return nil } @@ -262,6 +263,7 @@ func autoConvert_wing_MachineSpec_To_v1alpha1_MachineSpec(in *wing.MachineSpec, return err } out.ConfigSource = (*v1.NodeConfigSource)(unsafe.Pointer(in.ConfigSource)) + out.PuppetTargetRef = in.PuppetTargetRef return nil } @@ -278,6 +280,7 @@ func autoConvert_v1alpha1_MachineStatus_To_wing_MachineStatus(in *MachineStatus, out.ErrorMessage = (*string)(unsafe.Pointer(in.ErrorMessage)) out.ProviderStatus = (*runtime.RawExtension)(unsafe.Pointer(in.ProviderStatus)) out.Addresses = *(*[]v1.NodeAddress)(unsafe.Pointer(&in.Addresses)) + out.Converged = in.Converged return nil } @@ -294,6 +297,7 @@ func autoConvert_wing_MachineStatus_To_v1alpha1_MachineStatus(in *wing.MachineSt out.ErrorMessage = (*string)(unsafe.Pointer(in.ErrorMessage)) out.ProviderStatus = (*runtime.RawExtension)(unsafe.Pointer(in.ProviderStatus)) out.Addresses = *(*[]v1.NodeAddress)(unsafe.Pointer(&in.Addresses)) + out.Converged = in.Converged return nil } diff --git a/pkg/wing/informers/externalversions/factory.go b/pkg/wing/informers/externalversions/factory.go index 73e99683bc..8a18235eca 100644 --- a/pkg/wing/informers/externalversions/factory.go +++ b/pkg/wing/informers/externalversions/factory.go @@ -6,7 +6,6 @@ package externalversions import ( client "github.com/jetstack/tarmak/pkg/wing/client" - apis "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/apis" internalinterfaces "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/internalinterfaces" wing "github.com/jetstack/tarmak/pkg/wing/informers/externalversions/wing" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -109,14 +108,9 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - Wing() apis.Interface Wing() wing.Interface } -func (f *sharedInformerFactory) Wing() apis.Interface { - return apis.New(f, f.namespace, f.tweakListOptions) -} - func (f *sharedInformerFactory) Wing() wing.Interface { return wing.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/wing/informers/externalversions/generic.go b/pkg/wing/informers/externalversions/generic.go index 95fb53ea2a..210655e7b1 100644 --- a/pkg/wing/informers/externalversions/generic.go +++ b/pkg/wing/informers/externalversions/generic.go @@ -6,7 +6,6 @@ package externalversions import ( "fmt" - wing "github.com/jetstack/tarmak/pkg/apis/wing" v1alpha1 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" @@ -38,17 +37,7 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=wing.tarmak.io, Version=wing - case wing.SchemeGroupVersion.WithResource("instances"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().Wing().Instances().Informer()}, nil - case wing.SchemeGroupVersion.WithResource("machines"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().Wing().Machines().Informer()}, nil - case wing.SchemeGroupVersion.WithResource("puppettargets"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().Wing().PuppetTargets().Informer()}, nil - case wing.SchemeGroupVersion.WithResource("wingjobs"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().Wing().WingJobs().Informer()}, nil - - // Group=wing.tarmak.io, Version=v1alpha1 + // Group=wing.tarmak.io, Version=v1alpha1 case v1alpha1.SchemeGroupVersion.WithResource("instances"): return &genericInformer{resource: resource.GroupResource(), informer: f.Wing().V1alpha1().Instances().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("machines"): diff --git a/pkg/wing/instancecontroller.go b/pkg/wing/instancecontroller.go index 43e017f070..066181ecb6 100644 --- a/pkg/wing/instancecontroller.go +++ b/pkg/wing/instancecontroller.go @@ -14,7 +14,7 @@ import ( "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" ) -type InstanceController struct { +type MachineController struct { indexer cache.Indexer queue workqueue.RateLimitingInterface informer cache.Controller @@ -22,17 +22,17 @@ type InstanceController struct { wing *Wing } -func NewInstanceController(queue workqueue.RateLimitingInterface, indexer cache.Indexer, informer cache.Controller, wing *Wing) *InstanceController { - return &InstanceController{ +func NewMachineController(queue workqueue.RateLimitingInterface, indexer cache.Indexer, informer cache.Controller, wing *Wing) *MachineController { + return &MachineController{ informer: informer, indexer: indexer, queue: queue, - log: wing.log.WithField("tier", "InstanceController"), + log: wing.log.WithField("tier", "MachineController"), wing: wing, } } -func (c *InstanceController) processNextItem() bool { +func (c *MachineController) processNextItem() bool { // Wait until there is a new item in the working queue key, quit := c.queue.Get() if quit { @@ -44,13 +44,13 @@ func (c *InstanceController) processNextItem() bool { defer c.queue.Done(key) // Invoke the method containing the business logic - err := c.syncInstance(key.(string)) + err := c.syncMachine(key.(string)) // Handle the error if something went wrong during the execution of the business logic c.handleErr(err, key) return true } -func (c *InstanceController) syncInstance(key string) error { +func (c *MachineController) syncMachine(key string) error { // ensure only one converge at a time c.wing.convergeWG.Wait() @@ -62,25 +62,25 @@ func (c *InstanceController) syncInstance(key string) error { } if !exists { - // Below we will warm up our cache with a Instance, so that we will see a delete for one instance - fmt.Printf("Instance %s does not exist anymore\n", key) + // Below we will warm up our cache with a Machine, so that we will see a delete for one instance + fmt.Printf("Machine %s does not exist anymore\n", key) } else { // Note that you also have to check the uid if you have a local controlled resource, which // is dependent on the actual instance, to detect that a Instance was recreated with the same name - _, ok := obj.(*v1alpha1.Instance) + _, ok := obj.(*v1alpha1.Machine) if !ok { - c.log.Error("couldn't cast to Instance") + c.log.Error("couldn't cast to Machine") return nil } c.log.Infof("running converge") - c.wing.convergeInstance() + c.wing.convergeMachine() } return nil } // handleErr checks if an error happened and makes sure we will retry later. -func (c *InstanceController) handleErr(err error, key interface{}) { +func (c *MachineController) handleErr(err error, key interface{}) { if err == nil { // Forget about the #AddRateLimited history of the key on every successful synchronization. // This ensures that future processing of updates for this key is not delayed because of @@ -91,7 +91,7 @@ func (c *InstanceController) handleErr(err error, key interface{}) { // This controller retries 5 times if something goes wrong. After that, it stops trying. if c.queue.NumRequeues(key) < 5 { - c.log.Infof("Error syncing instance %v: %v", key, err) + c.log.Infof("Error syncing machine %v: %v", key, err) // Re-enqueue the key rate limited. Based on the rate limiter on the // queue and the re-enqueue history, the key will be processed later again. @@ -102,15 +102,15 @@ func (c *InstanceController) handleErr(err error, key interface{}) { c.queue.Forget(key) // Report to an external entity that, even after several retries, we could not successfully process this key runtime.HandleError(err) - c.log.Infof("Dropping instance %q out of the queue: %v", key, err) + c.log.Infof("Dropping machine %q out of the queue: %v", key, err) } -func (c *InstanceController) Run(threadiness int, stopCh chan struct{}) { +func (c *MachineController) Run(threadiness int, stopCh chan struct{}) { defer runtime.HandleCrash() // Let the workers stop when we are done defer c.queue.ShutDown() - c.log.Info("Starting Instance controller") + c.log.Info("Starting Machine controller") go c.informer.Run(stopCh) @@ -125,10 +125,10 @@ func (c *InstanceController) Run(threadiness int, stopCh chan struct{}) { } <-stopCh - c.log.Info("Stopping Instance controller") + c.log.Info("Stopping Machine controller") } -func (c *InstanceController) runWorker() { +func (c *MachineController) runWorker() { for c.processNextItem() { } } diff --git a/pkg/wing/puppet.go b/pkg/wing/puppet.go index 729cb65a67..0b0d824f09 100644 --- a/pkg/wing/puppet.go +++ b/pkg/wing/puppet.go @@ -143,44 +143,39 @@ func (w *Wing) runPuppet(job *v1alpha1.WingJob) error { return nil } -func (w *Wing) convergeInstance() error { - instanceAPI := w.clientset.WingV1alpha1().Instances(w.flags.ClusterName) - instance, err := instanceAPI.Get( +func (w *Wing) convergeMachine() error { + machineAPI := w.clientset.WingV1alpha1().Machines(w.flags.ClusterName) + machine, err := machineAPI.Get( w.flags.InstanceName, metav1.GetOptions{}, ) if err != nil { if kerr, ok := err.(*apierrors.StatusError); ok && kerr.ErrStatus.Reason == metav1.StatusReasonNotFound { - instance = &v1alpha1.Instance{ + machine = &v1alpha1.Machine{ ObjectMeta: metav1.ObjectMeta{ Name: w.flags.InstanceName, }, - Status: &v1alpha1.InstanceStatus{ + Status: v1alpha1.MachineStatus{ Converged: false, }, } - _, err := instanceAPI.Create(instance) + _, err := machineAPI.Create(machine) if err != nil { - return fmt.Errorf("error creating instance: %s", err) + return fmt.Errorf("error creating machine: %s", err) } return nil } - return fmt.Errorf("error get existing instance: %s", err) + return fmt.Errorf("error get existing machine: %s", err) } - if instance.Status.Converged { - w.log.Infof("Instance already converged: ", instance.Name) + if machine.Status.Converged { + w.log.Infof("Machine already converged: ", machine.Name) return nil } - if instance.Spec == nil { - w.log.Warnf("instance %s has empty spec field", instance.Name) - return nil - } - - puppetTarget := instance.Spec.PuppetTargetRef + puppetTarget := machine.Spec.PuppetTargetRef if puppetTarget == "" { - w.log.Warn("no puppet target for instance: ", instance.Name) + w.log.Warn("no puppet target for machine: ", machine.Name) return nil } @@ -198,7 +193,7 @@ func (w *Wing) convergeInstance() error { Name: jobName, }, Spec: &v1alpha1.WingJobSpec{ - InstanceName: instance.Name, + InstanceName: machine.Name, PuppetTargetRef: puppetTarget, Operation: "apply", RequestTimestamp: metav1.Now(), @@ -214,9 +209,9 @@ func (w *Wing) convergeInstance() error { return fmt.Errorf("error get existing WingJob: %s", err) } - instanceCopy := instance.DeepCopy() - instanceCopy.Status.Converged = true - _, err = instanceAPI.Update(instanceCopy) + machineCopy := machine.DeepCopy() + machineCopy.Status.Converged = true + _, err = machineAPI.Update(machineCopy) if err != nil { return err } diff --git a/pkg/wing/wing.go b/pkg/wing/wing.go index 2563c15564..a53c19de4a 100644 --- a/pkg/wing/wing.go +++ b/pkg/wing/wing.go @@ -32,8 +32,8 @@ type Wing struct { convergeWG sync.WaitGroup // wait group for converge runs // controller loop - controller *Controller - instanceController *InstanceController + controller *Controller + machineController *MachineController // allows overriding puppet command for testing puppetCommandOverride Command @@ -89,7 +89,7 @@ func (w *Wing) Run(args []string) error { w.signalHandler(signalCh) // run converge on instance after first start - go w.convergeInstance() + go w.convergeMachine() // start watching for API server events that trigger applies w.watchForNotifications() @@ -155,31 +155,31 @@ func (w *Wing) watchForNotifications() { // Now let's start the controller go w.controller.Run(1, w.stopCh) - instanceListWatcher := cache.NewListWatchFromClient( + machineListWatcher := cache.NewListWatchFromClient( w.clientset.WingV1alpha1().RESTClient(), - "instances", w.flags.ClusterName, + "machines", w.flags.ClusterName, fields.ParseSelectorOrDie(fmt.Sprintf("metadata.name=%s", w.flags.InstanceName)), ) // create the workqueue - instanceQueue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) + machineQueue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) // Bind the workqueue to a cache with the help of an informer. This way we make sure that // whenever the cache is updated, the pod key is added to the workqueue. // Note that when we finally process the item from the workqueue, we might see a newer version // of the Pod than the version which was responsible for triggering the update. - instanceIndexer, instanceInformer := cache.NewIndexerInformer(instanceListWatcher, &v1alpha1.Instance{}, 0, cache.ResourceEventHandlerFuncs{ + machineIndexer, machineInformer := cache.NewIndexerInformer(machineListWatcher, &v1alpha1.Machine{}, 0, cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { key, err := cache.MetaNamespaceKeyFunc(obj) if err == nil { - instanceQueue.AddAfter(key, 2*time.Second) + machineQueue.AddAfter(key, 2*time.Second) } }, UpdateFunc: func(old interface{}, new interface{}) { key, err := cache.MetaNamespaceKeyFunc(new) if err == nil { - instanceQueue.AddAfter(key, 2*time.Second) + machineQueue.AddAfter(key, 2*time.Second) } }, DeleteFunc: func(obj interface{}) { @@ -187,15 +187,15 @@ func (w *Wing) watchForNotifications() { // key function. key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err == nil { - instanceQueue.AddAfter(key, 2*time.Second) + machineQueue.AddAfter(key, 2*time.Second) } }, }, cache.Indexers{}) - w.instanceController = NewInstanceController(instanceQueue, instanceIndexer, instanceInformer, w) + w.machineController = NewMachineController(machineQueue, machineIndexer, machineInformer, w) // Now let's start the controller - go w.instanceController.Run(1, w.stopCh) + go w.machineController.Run(1, w.stopCh) } @@ -216,7 +216,7 @@ func (w *Wing) signalHandler(ch chan os.Signal) { // create new converge stop channel and run converge w.convergeStopCh = make(chan struct{}) - w.convergeInstance() + w.convergeMachine() case syscall.SIGINT: w.log.Infof("wing received SIGINT") From 85a344666172b5fc9ff29f7fb0eac4c55eb1f577 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Tue, 24 Jul 2018 18:01:05 +0100 Subject: [PATCH 13/14] Fix client-gen --- Makefile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Makefile b/Makefile index 5e9b4beedb..9df57e6f55 100644 --- a/Makefile +++ b/Makefile @@ -181,6 +181,35 @@ go_generate_types: depend $(TYPES_FILES) --input-dirs "$(PACKAGE_NAME)/pkg/apis/wing" \ --input-dirs "$(PACKAGE_NAME)/pkg/apis/wing/v1alpha1" \ --output-file-base zz_generated.conversion + # Generate the internal clientset (pkg/client/clientset_generated/internalclientset) + ${BINDIR}/client-gen "$@" \ + --go-header-file "${HACK_DIR}/boilerplate/boilerplate.go.txt" \ + --input-base "github.com/jetstack/tarmak/pkg/apis/" \ + --input "wing" \ + --clientset-path "github.com/jetstack/tarmak/pkg/wing/clients" \ + --clientset-name internalclientset \ + # Generate the versioned clientset (pkg/client/clientset_generated/clientset) + ${BINDIR}/client-gen "$@" \ + --go-header-file "${HACK_DIR}/boilerplate/boilerplate.go.txt" \ + --input-base "github.com/jetstack/tarmak/pkg/apis/" \ + --input "wing/v1alpha1" \ + --clientset-path "github.com/jetstack/tarmak/pkg/wing" \ + --clientset-name "client" \ + # generate lister + ${BINDIR}/lister-gen "$@" \ + --go-header-file "${HACK_DIR}/boilerplate/boilerplate.go.txt" \ + --input-dirs="github.com/jetstack/tarmak/pkg/apis/wing" \ + --input-dirs="github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" \ + --output-package "github.com/jetstack/tarmak/pkg/wing/listers" \ + # generate informer + ${BINDIR}/informer-gen "$@" \ + --go-header-file "${HACK_DIR}/boilerplate/boilerplate.go.txt" \ + --input-dirs="github.com/jetstack/tarmak/pkg/apis/wing" \ + --input-dirs="github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" \ + --internal-clientset-package "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset" \ + --versioned-clientset-package "github.com/jetstack/tarmak/pkg/wing/client" \ + --listers-package "github.com/jetstack/tarmak/pkg/wing/listers" \ + --output-package "github.com/jetstack/tarmak/pkg/wing/informers" # generate all pkg/client contents $(HACK_DIR)/update-client-gen.sh From 98d321f1c10776a1b5a11886478ed10ba5caea29 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Tue, 24 Jul 2018 18:02:26 +0100 Subject: [PATCH 14/14] Converge machines --- pkg/wing/convergemachine.go | 85 ++++++++++++++++++++++++++++++++++ pkg/wing/instancecontroller.go | 4 -- pkg/wing/puppet.go | 77 ------------------------------ pkg/wing/wing.go | 3 -- 4 files changed, 85 insertions(+), 84 deletions(-) create mode 100644 pkg/wing/convergemachine.go diff --git a/pkg/wing/convergemachine.go b/pkg/wing/convergemachine.go new file mode 100644 index 0000000000..9275725010 --- /dev/null +++ b/pkg/wing/convergemachine.go @@ -0,0 +1,85 @@ +package wing + +import ( + "fmt" + + "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func (w *Wing) convergeMachine() error { + machineAPI := w.clientset.WingV1alpha1().Machines(w.flags.ClusterName) + machine, err := machineAPI.Get( + w.flags.InstanceName, + metav1.GetOptions{}, + ) + if err != nil { + if kerr, ok := err.(*apierrors.StatusError); ok && kerr.ErrStatus.Reason == metav1.StatusReasonNotFound { + machine = &v1alpha1.Machine{ + ObjectMeta: metav1.ObjectMeta{ + Name: w.flags.InstanceName, + }, + Status: v1alpha1.MachineStatus{ + Converged: false, + }, + } + _, err := machineAPI.Create(machine) + if err != nil { + return fmt.Errorf("error creating machine: %s", err) + } + return nil + } + return fmt.Errorf("error get existing machine: %s", err) + } + + if machine.Status.Converged { + w.log.Infof("Machine already converged: %s", machine.Name) + return nil + } + + puppetTarget := machine.Spec.PuppetTargetRef + if puppetTarget == "" { + w.log.Warn("no puppet target for machine: ", machine.Name) + return nil + } + + // FIXME: this shouldn't be done on the wing agent + jobName := fmt.Sprintf("%s-%s", w.flags.InstanceName, puppetTarget) + jobsAPI := w.clientset.WingV1alpha1().WingJobs(w.flags.ClusterName) + job, err := jobsAPI.Get( + jobName, + metav1.GetOptions{}, + ) + if err != nil { + if kerr, ok := err.(*apierrors.StatusError); ok && kerr.ErrStatus.Reason == metav1.StatusReasonNotFound { + job = &v1alpha1.WingJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: jobName, + }, + Spec: &v1alpha1.WingJobSpec{ + InstanceName: machine.Name, + PuppetTargetRef: puppetTarget, + Operation: "apply", + RequestTimestamp: metav1.Now(), + }, + Status: &v1alpha1.WingJobStatus{}, + } + _, err := jobsAPI.Create(job) + if err != nil { + return fmt.Errorf("error creating WingJob: %s", err) + } + return nil + } + return fmt.Errorf("error get existing WingJob: %s", err) + } + + machineCopy := machine.DeepCopy() + machineCopy.Status.Converged = true + _, err = machineAPI.Update(machineCopy) + if err != nil { + return err + } + + return nil +} diff --git a/pkg/wing/instancecontroller.go b/pkg/wing/instancecontroller.go index 066181ecb6..ebf1e9f9b6 100644 --- a/pkg/wing/instancecontroller.go +++ b/pkg/wing/instancecontroller.go @@ -51,10 +51,6 @@ func (c *MachineController) processNextItem() bool { } func (c *MachineController) syncMachine(key string) error { - - // ensure only one converge at a time - c.wing.convergeWG.Wait() - obj, exists, err := c.indexer.GetByKey(key) if err != nil { c.log.Errorf("Fetching object with key %s from store failed with %v", key, err) diff --git a/pkg/wing/puppet.go b/pkg/wing/puppet.go index 0b0d824f09..68e26209ff 100644 --- a/pkg/wing/puppet.go +++ b/pkg/wing/puppet.go @@ -19,7 +19,6 @@ import ( "github.com/cenkalti/backoff" "github.com/docker/docker/pkg/archive" "golang.org/x/net/context" - apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1" @@ -143,82 +142,6 @@ func (w *Wing) runPuppet(job *v1alpha1.WingJob) error { return nil } -func (w *Wing) convergeMachine() error { - machineAPI := w.clientset.WingV1alpha1().Machines(w.flags.ClusterName) - machine, err := machineAPI.Get( - w.flags.InstanceName, - metav1.GetOptions{}, - ) - if err != nil { - if kerr, ok := err.(*apierrors.StatusError); ok && kerr.ErrStatus.Reason == metav1.StatusReasonNotFound { - machine = &v1alpha1.Machine{ - ObjectMeta: metav1.ObjectMeta{ - Name: w.flags.InstanceName, - }, - Status: v1alpha1.MachineStatus{ - Converged: false, - }, - } - _, err := machineAPI.Create(machine) - if err != nil { - return fmt.Errorf("error creating machine: %s", err) - } - return nil - } - return fmt.Errorf("error get existing machine: %s", err) - } - - if machine.Status.Converged { - w.log.Infof("Machine already converged: ", machine.Name) - return nil - } - - puppetTarget := machine.Spec.PuppetTargetRef - if puppetTarget == "" { - w.log.Warn("no puppet target for machine: ", machine.Name) - return nil - } - - // FIXME: this shouldn't be done on the wing agent - jobName := fmt.Sprintf("%s-%s", w.flags.InstanceName, puppetTarget) - jobsAPI := w.clientset.WingV1alpha1().WingJobs(w.flags.ClusterName) - job, err := jobsAPI.Get( - jobName, - metav1.GetOptions{}, - ) - if err != nil { - if kerr, ok := err.(*apierrors.StatusError); ok && kerr.ErrStatus.Reason == metav1.StatusReasonNotFound { - job = &v1alpha1.WingJob{ - ObjectMeta: metav1.ObjectMeta{ - Name: jobName, - }, - Spec: &v1alpha1.WingJobSpec{ - InstanceName: machine.Name, - PuppetTargetRef: puppetTarget, - Operation: "apply", - RequestTimestamp: metav1.Now(), - }, - Status: &v1alpha1.WingJobStatus{}, - } - _, err := jobsAPI.Create(job) - if err != nil { - return fmt.Errorf("error creating WingJob: %s", err) - } - return nil - } - return fmt.Errorf("error get existing WingJob: %s", err) - } - - machineCopy := machine.DeepCopy() - machineCopy.Status.Converged = true - _, err = machineAPI.Update(machineCopy) - if err != nil { - return err - } - - return nil -} - func (w *Wing) converge(job *v1alpha1.WingJob) { w.convergeWG.Add(1) defer w.convergeWG.Done() diff --git a/pkg/wing/wing.go b/pkg/wing/wing.go index a53c19de4a..a3705af0cb 100644 --- a/pkg/wing/wing.go +++ b/pkg/wing/wing.go @@ -88,9 +88,6 @@ func (w *Wing) Run(args []string) error { signal.Notify(signalCh, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP) w.signalHandler(signalCh) - // run converge on instance after first start - go w.convergeMachine() - // start watching for API server events that trigger applies w.watchForNotifications()