diff --git a/.gitignore b/.gitignore index d3d0155..3ed89e6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ vendor Gopkg.lock .vscode + +.DS_Store \ No newline at end of file diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 4de9cb6..e018c03 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -64,7 +64,7 @@ generate_client "split" "v1alpha1,v1alpha2,v1alpha3" echo "" echo "##### Generating access client ######" -generate_client "access" "v1alpha1,v1alpha2" +generate_client "access" "v1alpha1,v1alpha2,v1alpha3" echo "" echo "##### Generating metrics client ######" diff --git a/pkg/apis/access/v1alpha3/doc.go b/pkg/apis/access/v1alpha3/doc.go new file mode 100644 index 0000000..a07f00b --- /dev/null +++ b/pkg/apis/access/v1alpha3/doc.go @@ -0,0 +1,4 @@ +// +k8s:deepcopy-gen=package +// +groupName=access.smi-spec.io + +package v1alpha3 diff --git a/pkg/apis/access/v1alpha3/register.go b/pkg/apis/access/v1alpha3/register.go new file mode 100644 index 0000000..9261072 --- /dev/null +++ b/pkg/apis/access/v1alpha3/register.go @@ -0,0 +1,48 @@ +package v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + ts "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access" +) + +// SchemeGroupVersion is the identifier for the API which includes +// the name of the group and the version of the API +var SchemeGroupVersion = schema.GroupVersion{ + Group: ts.GroupName, + Version: "v1alpha3", +} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder collects functions that add things to a scheme. It's to allow + // code to compile without explicitly referencing generated types. You should + // declare one in each package that will have generated deep copy or conversion + // functions. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme applies all the stored functions to the scheme. A non-nil error + // indicates that one function failed and the attempt was abandoned. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &TrafficTarget{}, + &TrafficTargetList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/access/v1alpha3/traffic_target.go b/pkg/apis/access/v1alpha3/traffic_target.go new file mode 100644 index 0000000..f330a98 --- /dev/null +++ b/pkg/apis/access/v1alpha3/traffic_target.go @@ -0,0 +1,78 @@ +package v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TrafficTarget associates a set of traffic definitions (rules) with a service identity which is allocated to a group of pods. +// Access is controlled via referenced TrafficSpecs and by a list of source service identities. +// * If a pod which holds the referenced service identity makes a call to the destination on one of the defined routes then access +// will be allowed +// * Any pod which attempts to connect and is not in the defined list of sources will be denied +// * Any pod which is in the defined list, but attempts to connect on a route which is not in the list of the +// TrafficSpecs will be denied +type TrafficTarget struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec TrafficTargetSpec `json:"spec"` +} + +// TrafficTargetSpec is the specification of a TrafficTarget +type TrafficTargetSpec struct { + // Selector is the pod or group of pods to allow ingress traffic + Destination IdentityBindingSubject `json:"destination"` + + // Sources are the pod or group of pods to allow ingress traffic + Sources []IdentityBindingSubject `json:"sources,omitempty"` + + // Rules are the traffic rules to allow (HTTPRoutes | TCPRoute) + Rules []TrafficTargetRule `json:"rules,omitempty"` +} + +// TrafficTargetRule is the TrafficSpec to allow for a TrafficTarget +type TrafficTargetRule struct { + // Kind is the kind of TrafficSpec to allow + Kind string `json:"kind"` + + // Name of the TrafficSpec to use + Name string `json:"name"` + + // Matches is a list of TrafficSpec routes to allow traffic for + // +optional + Matches []string `json:"matches,omitempty"` +} + +// IdentityBindingSubject is a Kubernetes objects which should be allowed access to the TrafficTarget +type IdentityBindingSubject struct { + // Kind is the type of Subject to allow ingress (ServiceAccount | Group) + Kind string `json:"kind"` + + // Name of the Subject, i.e. ServiceAccountName + Name string `json:"name"` + + // Namespace where the Subject is deployed + // +optional + Namespace string `json:"namespace,omitempty"` + + // Port defines a TCP port to apply the TrafficTarget to + // +optional + Port *int `json:"port,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +// TrafficTargetList satisfy K8s code gen requirements +type TrafficTargetList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []TrafficTarget `json:"items"` +} diff --git a/pkg/apis/access/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/access/v1alpha3/zz_generated.deepcopy.go new file mode 100644 index 0000000..a1b2a85 --- /dev/null +++ b/pkg/apis/access/v1alpha3/zz_generated.deepcopy.go @@ -0,0 +1,156 @@ +// +build !ignore_autogenerated + +/* +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 v1alpha3 + +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 *IdentityBindingSubject) DeepCopyInto(out *IdentityBindingSubject) { + *out = *in + if in.Port != nil { + in, out := &in.Port, &out.Port + *out = new(int) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IdentityBindingSubject. +func (in *IdentityBindingSubject) DeepCopy() *IdentityBindingSubject { + if in == nil { + return nil + } + out := new(IdentityBindingSubject) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TrafficTarget) DeepCopyInto(out *TrafficTarget) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTarget. +func (in *TrafficTarget) DeepCopy() *TrafficTarget { + if in == nil { + return nil + } + out := new(TrafficTarget) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TrafficTarget) 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 *TrafficTargetList) DeepCopyInto(out *TrafficTargetList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTargetList. +func (in *TrafficTargetList) DeepCopy() *TrafficTargetList { + if in == nil { + return nil + } + out := new(TrafficTargetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TrafficTargetList) 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 *TrafficTargetRule) DeepCopyInto(out *TrafficTargetRule) { + *out = *in + if in.Matches != nil { + in, out := &in.Matches, &out.Matches + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTargetRule. +func (in *TrafficTargetRule) DeepCopy() *TrafficTargetRule { + if in == nil { + return nil + } + out := new(TrafficTargetRule) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TrafficTargetSpec) DeepCopyInto(out *TrafficTargetSpec) { + *out = *in + in.Destination.DeepCopyInto(&out.Destination) + if in.Sources != nil { + in, out := &in.Sources, &out.Sources + *out = make([]IdentityBindingSubject, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Rules != nil { + in, out := &in.Rules, &out.Rules + *out = make([]TrafficTargetRule, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTargetSpec. +func (in *TrafficTargetSpec) DeepCopy() *TrafficTargetSpec { + if in == nil { + return nil + } + out := new(TrafficTargetSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/gen/client/access/clientset/versioned/clientset.go b/pkg/gen/client/access/clientset/versioned/clientset.go index 1396b49..c20546d 100644 --- a/pkg/gen/client/access/clientset/versioned/clientset.go +++ b/pkg/gen/client/access/clientset/versioned/clientset.go @@ -21,6 +21,7 @@ import ( accessv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha1" accessv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2" + accessv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -30,6 +31,7 @@ type Interface interface { Discovery() discovery.DiscoveryInterface AccessV1alpha1() accessv1alpha1.AccessV1alpha1Interface AccessV1alpha2() accessv1alpha2.AccessV1alpha2Interface + AccessV1alpha3() accessv1alpha3.AccessV1alpha3Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -38,6 +40,7 @@ type Clientset struct { *discovery.DiscoveryClient accessV1alpha1 *accessv1alpha1.AccessV1alpha1Client accessV1alpha2 *accessv1alpha2.AccessV1alpha2Client + accessV1alpha3 *accessv1alpha3.AccessV1alpha3Client } // AccessV1alpha1 retrieves the AccessV1alpha1Client @@ -50,6 +53,11 @@ func (c *Clientset) AccessV1alpha2() accessv1alpha2.AccessV1alpha2Interface { return c.accessV1alpha2 } +// AccessV1alpha3 retrieves the AccessV1alpha3Client +func (c *Clientset) AccessV1alpha3() accessv1alpha3.AccessV1alpha3Interface { + return c.accessV1alpha3 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -79,6 +87,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.accessV1alpha3, err = accessv1alpha3.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -93,6 +105,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.accessV1alpha1 = accessv1alpha1.NewForConfigOrDie(c) cs.accessV1alpha2 = accessv1alpha2.NewForConfigOrDie(c) + cs.accessV1alpha3 = accessv1alpha3.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -103,6 +116,7 @@ func New(c rest.Interface) *Clientset { var cs Clientset cs.accessV1alpha1 = accessv1alpha1.New(c) cs.accessV1alpha2 = accessv1alpha2.New(c) + cs.accessV1alpha3 = accessv1alpha3.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/gen/client/access/clientset/versioned/fake/clientset_generated.go b/pkg/gen/client/access/clientset/versioned/fake/clientset_generated.go index 9dbe2aa..03d5fa5 100644 --- a/pkg/gen/client/access/clientset/versioned/fake/clientset_generated.go +++ b/pkg/gen/client/access/clientset/versioned/fake/clientset_generated.go @@ -22,6 +22,8 @@ import ( fakeaccessv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha1/fake" accessv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2" fakeaccessv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake" + accessv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3" + fakeaccessv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -85,3 +87,8 @@ func (c *Clientset) AccessV1alpha1() accessv1alpha1.AccessV1alpha1Interface { func (c *Clientset) AccessV1alpha2() accessv1alpha2.AccessV1alpha2Interface { return &fakeaccessv1alpha2.FakeAccessV1alpha2{Fake: &c.Fake} } + +// AccessV1alpha3 retrieves the AccessV1alpha3Client +func (c *Clientset) AccessV1alpha3() accessv1alpha3.AccessV1alpha3Interface { + return &fakeaccessv1alpha3.FakeAccessV1alpha3{Fake: &c.Fake} +} diff --git a/pkg/gen/client/access/clientset/versioned/fake/register.go b/pkg/gen/client/access/clientset/versioned/fake/register.go index a791177..f843bc0 100644 --- a/pkg/gen/client/access/clientset/versioned/fake/register.go +++ b/pkg/gen/client/access/clientset/versioned/fake/register.go @@ -19,6 +19,7 @@ package fake import ( accessv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha1" accessv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" + accessv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -32,6 +33,7 @@ var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ accessv1alpha1.AddToScheme, accessv1alpha2.AddToScheme, + accessv1alpha3.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/gen/client/access/clientset/versioned/scheme/register.go b/pkg/gen/client/access/clientset/versioned/scheme/register.go index c83fea7..b49b98a 100644 --- a/pkg/gen/client/access/clientset/versioned/scheme/register.go +++ b/pkg/gen/client/access/clientset/versioned/scheme/register.go @@ -19,6 +19,7 @@ package scheme import ( accessv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha1" accessv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" + accessv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -32,6 +33,7 @@ var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ accessv1alpha1.AddToScheme, accessv1alpha2.AddToScheme, + accessv1alpha3.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/access_client.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/access_client.go new file mode 100644 index 0000000..221085a --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/access_client.go @@ -0,0 +1,87 @@ +/* +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 v1alpha3 + +import ( + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3" + "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type AccessV1alpha3Interface interface { + RESTClient() rest.Interface + TrafficTargetsGetter +} + +// AccessV1alpha3Client is used to interact with features provided by the access.smi-spec.io group. +type AccessV1alpha3Client struct { + restClient rest.Interface +} + +func (c *AccessV1alpha3Client) TrafficTargets(namespace string) TrafficTargetInterface { + return newTrafficTargets(c, namespace) +} + +// NewForConfig creates a new AccessV1alpha3Client for the given config. +func NewForConfig(c *rest.Config) (*AccessV1alpha3Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &AccessV1alpha3Client{client}, nil +} + +// NewForConfigOrDie creates a new AccessV1alpha3Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AccessV1alpha3Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AccessV1alpha3Client for the given RESTClient. +func New(c rest.Interface) *AccessV1alpha3Client { + return &AccessV1alpha3Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha3.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + 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 *AccessV1alpha3Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/doc.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/doc.go new file mode 100644 index 0000000..3207da3 --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/doc.go @@ -0,0 +1,18 @@ +/* +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 v1alpha3 diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/doc.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/doc.go new file mode 100644 index 0000000..3c48772 --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/doc.go @@ -0,0 +1,18 @@ +/* +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/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/fake_access_client.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/fake_access_client.go new file mode 100644 index 0000000..bbc7c47 --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/fake_access_client.go @@ -0,0 +1,38 @@ +/* +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 ( + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAccessV1alpha3 struct { + *testing.Fake +} + +func (c *FakeAccessV1alpha3) TrafficTargets(namespace string) v1alpha3.TrafficTargetInterface { + return &FakeTrafficTargets{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAccessV1alpha3) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/fake_traffictarget.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/fake_traffictarget.go new file mode 100644 index 0000000..08b9aae --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/fake/fake_traffictarget.go @@ -0,0 +1,128 @@ +/* +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 ( + "context" + + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3" + 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" +) + +// FakeTrafficTargets implements TrafficTargetInterface +type FakeTrafficTargets struct { + Fake *FakeAccessV1alpha3 + ns string +} + +var traffictargetsResource = schema.GroupVersionResource{Group: "access.smi-spec.io", Version: "v1alpha3", Resource: "traffictargets"} + +var traffictargetsKind = schema.GroupVersionKind{Group: "access.smi-spec.io", Version: "v1alpha3", Kind: "TrafficTarget"} + +// Get takes name of the trafficTarget, and returns the corresponding trafficTarget object, and an error if there is any. +func (c *FakeTrafficTargets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.TrafficTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(traffictargetsResource, c.ns, name), &v1alpha3.TrafficTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.TrafficTarget), err +} + +// List takes label and field selectors, and returns the list of TrafficTargets that match those selectors. +func (c *FakeTrafficTargets) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.TrafficTargetList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(traffictargetsResource, traffictargetsKind, c.ns, opts), &v1alpha3.TrafficTargetList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha3.TrafficTargetList{ListMeta: obj.(*v1alpha3.TrafficTargetList).ListMeta} + for _, item := range obj.(*v1alpha3.TrafficTargetList).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 trafficTargets. +func (c *FakeTrafficTargets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(traffictargetsResource, c.ns, opts)) + +} + +// Create takes the representation of a trafficTarget and creates it. Returns the server's representation of the trafficTarget, and an error, if there is any. +func (c *FakeTrafficTargets) Create(ctx context.Context, trafficTarget *v1alpha3.TrafficTarget, opts v1.CreateOptions) (result *v1alpha3.TrafficTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(traffictargetsResource, c.ns, trafficTarget), &v1alpha3.TrafficTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.TrafficTarget), err +} + +// Update takes the representation of a trafficTarget and updates it. Returns the server's representation of the trafficTarget, and an error, if there is any. +func (c *FakeTrafficTargets) Update(ctx context.Context, trafficTarget *v1alpha3.TrafficTarget, opts v1.UpdateOptions) (result *v1alpha3.TrafficTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(traffictargetsResource, c.ns, trafficTarget), &v1alpha3.TrafficTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.TrafficTarget), err +} + +// Delete takes name of the trafficTarget and deletes it. Returns an error if one occurs. +func (c *FakeTrafficTargets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(traffictargetsResource, c.ns, name), &v1alpha3.TrafficTarget{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTrafficTargets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(traffictargetsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha3.TrafficTargetList{}) + return err +} + +// Patch applies the patch and returns the patched trafficTarget. +func (c *FakeTrafficTargets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.TrafficTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(traffictargetsResource, c.ns, name, pt, data, subresources...), &v1alpha3.TrafficTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.TrafficTarget), err +} diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/generated_expansion.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/generated_expansion.go new file mode 100644 index 0000000..1ddbe12 --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/generated_expansion.go @@ -0,0 +1,19 @@ +/* +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 v1alpha3 + +type TrafficTargetExpansion interface{} diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/traffictarget.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/traffictarget.go new file mode 100644 index 0000000..92a125e --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha3/traffictarget.go @@ -0,0 +1,176 @@ +/* +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 v1alpha3 + +import ( + "context" + "time" + + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3" + scheme "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/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" +) + +// TrafficTargetsGetter has a method to return a TrafficTargetInterface. +// A group's client should implement this interface. +type TrafficTargetsGetter interface { + TrafficTargets(namespace string) TrafficTargetInterface +} + +// TrafficTargetInterface has methods to work with TrafficTarget resources. +type TrafficTargetInterface interface { + Create(ctx context.Context, trafficTarget *v1alpha3.TrafficTarget, opts v1.CreateOptions) (*v1alpha3.TrafficTarget, error) + Update(ctx context.Context, trafficTarget *v1alpha3.TrafficTarget, opts v1.UpdateOptions) (*v1alpha3.TrafficTarget, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha3.TrafficTarget, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha3.TrafficTargetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.TrafficTarget, err error) + TrafficTargetExpansion +} + +// trafficTargets implements TrafficTargetInterface +type trafficTargets struct { + client rest.Interface + ns string +} + +// newTrafficTargets returns a TrafficTargets +func newTrafficTargets(c *AccessV1alpha3Client, namespace string) *trafficTargets { + return &trafficTargets{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the trafficTarget, and returns the corresponding trafficTarget object, and an error if there is any. +func (c *trafficTargets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.TrafficTarget, err error) { + result = &v1alpha3.TrafficTarget{} + err = c.client.Get(). + Namespace(c.ns). + Resource("traffictargets"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of TrafficTargets that match those selectors. +func (c *trafficTargets) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.TrafficTargetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha3.TrafficTargetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("traffictargets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested trafficTargets. +func (c *trafficTargets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("traffictargets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a trafficTarget and creates it. Returns the server's representation of the trafficTarget, and an error, if there is any. +func (c *trafficTargets) Create(ctx context.Context, trafficTarget *v1alpha3.TrafficTarget, opts v1.CreateOptions) (result *v1alpha3.TrafficTarget, err error) { + result = &v1alpha3.TrafficTarget{} + err = c.client.Post(). + Namespace(c.ns). + Resource("traffictargets"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(trafficTarget). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a trafficTarget and updates it. Returns the server's representation of the trafficTarget, and an error, if there is any. +func (c *trafficTargets) Update(ctx context.Context, trafficTarget *v1alpha3.TrafficTarget, opts v1.UpdateOptions) (result *v1alpha3.TrafficTarget, err error) { + result = &v1alpha3.TrafficTarget{} + err = c.client.Put(). + Namespace(c.ns). + Resource("traffictargets"). + Name(trafficTarget.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(trafficTarget). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the trafficTarget and deletes it. Returns an error if one occurs. +func (c *trafficTargets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("traffictargets"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *trafficTargets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("traffictargets"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched trafficTarget. +func (c *trafficTargets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.TrafficTarget, err error) { + result = &v1alpha3.TrafficTarget{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("traffictargets"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/gen/client/access/informers/externalversions/access/interface.go b/pkg/gen/client/access/informers/externalversions/access/interface.go index cbaf6e6..eb93131 100644 --- a/pkg/gen/client/access/informers/externalversions/access/interface.go +++ b/pkg/gen/client/access/informers/externalversions/access/interface.go @@ -19,6 +19,7 @@ package access import ( v1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/informers/externalversions/access/v1alpha1" v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/informers/externalversions/access/v1alpha2" + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/informers/externalversions/access/v1alpha3" internalinterfaces "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/informers/externalversions/internalinterfaces" ) @@ -28,6 +29,8 @@ type Interface interface { V1alpha1() v1alpha1.Interface // V1alpha2 provides access to shared informers for resources in V1alpha2. V1alpha2() v1alpha2.Interface + // V1alpha3 provides access to shared informers for resources in V1alpha3. + V1alpha3() v1alpha3.Interface } type group struct { @@ -50,3 +53,8 @@ func (g *group) V1alpha1() v1alpha1.Interface { func (g *group) V1alpha2() v1alpha2.Interface { return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1alpha3 returns a new v1alpha3.Interface. +func (g *group) V1alpha3() v1alpha3.Interface { + return v1alpha3.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/gen/client/access/informers/externalversions/access/v1alpha3/interface.go b/pkg/gen/client/access/informers/externalversions/access/v1alpha3/interface.go new file mode 100644 index 0000000..62d7680 --- /dev/null +++ b/pkg/gen/client/access/informers/externalversions/access/v1alpha3/interface.go @@ -0,0 +1,43 @@ +/* +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 v1alpha3 + +import ( + internalinterfaces "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // TrafficTargets returns a TrafficTargetInformer. + TrafficTargets() TrafficTargetInformer +} + +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} +} + +// TrafficTargets returns a TrafficTargetInformer. +func (v *version) TrafficTargets() TrafficTargetInformer { + return &trafficTargetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/gen/client/access/informers/externalversions/access/v1alpha3/traffictarget.go b/pkg/gen/client/access/informers/externalversions/access/v1alpha3/traffictarget.go new file mode 100644 index 0000000..4d207b5 --- /dev/null +++ b/pkg/gen/client/access/informers/externalversions/access/v1alpha3/traffictarget.go @@ -0,0 +1,88 @@ +/* +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 v1alpha3 + +import ( + "context" + time "time" + + accessv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3" + versioned "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned" + internalinterfaces "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/informers/externalversions/internalinterfaces" + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/listers/access/v1alpha3" + 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" +) + +// TrafficTargetInformer provides access to a shared informer and lister for +// TrafficTargets. +type TrafficTargetInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha3.TrafficTargetLister +} + +type trafficTargetInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTrafficTargetInformer constructs a new informer for TrafficTarget 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 NewTrafficTargetInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTrafficTargetInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTrafficTargetInformer constructs a new informer for TrafficTarget 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 NewFilteredTrafficTargetInformer(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.AccessV1alpha3().TrafficTargets(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AccessV1alpha3().TrafficTargets(namespace).Watch(context.TODO(), options) + }, + }, + &accessv1alpha3.TrafficTarget{}, + resyncPeriod, + indexers, + ) +} + +func (f *trafficTargetInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTrafficTargetInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *trafficTargetInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&accessv1alpha3.TrafficTarget{}, f.defaultInformer) +} + +func (f *trafficTargetInformer) Lister() v1alpha3.TrafficTargetLister { + return v1alpha3.NewTrafficTargetLister(f.Informer().GetIndexer()) +} diff --git a/pkg/gen/client/access/informers/externalversions/generic.go b/pkg/gen/client/access/informers/externalversions/generic.go index bba20c6..ec4e825 100644 --- a/pkg/gen/client/access/informers/externalversions/generic.go +++ b/pkg/gen/client/access/informers/externalversions/generic.go @@ -21,6 +21,7 @@ import ( v1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha1" v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -59,6 +60,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha2.SchemeGroupVersion.WithResource("traffictargets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Access().V1alpha2().TrafficTargets().Informer()}, nil + // Group=access.smi-spec.io, Version=v1alpha3 + case v1alpha3.SchemeGroupVersion.WithResource("traffictargets"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Access().V1alpha3().TrafficTargets().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/gen/client/access/listers/access/v1alpha3/expansion_generated.go b/pkg/gen/client/access/listers/access/v1alpha3/expansion_generated.go new file mode 100644 index 0000000..b483297 --- /dev/null +++ b/pkg/gen/client/access/listers/access/v1alpha3/expansion_generated.go @@ -0,0 +1,25 @@ +/* +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 v1alpha3 + +// TrafficTargetListerExpansion allows custom methods to be added to +// TrafficTargetLister. +type TrafficTargetListerExpansion interface{} + +// TrafficTargetNamespaceListerExpansion allows custom methods to be added to +// TrafficTargetNamespaceLister. +type TrafficTargetNamespaceListerExpansion interface{} diff --git a/pkg/gen/client/access/listers/access/v1alpha3/traffictarget.go b/pkg/gen/client/access/listers/access/v1alpha3/traffictarget.go new file mode 100644 index 0000000..a137362 --- /dev/null +++ b/pkg/gen/client/access/listers/access/v1alpha3/traffictarget.go @@ -0,0 +1,92 @@ +/* +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 v1alpha3 + +import ( + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// TrafficTargetLister helps list TrafficTargets. +type TrafficTargetLister interface { + // List lists all TrafficTargets in the indexer. + List(selector labels.Selector) (ret []*v1alpha3.TrafficTarget, err error) + // TrafficTargets returns an object that can list and get TrafficTargets. + TrafficTargets(namespace string) TrafficTargetNamespaceLister + TrafficTargetListerExpansion +} + +// trafficTargetLister implements the TrafficTargetLister interface. +type trafficTargetLister struct { + indexer cache.Indexer +} + +// NewTrafficTargetLister returns a new TrafficTargetLister. +func NewTrafficTargetLister(indexer cache.Indexer) TrafficTargetLister { + return &trafficTargetLister{indexer: indexer} +} + +// List lists all TrafficTargets in the indexer. +func (s *trafficTargetLister) List(selector labels.Selector) (ret []*v1alpha3.TrafficTarget, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.TrafficTarget)) + }) + return ret, err +} + +// TrafficTargets returns an object that can list and get TrafficTargets. +func (s *trafficTargetLister) TrafficTargets(namespace string) TrafficTargetNamespaceLister { + return trafficTargetNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TrafficTargetNamespaceLister helps list and get TrafficTargets. +type TrafficTargetNamespaceLister interface { + // List lists all TrafficTargets in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha3.TrafficTarget, err error) + // Get retrieves the TrafficTarget from the indexer for a given namespace and name. + Get(name string) (*v1alpha3.TrafficTarget, error) + TrafficTargetNamespaceListerExpansion +} + +// trafficTargetNamespaceLister implements the TrafficTargetNamespaceLister +// interface. +type trafficTargetNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all TrafficTargets in the indexer for a given namespace. +func (s trafficTargetNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.TrafficTarget, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.TrafficTarget)) + }) + return ret, err +} + +// Get retrieves the TrafficTarget from the indexer for a given namespace and name. +func (s trafficTargetNamespaceLister) Get(name string) (*v1alpha3.TrafficTarget, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha3.Resource("traffictarget"), name) + } + return obj.(*v1alpha3.TrafficTarget), nil +}