From 42443f1ccd5e10731a76a407ffca1f48254dfd83 Mon Sep 17 00:00:00 2001 From: Christopher Hein Date: Wed, 1 Aug 2018 20:58:57 -0700 Subject: [PATCH 1/2] Adding Code Generated Files **Why:** * This adds the code generated files for the cft resource --- .../v1alpha1/cloudformationtemplate.go | 65 ++++++++ .../v1alpha1/zz_generated.deepcopy.go | 152 +++++++++++++++++ pkg/client/clientset/versioned/clientset.go | 100 +++++++++++ pkg/client/clientset/versioned/doc.go | 20 +++ .../versioned/fake/clientset_generated.go | 81 +++++++++ pkg/client/clientset/versioned/fake/doc.go | 20 +++ .../clientset/versioned/fake/register.go | 54 ++++++ pkg/client/clientset/versioned/scheme/doc.go | 20 +++ .../clientset/versioned/scheme/register.go | 54 ++++++ .../v1alpha1/cloudformationtemplate.go | 157 ++++++++++++++++++ .../typed/operator.aws/v1alpha1/doc.go | 20 +++ .../typed/operator.aws/v1alpha1/fake/doc.go | 20 +++ .../fake/fake_cloudformationtemplate.go | 128 ++++++++++++++ .../v1alpha1/fake/fake_operator.aws_client.go | 40 +++++ .../v1alpha1/generated_expansion.go | 21 +++ .../v1alpha1/operator.aws_client.go | 90 ++++++++++ .../informers/externalversions/factory.go | 131 +++++++++++++++ .../informers/externalversions/generic.go | 62 +++++++ .../internalinterfaces/factory_interfaces.go | 38 +++++ .../operator.aws/interface.go | 46 +++++ .../v1alpha1/cloudformationtemplate.go | 89 ++++++++++ .../operator.aws/v1alpha1/interface.go | 45 +++++ .../v1alpha1/cloudformationtemplate.go | 94 +++++++++++ .../v1alpha1/expansion_generated.go | 27 +++ .../cloudformationtemplate/controller.go | 90 ++++++++++ 25 files changed, 1664 insertions(+) create mode 100644 pkg/apis/operator.aws/v1alpha1/cloudformationtemplate.go create mode 100644 pkg/apis/operator.aws/v1alpha1/zz_generated.deepcopy.go create mode 100644 pkg/client/clientset/versioned/clientset.go create mode 100644 pkg/client/clientset/versioned/doc.go create mode 100644 pkg/client/clientset/versioned/fake/clientset_generated.go create mode 100644 pkg/client/clientset/versioned/fake/doc.go create mode 100644 pkg/client/clientset/versioned/fake/register.go create mode 100644 pkg/client/clientset/versioned/scheme/doc.go create mode 100644 pkg/client/clientset/versioned/scheme/register.go create mode 100644 pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/cloudformationtemplate.go create mode 100644 pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_cloudformationtemplate.go create mode 100644 pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_operator.aws_client.go create mode 100644 pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/operator.aws_client.go create mode 100644 pkg/client/informers/externalversions/factory.go create mode 100644 pkg/client/informers/externalversions/generic.go create mode 100644 pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 pkg/client/informers/externalversions/operator.aws/interface.go create mode 100644 pkg/client/informers/externalversions/operator.aws/v1alpha1/cloudformationtemplate.go create mode 100644 pkg/client/informers/externalversions/operator.aws/v1alpha1/interface.go create mode 100644 pkg/client/listers/operator.aws/v1alpha1/cloudformationtemplate.go create mode 100644 pkg/client/listers/operator.aws/v1alpha1/expansion_generated.go create mode 100644 pkg/operator/cloudformationtemplate/controller.go diff --git a/pkg/apis/operator.aws/v1alpha1/cloudformationtemplate.go b/pkg/apis/operator.aws/v1alpha1/cloudformationtemplate.go new file mode 100644 index 000000000..7c1aadaea --- /dev/null +++ b/pkg/apis/operator.aws/v1alpha1/cloudformationtemplate.go @@ -0,0 +1,65 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CloudFormationTemplate defines the base resource +type CloudFormationTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + Data CloudFormationTemplateData `json:"data"` + Status CloudFormationTemplateStatus `json:"status"` + Output CloudFormationTemplateOutput `json:"output"` + AdditionalResources CloudFormationTemplateAdditionalResources `json:"additionalResources"` +} +// CloudFormationTemplateData defines the Data resource for CloudFormationTemplate +type CloudFormationTemplateData struct { + CloudFormationTemplateName string `json:"cloudFormationTemplateName"` + CloudFormationTemplateNamespace string `json:"cloudFormationTemplateNamespace"` + Key string `json:"key"` + Template string `json:"template"` +} + + +// CloudFormationTemplateOutput defines the output resource for CloudFormationTemplate +type CloudFormationTemplateOutput struct { + URL string `json:"url"` +} + +// CloudFormationTemplateStatus holds the status of the Cloudformation template +type CloudFormationTemplateStatus struct { + ResourceStatus string `json:"resourceStatus"` + ResourceStatusReason string `json:"resourceStatusReason"` +} + +// CloudFormationTemplateAdditionalResources holds the additional resources +type CloudFormationTemplateAdditionalResources struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CloudFormationTemplateList defines the list attribute for the CloudFormationTemplate type +type CloudFormationTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + Items []CloudFormationTemplate `json:"items"` +} + +func init() { + localSchemeBuilder.Register(addCloudFormationTemplateTypes) +} + +func addCloudFormationTemplateTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &CloudFormationTemplate{}, + &CloudFormationTemplateList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/operator.aws/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/operator.aws/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..a2fb76839 --- /dev/null +++ b/pkg/apis/operator.aws/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,152 @@ +// +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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +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 *CloudFormationTemplate) DeepCopyInto(out *CloudFormationTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Data = in.Data + out.Status = in.Status + out.Output = in.Output + out.AdditionalResources = in.AdditionalResources + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudFormationTemplate. +func (in *CloudFormationTemplate) DeepCopy() *CloudFormationTemplate { + if in == nil { + return nil + } + out := new(CloudFormationTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CloudFormationTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudFormationTemplateAdditionalResources) DeepCopyInto(out *CloudFormationTemplateAdditionalResources) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudFormationTemplateAdditionalResources. +func (in *CloudFormationTemplateAdditionalResources) DeepCopy() *CloudFormationTemplateAdditionalResources { + if in == nil { + return nil + } + out := new(CloudFormationTemplateAdditionalResources) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudFormationTemplateData) DeepCopyInto(out *CloudFormationTemplateData) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudFormationTemplateData. +func (in *CloudFormationTemplateData) DeepCopy() *CloudFormationTemplateData { + if in == nil { + return nil + } + out := new(CloudFormationTemplateData) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudFormationTemplateList) DeepCopyInto(out *CloudFormationTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CloudFormationTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudFormationTemplateList. +func (in *CloudFormationTemplateList) DeepCopy() *CloudFormationTemplateList { + if in == nil { + return nil + } + out := new(CloudFormationTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CloudFormationTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudFormationTemplateOutput) DeepCopyInto(out *CloudFormationTemplateOutput) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudFormationTemplateOutput. +func (in *CloudFormationTemplateOutput) DeepCopy() *CloudFormationTemplateOutput { + if in == nil { + return nil + } + out := new(CloudFormationTemplateOutput) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudFormationTemplateStatus) DeepCopyInto(out *CloudFormationTemplateStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudFormationTemplateStatus. +func (in *CloudFormationTemplateStatus) DeepCopy() *CloudFormationTemplateStatus { + if in == nil { + return nil + } + out := new(CloudFormationTemplateStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 000000000..0b09acca8 --- /dev/null +++ b/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,100 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package versioned + +import ( + operatorv1alpha1 "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1" + glog "github.com/golang/glog" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + OperatorV1alpha1() operatorv1alpha1.OperatorV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Operator() operatorv1alpha1.OperatorV1alpha1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + operatorV1alpha1 *operatorv1alpha1.OperatorV1alpha1Client +} + +// OperatorV1alpha1 retrieves the OperatorV1alpha1Client +func (c *Clientset) OperatorV1alpha1() operatorv1alpha1.OperatorV1alpha1Interface { + return c.operatorV1alpha1 +} + +// Deprecated: Operator retrieves the default version of OperatorClient. +// Please explicitly pick a version. +func (c *Clientset) Operator() operatorv1alpha1.OperatorV1alpha1Interface { + return c.operatorV1alpha1 +} + +// 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.operatorV1alpha1, err = operatorv1alpha1.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.operatorV1alpha1 = operatorv1alpha1.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.operatorV1alpha1 = operatorv1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/client/clientset/versioned/doc.go b/pkg/client/clientset/versioned/doc.go new file mode 100644 index 000000000..006b79214 --- /dev/null +++ b/pkg/client/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated clientset. +package versioned diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 000000000..b50d833d8 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,81 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + clientset "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned" + operatorv1alpha1 "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1" + fakeoperatorv1alpha1 "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake" + "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" +) + +// 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("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, 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{} + +// OperatorV1alpha1 retrieves the OperatorV1alpha1Client +func (c *Clientset) OperatorV1alpha1() operatorv1alpha1.OperatorV1alpha1Interface { + return &fakeoperatorv1alpha1.FakeOperatorV1alpha1{Fake: &c.Fake} +} + +// Operator retrieves the OperatorV1alpha1Client +func (c *Clientset) Operator() operatorv1alpha1.OperatorV1alpha1Interface { + return &fakeoperatorv1alpha1.FakeOperatorV1alpha1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/doc.go b/pkg/client/clientset/versioned/fake/doc.go new file mode 100644 index 000000000..0bc260bca --- /dev/null +++ b/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go new file mode 100644 index 000000000..8dbbd59aa --- /dev/null +++ b/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,54 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + operatorv1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/v1alpha1" + 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" +) + +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/kubernetes/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) { + operatorv1alpha1.AddToScheme(scheme) +} diff --git a/pkg/client/clientset/versioned/scheme/doc.go b/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 000000000..5c5c8debb --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go new file mode 100644 index 000000000..d1b720695 --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,54 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + operatorv1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/v1alpha1" + 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" +) + +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/kubernetes/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) { + operatorv1alpha1.AddToScheme(scheme) +} diff --git a/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/cloudformationtemplate.go b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/cloudformationtemplate.go new file mode 100644 index 000000000..c836b7898 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/cloudformationtemplate.go @@ -0,0 +1,157 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/v1alpha1" + scheme "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// CloudFormationTemplatesGetter has a method to return a CloudFormationTemplateInterface. +// A group's client should implement this interface. +type CloudFormationTemplatesGetter interface { + CloudFormationTemplates(namespace string) CloudFormationTemplateInterface +} + +// CloudFormationTemplateInterface has methods to work with CloudFormationTemplate resources. +type CloudFormationTemplateInterface interface { + Create(*v1alpha1.CloudFormationTemplate) (*v1alpha1.CloudFormationTemplate, error) + Update(*v1alpha1.CloudFormationTemplate) (*v1alpha1.CloudFormationTemplate, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.CloudFormationTemplate, error) + List(opts v1.ListOptions) (*v1alpha1.CloudFormationTemplateList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CloudFormationTemplate, err error) + CloudFormationTemplateExpansion +} + +// cloudFormationTemplates implements CloudFormationTemplateInterface +type cloudFormationTemplates struct { + client rest.Interface + ns string +} + +// newCloudFormationTemplates returns a CloudFormationTemplates +func newCloudFormationTemplates(c *OperatorV1alpha1Client, namespace string) *cloudFormationTemplates { + return &cloudFormationTemplates{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the cloudFormationTemplate, and returns the corresponding cloudFormationTemplate object, and an error if there is any. +func (c *cloudFormationTemplates) Get(name string, options v1.GetOptions) (result *v1alpha1.CloudFormationTemplate, err error) { + result = &v1alpha1.CloudFormationTemplate{} + err = c.client.Get(). + Namespace(c.ns). + Resource("cloudformationtemplates"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of CloudFormationTemplates that match those selectors. +func (c *cloudFormationTemplates) List(opts v1.ListOptions) (result *v1alpha1.CloudFormationTemplateList, err error) { + result = &v1alpha1.CloudFormationTemplateList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("cloudformationtemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested cloudFormationTemplates. +func (c *cloudFormationTemplates) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("cloudformationtemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a cloudFormationTemplate and creates it. Returns the server's representation of the cloudFormationTemplate, and an error, if there is any. +func (c *cloudFormationTemplates) Create(cloudFormationTemplate *v1alpha1.CloudFormationTemplate) (result *v1alpha1.CloudFormationTemplate, err error) { + result = &v1alpha1.CloudFormationTemplate{} + err = c.client.Post(). + Namespace(c.ns). + Resource("cloudformationtemplates"). + Body(cloudFormationTemplate). + Do(). + Into(result) + return +} + +// Update takes the representation of a cloudFormationTemplate and updates it. Returns the server's representation of the cloudFormationTemplate, and an error, if there is any. +func (c *cloudFormationTemplates) Update(cloudFormationTemplate *v1alpha1.CloudFormationTemplate) (result *v1alpha1.CloudFormationTemplate, err error) { + result = &v1alpha1.CloudFormationTemplate{} + err = c.client.Put(). + Namespace(c.ns). + Resource("cloudformationtemplates"). + Name(cloudFormationTemplate.Name). + Body(cloudFormationTemplate). + Do(). + Into(result) + return +} + +// Delete takes name of the cloudFormationTemplate and deletes it. Returns an error if one occurs. +func (c *cloudFormationTemplates) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("cloudformationtemplates"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *cloudFormationTemplates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("cloudformationtemplates"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched cloudFormationTemplate. +func (c *cloudFormationTemplates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CloudFormationTemplate, err error) { + result = &v1alpha1.CloudFormationTemplate{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("cloudformationtemplates"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/doc.go new file mode 100644 index 000000000..69ca30111 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/doc.go new file mode 100644 index 000000000..87a1873ed --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_cloudformationtemplate.go b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_cloudformationtemplate.go new file mode 100644 index 000000000..7eb94d6de --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_cloudformationtemplate.go @@ -0,0 +1,128 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/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" +) + +// FakeCloudFormationTemplates implements CloudFormationTemplateInterface +type FakeCloudFormationTemplates struct { + Fake *FakeOperatorV1alpha1 + ns string +} + +var cloudformationtemplatesResource = schema.GroupVersionResource{Group: "operator.aws", Version: "v1alpha1", Resource: "cloudformationtemplates"} + +var cloudformationtemplatesKind = schema.GroupVersionKind{Group: "operator.aws", Version: "v1alpha1", Kind: "CloudFormationTemplate"} + +// Get takes name of the cloudFormationTemplate, and returns the corresponding cloudFormationTemplate object, and an error if there is any. +func (c *FakeCloudFormationTemplates) Get(name string, options v1.GetOptions) (result *v1alpha1.CloudFormationTemplate, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(cloudformationtemplatesResource, c.ns, name), &v1alpha1.CloudFormationTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CloudFormationTemplate), err +} + +// List takes label and field selectors, and returns the list of CloudFormationTemplates that match those selectors. +func (c *FakeCloudFormationTemplates) List(opts v1.ListOptions) (result *v1alpha1.CloudFormationTemplateList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(cloudformationtemplatesResource, cloudformationtemplatesKind, c.ns, opts), &v1alpha1.CloudFormationTemplateList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.CloudFormationTemplateList{} + for _, item := range obj.(*v1alpha1.CloudFormationTemplateList).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 cloudFormationTemplates. +func (c *FakeCloudFormationTemplates) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(cloudformationtemplatesResource, c.ns, opts)) + +} + +// Create takes the representation of a cloudFormationTemplate and creates it. Returns the server's representation of the cloudFormationTemplate, and an error, if there is any. +func (c *FakeCloudFormationTemplates) Create(cloudFormationTemplate *v1alpha1.CloudFormationTemplate) (result *v1alpha1.CloudFormationTemplate, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(cloudformationtemplatesResource, c.ns, cloudFormationTemplate), &v1alpha1.CloudFormationTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CloudFormationTemplate), err +} + +// Update takes the representation of a cloudFormationTemplate and updates it. Returns the server's representation of the cloudFormationTemplate, and an error, if there is any. +func (c *FakeCloudFormationTemplates) Update(cloudFormationTemplate *v1alpha1.CloudFormationTemplate) (result *v1alpha1.CloudFormationTemplate, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(cloudformationtemplatesResource, c.ns, cloudFormationTemplate), &v1alpha1.CloudFormationTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CloudFormationTemplate), err +} + +// Delete takes name of the cloudFormationTemplate and deletes it. Returns an error if one occurs. +func (c *FakeCloudFormationTemplates) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(cloudformationtemplatesResource, c.ns, name), &v1alpha1.CloudFormationTemplate{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCloudFormationTemplates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(cloudformationtemplatesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.CloudFormationTemplateList{}) + return err +} + +// Patch applies the patch and returns the patched cloudFormationTemplate. +func (c *FakeCloudFormationTemplates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CloudFormationTemplate, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(cloudformationtemplatesResource, c.ns, name, data, subresources...), &v1alpha1.CloudFormationTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CloudFormationTemplate), err +} diff --git a/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_operator.aws_client.go b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_operator.aws_client.go new file mode 100644 index 000000000..756abacea --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_operator.aws_client.go @@ -0,0 +1,40 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeOperatorV1alpha1 struct { + *testing.Fake +} + +func (c *FakeOperatorV1alpha1) CloudFormationTemplates(namespace string) v1alpha1.CloudFormationTemplateInterface { + return &FakeCloudFormationTemplates{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeOperatorV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..b6a1ed7e0 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type CloudFormationTemplateExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/operator.aws_client.go b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/operator.aws_client.go new file mode 100644 index 000000000..60824d532 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/operator.aws_client.go @@ -0,0 +1,90 @@ +/* +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/v1alpha1" + "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type OperatorV1alpha1Interface interface { + RESTClient() rest.Interface + CloudFormationTemplatesGetter +} + +// OperatorV1alpha1Client is used to interact with features provided by the operator.aws group. +type OperatorV1alpha1Client struct { + restClient rest.Interface +} + +func (c *OperatorV1alpha1Client) CloudFormationTemplates(namespace string) CloudFormationTemplateInterface { + return newCloudFormationTemplates(c, namespace) +} + +// NewForConfig creates a new OperatorV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*OperatorV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &OperatorV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new OperatorV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *OperatorV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new OperatorV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *OperatorV1alpha1Client { + return &OperatorV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.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 *OperatorV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go new file mode 100644 index 000000000..9f3b44a66 --- /dev/null +++ b/pkg/client/informers/externalversions/factory.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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned" + internalinterfaces "github.com/christopherhein/aws-operator/pkg/client/informers/externalversions/internalinterfaces" + operator_aws "github.com/christopherhein/aws-operator/pkg/client/informers/externalversions/operator.aws" + 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" +) + +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 + + Operator() operator_aws.Interface +} + +func (f *sharedInformerFactory) Operator() operator_aws.Interface { + return operator_aws.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go new file mode 100644 index 000000000..faec7cce0 --- /dev/null +++ b/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + v1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// 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=operator.aws, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("cloudformationtemplates"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Operator().V1alpha1().CloudFormationTemplates().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 000000000..7c65da333 --- /dev/null +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +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/pkg/client/informers/externalversions/operator.aws/interface.go b/pkg/client/informers/externalversions/operator.aws/interface.go new file mode 100644 index 000000000..416ca07ba --- /dev/null +++ b/pkg/client/informers/externalversions/operator.aws/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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package operator + +import ( + internalinterfaces "github.com/christopherhein/aws-operator/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/christopherhein/aws-operator/pkg/client/informers/externalversions/operator.aws/v1alpha1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.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} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/operator.aws/v1alpha1/cloudformationtemplate.go b/pkg/client/informers/externalversions/operator.aws/v1alpha1/cloudformationtemplate.go new file mode 100644 index 000000000..d6906a474 --- /dev/null +++ b/pkg/client/informers/externalversions/operator.aws/v1alpha1/cloudformationtemplate.go @@ -0,0 +1,89 @@ +/* +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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + operator_aws_v1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/v1alpha1" + versioned "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned" + internalinterfaces "github.com/christopherhein/aws-operator/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/christopherhein/aws-operator/pkg/client/listers/operator.aws/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" +) + +// CloudFormationTemplateInformer provides access to a shared informer and lister for +// CloudFormationTemplates. +type CloudFormationTemplateInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.CloudFormationTemplateLister +} + +type cloudFormationTemplateInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCloudFormationTemplateInformer constructs a new informer for CloudFormationTemplate 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 NewCloudFormationTemplateInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCloudFormationTemplateInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCloudFormationTemplateInformer constructs a new informer for CloudFormationTemplate 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 NewFilteredCloudFormationTemplateInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OperatorV1alpha1().CloudFormationTemplates(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OperatorV1alpha1().CloudFormationTemplates(namespace).Watch(options) + }, + }, + &operator_aws_v1alpha1.CloudFormationTemplate{}, + resyncPeriod, + indexers, + ) +} + +func (f *cloudFormationTemplateInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCloudFormationTemplateInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *cloudFormationTemplateInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&operator_aws_v1alpha1.CloudFormationTemplate{}, f.defaultInformer) +} + +func (f *cloudFormationTemplateInformer) Lister() v1alpha1.CloudFormationTemplateLister { + return v1alpha1.NewCloudFormationTemplateLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/operator.aws/v1alpha1/interface.go b/pkg/client/informers/externalversions/operator.aws/v1alpha1/interface.go new file mode 100644 index 000000000..bab8742c2 --- /dev/null +++ b/pkg/client/informers/externalversions/operator.aws/v1alpha1/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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/christopherhein/aws-operator/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // CloudFormationTemplates returns a CloudFormationTemplateInformer. + CloudFormationTemplates() CloudFormationTemplateInformer +} + +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} +} + +// CloudFormationTemplates returns a CloudFormationTemplateInformer. +func (v *version) CloudFormationTemplates() CloudFormationTemplateInformer { + return &cloudFormationTemplateInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/listers/operator.aws/v1alpha1/cloudformationtemplate.go b/pkg/client/listers/operator.aws/v1alpha1/cloudformationtemplate.go new file mode 100644 index 000000000..0364efd7d --- /dev/null +++ b/pkg/client/listers/operator.aws/v1alpha1/cloudformationtemplate.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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// CloudFormationTemplateLister helps list CloudFormationTemplates. +type CloudFormationTemplateLister interface { + // List lists all CloudFormationTemplates in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.CloudFormationTemplate, err error) + // CloudFormationTemplates returns an object that can list and get CloudFormationTemplates. + CloudFormationTemplates(namespace string) CloudFormationTemplateNamespaceLister + CloudFormationTemplateListerExpansion +} + +// cloudFormationTemplateLister implements the CloudFormationTemplateLister interface. +type cloudFormationTemplateLister struct { + indexer cache.Indexer +} + +// NewCloudFormationTemplateLister returns a new CloudFormationTemplateLister. +func NewCloudFormationTemplateLister(indexer cache.Indexer) CloudFormationTemplateLister { + return &cloudFormationTemplateLister{indexer: indexer} +} + +// List lists all CloudFormationTemplates in the indexer. +func (s *cloudFormationTemplateLister) List(selector labels.Selector) (ret []*v1alpha1.CloudFormationTemplate, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.CloudFormationTemplate)) + }) + return ret, err +} + +// CloudFormationTemplates returns an object that can list and get CloudFormationTemplates. +func (s *cloudFormationTemplateLister) CloudFormationTemplates(namespace string) CloudFormationTemplateNamespaceLister { + return cloudFormationTemplateNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// CloudFormationTemplateNamespaceLister helps list and get CloudFormationTemplates. +type CloudFormationTemplateNamespaceLister interface { + // List lists all CloudFormationTemplates in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.CloudFormationTemplate, err error) + // Get retrieves the CloudFormationTemplate from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.CloudFormationTemplate, error) + CloudFormationTemplateNamespaceListerExpansion +} + +// cloudFormationTemplateNamespaceLister implements the CloudFormationTemplateNamespaceLister +// interface. +type cloudFormationTemplateNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all CloudFormationTemplates in the indexer for a given namespace. +func (s cloudFormationTemplateNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.CloudFormationTemplate, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.CloudFormationTemplate)) + }) + return ret, err +} + +// Get retrieves the CloudFormationTemplate from the indexer for a given namespace and name. +func (s cloudFormationTemplateNamespaceLister) Get(name string) (*v1alpha1.CloudFormationTemplate, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("cloudformationtemplate"), name) + } + return obj.(*v1alpha1.CloudFormationTemplate), nil +} diff --git a/pkg/client/listers/operator.aws/v1alpha1/expansion_generated.go b/pkg/client/listers/operator.aws/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..af75ff589 --- /dev/null +++ b/pkg/client/listers/operator.aws/v1alpha1/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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// CloudFormationTemplateListerExpansion allows custom methods to be added to +// CloudFormationTemplateLister. +type CloudFormationTemplateListerExpansion interface{} + +// CloudFormationTemplateNamespaceListerExpansion allows custom methods to be added to +// CloudFormationTemplateNamespaceLister. +type CloudFormationTemplateNamespaceListerExpansion interface{} diff --git a/pkg/operator/cloudformationtemplate/controller.go b/pkg/operator/cloudformationtemplate/controller.go new file mode 100644 index 000000000..ccc5f23f8 --- /dev/null +++ b/pkg/operator/cloudformationtemplate/controller.go @@ -0,0 +1,90 @@ +// >>>>>>> DO NOT EDIT THIS FILE <<<<<<<<<< +// This file is autogenerated via `aws-operator generate` +// If you'd like the change anything about this file make edits to the .templ +// file in the pkg/codegen/assets directory. + +package cloudformationtemplate + +import ( + "reflect" + + "github.com/christopherhein/aws-operator/pkg/config" + opkit "github.com/christopherhein/operator-kit" + apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + "k8s.io/client-go/tools/cache" + + awsapi "github.com/christopherhein/aws-operator/pkg/apis/operator.aws" + awsV1alpha1 "github.com/christopherhein/aws-operator/pkg/apis/operator.aws/v1alpha1" + awsclient "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1" + "github.com/christopherhein/aws-operator/pkg/customizations/cloudformationtemplate" +) + +// Resource is the object store definition +var Resource = opkit.CustomResource{ + Name: "cloudformationtemplate", + Plural: "cloudformationtemplates", + Group: awsapi.GroupName, + Version: awsapi.Version, + Scope: apiextensionsv1beta1.NamespaceScoped, + Kind: reflect.TypeOf(awsV1alpha1.CloudFormationTemplate{}).Name(), + ShortNames: []string{ + "cft", + "cfts", + "cfn", + "cfns", + "cloudformation", + }, +} + +// Controller represents a controller object for object store custom resources +type Controller struct { + config *config.Config + context *opkit.Context + awsclientset awsclient.OperatorV1alpha1Interface + topicARN string +} + +type data struct { + Obj *awsV1alpha1.CloudFormationTemplate + Config *config.Config +} + +// NewController create controller for watching object store custom resources created +func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.OperatorV1alpha1Interface) *Controller { + return &Controller{ + config: config, + context: context, + awsclientset: awsclientset, + } +} + +// StartWatch watches for instances of Object Store custom resources and acts on them +func (c *Controller) StartWatch(namespace string, stopCh chan struct{}) error { + resourceHandlers := cache.ResourceEventHandlerFuncs{ + AddFunc: c.onAdd, + UpdateFunc: c.onUpdate, + DeleteFunc: c.onDelete, + } + + restClient := c.awsclientset.RESTClient() + watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient) + go watcher.Watch(&awsV1alpha1.CloudFormationTemplate{}, stopCh) + + return nil +} + +func (c *Controller) onAdd(obj interface{}) { + s := obj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy() + cloudformationtemplate.OnAdd(c.config, s) +} + +func (c *Controller) onUpdate(oldObj, newObj interface{}) { + oo := oldObj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy() + no := newObj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy() + cloudformationtemplate.OnUpdate(c.config, oo, no) +} + +func (c *Controller) onDelete(obj interface{}) { + s := obj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy() + cloudformationtemplate.OnDelete(c.config, s) +} From 2a1beceea3bd70c9ce29ccfe9513bd673e5c0180 Mon Sep 17 00:00:00 2001 From: Christopher Hein Date: Wed, 1 Aug 2018 21:01:03 -0700 Subject: [PATCH 2/2] Adding The CFT Resource Objects **Why:** * These are the files that generate the code gened libraries **This change addresses the need by:** * closes #8 --- .../cloudformationtemplates/dynamodb.yaml | 100 ++++++++++++ .../cloudformationtemplates/s3bucket.yaml | 148 ++++++++++++++++++ .../cloudformationtemplates/sqsqueue.yaml | 100 ++++++++++++ models/cloudformationtemplate.yaml | 50 ++++++ 4 files changed, 398 insertions(+) create mode 100644 examples/cloudformationtemplates/dynamodb.yaml create mode 100644 examples/cloudformationtemplates/s3bucket.yaml create mode 100644 examples/cloudformationtemplates/sqsqueue.yaml create mode 100644 models/cloudformationtemplate.yaml diff --git a/examples/cloudformationtemplates/dynamodb.yaml b/examples/cloudformationtemplates/dynamodb.yaml new file mode 100644 index 000000000..be3a1c5e6 --- /dev/null +++ b/examples/cloudformationtemplates/dynamodb.yaml @@ -0,0 +1,100 @@ +apiVersion: operator.aws/v1alpha1 +kind: CloudFormationTemplate +metadata: + name: dynamodb +data: + key: dynamodb.yaml + template: | + AWSTemplateFormatVersion: 2010-09-09 + Description: 'AWS Operator - Amazon DynamoDB' + Parameters: + Namespace: + Description: >- + This is the namespace for the Kubernetes object. + Type: String + ResourceVersion: + Type: String + Description: >- + This is the resource version for the Kubernetes object. + ResourceName: + Description: >- + This is the resource name for the Kubernetes object + Type: String + ClusterName: + Description: >- + This is the cluster name for the operator + Type: String + TableName: + Description: >- + Must contain only lowercase letters, numbers and hyphens. + Type: String + HashAttributeName: + Type: String + Description: Name of the Hash key + HashAttributeType: + Type: String + AllowedValues: + - S + - N + - B + Default: "S" + Description: AttributeType for Hash key + RangeAttributeName: + Type: String + Description: Name of the Range key + RangeAttributeType: + Type: String + AllowedValues: + - S + - N + - B + Default: "S" + Description: AttributeType for the Range key + ReadCapacityUnits: + Type: String + Description: Read ReadCapacity Units + Default: "5" + WriteCapacityUnits: + Type: String + Description: Write Capacity Units + Default: "5" + Resources: + DynamoDBTable: + Type: "AWS::DynamoDB::Table" + Properties: + TableName: !Ref TableName + KeySchema: + - + AttributeName: !Ref HashAttributeName + KeyType: "HASH" + - + AttributeName: !Ref RangeAttributeName + KeyType: "RANGE" + AttributeDefinitions: + - + AttributeName: !Ref HashAttributeName + AttributeType: "S" + - + AttributeName: !Ref RangeAttributeName + AttributeType: "S" + ProvisionedThroughput: + ReadCapacityUnits: !Ref ReadCapacityUnits + WriteCapacityUnits: !Ref WriteCapacityUnits + Tags: + - Key: Namespace + Value: !Ref Namespace + - Key: ResourceVersion + Value: !Ref ResourceVersion + - Key: ResourceName + Value: !Ref ResourceName + - Key: ClusterName + Value: !Ref ClusterName + - Key: Heritage + Value: operator.aws + Outputs: + TableName: + Description: Name of the DynamoDB Table + Value: !Ref DynamoDBTable + TableArn: + Description: Arn of the DynamoDB Table + Value: !GetAtt DynamoDBTable.Arn diff --git a/examples/cloudformationtemplates/s3bucket.yaml b/examples/cloudformationtemplates/s3bucket.yaml new file mode 100644 index 000000000..dce11231e --- /dev/null +++ b/examples/cloudformationtemplates/s3bucket.yaml @@ -0,0 +1,148 @@ +apiVersion: operator.aws/v1alpha1 +kind: CloudFormationTemplate +metadata: + name: s3bucket +data: + key: s3bucket.yaml + template: | + AWSTemplateFormatVersion: 2010-09-09 + Description: 'AWS Operator - Amazon S3 Bucket' + Parameters: + Namespace: + Description: >- + This is the namespace for the Kubernetes object. + Type: String + ResourceVersion: + Type: String + Description: >- + This is the resource version for the Kubernetes object. + ResourceName: + Description: >- + This is the resource name for the Kubernetes object + Type: String + ClusterName: + Description: >- + This is the cluster name for the operator + Type: String + BucketName: + Description: >- + Must contain only lowercase letters, numbers, periods (.), and hyphens + (-),Cannot end in numbers + Type: String + Default: apps3bucket + LoggingPrefix: + Description: >- + Must contain only lowercase letters, numbers, periods (.), and hyphens + (-),Cannot end in numbers + Type: String + Default: Archive + EnableLogging: + Description: enable or discable S3 logging + Type: String + AllowedValues: + - 'true' + - 'false' + Default: 'true' + EnableGlacierLifeCycle: + Description: enable archiving to Glacier Storage + Type: String + AllowedValues: + - 'true' + - 'false' + Default: 'false' + GlacierLifeCycleTransitionInDays: + Description: Define how many days objects should exist before being moved to Glacier + Type: String + Default: '0' + EnableVersioning: + Description: enable versioning + Type: String + AllowedValues: + - 'true' + - 'false' + Default: 'false' + LifeCyclePrefix: + Description: >- + Must contain only lowercase letters, numbers, periods (.), and hyphens + (-),Cannot end in numbers + Type: String + Default: Archive + BucketAccessControl: + Description: define if the bucket can be accessed from public or private locations + Type: String + AllowedValues: + - Private + - PublicRead + - PublicReadWrite + - AuthenticatedRead + - LogDeliveryWrite + - BucketOwnerRead + - BucketOwnerFullControl + - AwsExecRead + Default: "Private" + Mappings: {} + Conditions: + UseLogging: !Equals + - !Ref EnableLogging + - 'true' + UseGlacierLifeCycle: !Equals + - !Ref EnableGlacierLifeCycle + - 'true' + UseVersioning: !Equals + - !Ref EnableVersioning + - 'true' + Resources: + S3bucket: + Type: 'AWS::S3::Bucket' + Properties: + BucketName: !Ref BucketName + AccessControl: !Ref BucketAccessControl + LifecycleConfiguration: + Rules: + - Id: GlacierRule + Prefix: !Ref LifeCyclePrefix + Status: Enabled + ExpirationInDays: '365' + Transitions: + - TransitionInDays: !Ref GlacierLifeCycleTransitionInDays + StorageClass: Glacier + LoggingConfiguration: !If + - UseLogging + - DestinationBucketName: !Ref LoggingBucket + LogFilePrefix: !Ref LoggingPrefix + - !Ref 'AWS::NoValue' + Tags: + - Key: Namespace + Value: !Ref Namespace + - Key: ResourceVersion + Value: !Ref ResourceVersion + - Key: ResourceName + Value: !Ref ResourceName + - Key: ClusterName + Value: !Ref ClusterName + - Key: Heritage + Value: operator.aws + VersioningConfiguration: !If + - UseVersioning + - Status: Enabled + - !Ref 'AWS::NoValue' + DeletionPolicy: Retain + LoggingBucket: + Condition: UseLogging + Type: 'AWS::S3::Bucket' + DeletionPolicy: Retain + Properties: + AccessControl: LogDeliveryWrite + BucketName: !Join + - '' + - - !Ref BucketName + - logging + Outputs: + BucketName: + Value: !Ref S3bucket + Description: Name of the sample Amazon S3 bucket. + BucketArn: + Value: !GetAtt + - S3bucket + - Arn + Description: Name of the Amazon S3 bucket diff --git a/examples/cloudformationtemplates/sqsqueue.yaml b/examples/cloudformationtemplates/sqsqueue.yaml new file mode 100644 index 000000000..b8634773c --- /dev/null +++ b/examples/cloudformationtemplates/sqsqueue.yaml @@ -0,0 +1,100 @@ +apiVersion: operator.aws/v1alpha1 +kind: CloudFormationTemplate +metadata: + name: sqsqueue +data: + key: sqsqueue.yaml + template: | + AWSTemplateFormatVersion: 2010-09-09 + Description: 'AWS Operator - Amazon DynamoDB' + Parameters: + Namespace: + Description: >- + This is the namespace for the Kubernetes object. + Type: String + ResourceVersion: + Type: String + Description: >- + This is the resource version for the Kubernetes object. + ResourceName: + Description: >- + This is the resource name for the Kubernetes object + Type: String + ClusterName: + Description: >- + This is the cluster name for the operator + Type: String + TableName: + Description: >- + Must contain only lowercase letters, numbers and hyphens. + Type: String + HashAttributeName: + Type: String + Description: Name of the Hash key + HashAttributeType: + Type: String + AllowedValues: + - S + - N + - B + Default: "S" + Description: AttributeType for Hash key + RangeAttributeName: + Type: String + Description: Name of the Range key + RangeAttributeType: + Type: String + AllowedValues: + - S + - N + - B + Default: "S" + Description: AttributeType for the Range key + ReadCapacityUnits: + Type: String + Description: Read ReadCapacity Units + Default: "5" + WriteCapacityUnits: + Type: String + Description: Write Capacity Units + Default: "5" + Resources: + DynamoDBTable: + Type: "AWS::DynamoDB::Table" + Properties: + TableName: !Ref TableName + KeySchema: + - + AttributeName: !Ref HashAttributeName + KeyType: "HASH" + - + AttributeName: !Ref RangeAttributeName + KeyType: "RANGE" + AttributeDefinitions: + - + AttributeName: !Ref HashAttributeName + AttributeType: "S" + - + AttributeName: !Ref RangeAttributeName + AttributeType: "S" + ProvisionedThroughput: + ReadCapacityUnits: !Ref ReadCapacityUnits + WriteCapacityUnits: !Ref WriteCapacityUnits + Tags: + - Key: Namespace + Value: !Ref Namespace + - Key: ResourceVersion + Value: !Ref ResourceVersion + - Key: ResourceName + Value: !Ref ResourceName + - Key: ClusterName + Value: !Ref ClusterName + - Key: Heritage + Value: operator.aws + Outputs: + TableName: + Description: Name of the DynamoDB Table + Value: !Ref DynamoDBTable + TableArn: + Description: Arn of the DynamoDB Table + Value: !GetAtt DynamoDBTable.Arn diff --git a/models/cloudformationtemplate.yaml b/models/cloudformationtemplate.yaml new file mode 100644 index 000000000..c4aa3c3f1 --- /dev/null +++ b/models/cloudformationtemplate.yaml @@ -0,0 +1,50 @@ +apiVersion: operator.aws/v1alpha1 +kind: ModelDefinition +metadata: + name: CloudFormationTemplateResource +spec: + kind: CloudFormationTemplate + type: Data + queue: false + useCloudFormation: false + resource: + name: cloudformationtemplate + plural: cloudformationtemplates + shortNames: + - name: cft + - name: cfts + - name: cfn + - name: cfns + - name: cloudformation + body: + schema: + title: CloudFormationTemplate + type: object + properties: + - key: key + type: string + description: | + Key is the S3 Key you want to store this as. + structKey: Key + - key: template + type: string + description: | + Template represents the cloudformation raw temple in either JSON or + YAML but represented as a string type. + structKey: Template + output: + schema: + type: object + properties: + - key: url + type: string + description: | + This is the finally URL for the asset. + structKey: URL + templateKey: URL + + customizations: + package: github.com/christopherhein/aws-operator/pkg/customizations/cloudformationtemplate + add: cloudformationtemplate.OnAdd + update: cloudformationtemplate.OnUpdate + delete: cloudformationtemplate.OnDelete