From 9175aaf9a2ea209fcb79ba323636615524d13c51 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sat, 27 Jun 2020 08:36:02 +0300 Subject: [PATCH 1/4] Add TrafficTarget v1alpha2 Signed-off-by: stefanprodan --- crds/access.yaml | 131 ++++++------- hack/update-codegen.sh | 2 +- pkg/apis/access/v1alpha2/doc.go | 4 + pkg/apis/access/v1alpha2/register.go | 48 +++++ pkg/apis/access/v1alpha2/traffic_target.go | 70 +++++++ .../access/v1alpha2/zz_generated.deepcopy.go | 155 +++++++++++++++ .../access/clientset/versioned/clientset.go | 14 ++ .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../typed/access/v1alpha2/access_client.go | 87 +++++++++ .../versioned/typed/access/v1alpha2/doc.go | 18 ++ .../typed/access/v1alpha2/fake/doc.go | 18 ++ .../v1alpha2/fake/fake_access_client.go | 38 ++++ .../v1alpha2/fake/fake_traffictarget.go | 128 +++++++++++++ .../access/v1alpha2/generated_expansion.go | 19 ++ .../typed/access/v1alpha2/traffictarget.go | 176 ++++++++++++++++++ .../externalversions/access/interface.go | 8 + .../access/v1alpha2/interface.go | 43 +++++ .../access/v1alpha2/traffictarget.go | 88 +++++++++ .../informers/externalversions/generic.go | 5 + .../access/v1alpha2/expansion_generated.go | 25 +++ .../listers/access/v1alpha2/traffictarget.go | 92 +++++++++ 23 files changed, 1116 insertions(+), 64 deletions(-) create mode 100644 pkg/apis/access/v1alpha2/doc.go create mode 100644 pkg/apis/access/v1alpha2/register.go create mode 100644 pkg/apis/access/v1alpha2/traffic_target.go create mode 100644 pkg/apis/access/v1alpha2/zz_generated.deepcopy.go create mode 100644 pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/access_client.go create mode 100644 pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/doc.go create mode 100644 pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake/doc.go create mode 100644 pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake/fake_access_client.go create mode 100644 pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake/fake_traffictarget.go create mode 100644 pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/generated_expansion.go create mode 100644 pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/traffictarget.go create mode 100644 pkg/gen/client/access/informers/externalversions/access/v1alpha2/interface.go create mode 100644 pkg/gen/client/access/informers/externalversions/access/v1alpha2/traffictarget.go create mode 100644 pkg/gen/client/access/listers/access/v1alpha2/expansion_generated.go create mode 100644 pkg/gen/client/access/listers/access/v1alpha2/traffictarget.go diff --git a/crds/access.yaml b/crds/access.yaml index 0bad634..656d18f 100644 --- a/crds/access.yaml +++ b/crds/access.yaml @@ -3,82 +3,87 @@ apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: name: traffictargets.access.smi-spec.io -spec: +spec: group: access.smi-spec.io scope: Namespaced - names: + names: kind: TrafficTarget shortNames: - tt plural: traffictargets singular: traffictarget - version: v1alpha1 + version: v1alpha2 versions: - - name: v1alpha1 + - name: v1alpha2 served: true storage: true + - name: v1alpha1 + served: false + storage: false validation: openAPIV3Schema: - required: - - destination properties: - destination: - description: The destination of this traffic target. - type: object + spec: required: - - name - - kind + - destination properties: - kind: - description: Kind of the destination. - type: string - name: - description: Name of the destination. - type: string - namespace: - description: Namespace of the destination. - type: string - port: - description: Port number of the destination. - type: number - specs: - description: Specifications of this traffic target. - type: array - items: - type: object - required: - - name - - kind - properties: - kind: - description: Kind of this spec. - type: string - enum: - - HTTPRouteGroup - - TCPRoute - name: - description: Name of this spec. - type: string - matches: - description: Match conditions of this spec. - type: array - items: + destination: + description: The destination of this traffic target. + type: object + required: + - name + - kind + properties: + kind: + description: Kind of the destination. + type: string + name: + description: Name of the destination. + type: string + namespace: + description: Namespace of the destination. type: string - sources: - description: Sources of this traffic target. - type: array - items: - type: object - required: - - name - - kind - properties: - kind: - description: Kind of this source. - type: string - name: - description: Name of this source. - type: string - namespace: - description: Namespace of this source. - type: string \ No newline at end of file + port: + description: Port number of the destination. + type: number + rules: + description: Specifications of this traffic target. + type: array + items: + type: object + required: + - name + - kind + properties: + kind: + description: Kind of this spec. + type: string + enum: + - HTTPRouteGroup + - TCPRoute + name: + description: Name of this spec. + type: string + matches: + description: Match conditions of this spec. + type: array + items: + type: string + sources: + description: Sources of this traffic target. + type: array + items: + type: object + required: + - name + - kind + properties: + kind: + description: Kind of this source. + type: string + name: + description: Name of this source. + type: string + namespace: + description: Namespace of this source. + type: string diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 91e5600..b32cca1 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" +generate_client "access" "v1alpha1,v1alpha2" echo "" echo "##### Generating metrics client ######" diff --git a/pkg/apis/access/v1alpha2/doc.go b/pkg/apis/access/v1alpha2/doc.go new file mode 100644 index 0000000..e0887e3 --- /dev/null +++ b/pkg/apis/access/v1alpha2/doc.go @@ -0,0 +1,4 @@ +// +k8s:deepcopy-gen=package +// +groupName=access.smi-spec.io + +package v1alpha2 diff --git a/pkg/apis/access/v1alpha2/register.go b/pkg/apis/access/v1alpha2/register.go new file mode 100644 index 0000000..9453136 --- /dev/null +++ b/pkg/apis/access/v1alpha2/register.go @@ -0,0 +1,48 @@ +package v1alpha2 + +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: "v1alpha2", +} + +// 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/v1alpha2/traffic_target.go b/pkg/apis/access/v1alpha2/traffic_target.go new file mode 100644 index 0000000..d3484a2 --- /dev/null +++ b/pkg/apis/access/v1alpha2/traffic_target.go @@ -0,0 +1,70 @@ +package v1alpha2 + +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"` + + // Rules are the traffic rules to allow (HTTPRoutes | TCPRoute), + Rules []TrafficTargetRule `json:"rules"` +} + +// 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 + 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 + Namespace string `json:"namespace,omitempty"` + // Port defines a TCP port to apply the TrafficTarget to + 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/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/access/v1alpha2/zz_generated.deepcopy.go new file mode 100644 index 0000000..ca8416a --- /dev/null +++ b/pkg/apis/access/v1alpha2/zz_generated.deepcopy.go @@ -0,0 +1,155 @@ +// +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 v1alpha2 + +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 + 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) + if in.Spec != nil { + in, out := &in.Spec, &out.Spec + *out = make([]TrafficTargetSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + 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 + out.Destination = in.Destination + if in.Sources != nil { + in, out := &in.Sources, &out.Sources + *out = make([]IdentityBindingSubject, len(*in)) + copy(*out, *in) + } + 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 9714298..1396b49 100644 --- a/pkg/gen/client/access/clientset/versioned/clientset.go +++ b/pkg/gen/client/access/clientset/versioned/clientset.go @@ -20,6 +20,7 @@ import ( "fmt" 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" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -28,6 +29,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface AccessV1alpha1() accessv1alpha1.AccessV1alpha1Interface + AccessV1alpha2() accessv1alpha2.AccessV1alpha2Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -35,6 +37,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient accessV1alpha1 *accessv1alpha1.AccessV1alpha1Client + accessV1alpha2 *accessv1alpha2.AccessV1alpha2Client } // AccessV1alpha1 retrieves the AccessV1alpha1Client @@ -42,6 +45,11 @@ func (c *Clientset) AccessV1alpha1() accessv1alpha1.AccessV1alpha1Interface { return c.accessV1alpha1 } +// AccessV1alpha2 retrieves the AccessV1alpha2Client +func (c *Clientset) AccessV1alpha2() accessv1alpha2.AccessV1alpha2Interface { + return c.accessV1alpha2 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -67,6 +75,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.accessV1alpha2, err = accessv1alpha2.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -80,6 +92,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.accessV1alpha1 = accessv1alpha1.NewForConfigOrDie(c) + cs.accessV1alpha2 = accessv1alpha2.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -89,6 +102,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.accessV1alpha1 = accessv1alpha1.New(c) + cs.accessV1alpha2 = accessv1alpha2.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 01edb0a..9dbe2aa 100644 --- a/pkg/gen/client/access/clientset/versioned/fake/clientset_generated.go +++ b/pkg/gen/client/access/clientset/versioned/fake/clientset_generated.go @@ -20,6 +20,8 @@ import ( clientset "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned" accessv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha1" 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" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -78,3 +80,8 @@ var _ clientset.Interface = &Clientset{} func (c *Clientset) AccessV1alpha1() accessv1alpha1.AccessV1alpha1Interface { return &fakeaccessv1alpha1.FakeAccessV1alpha1{Fake: &c.Fake} } + +// AccessV1alpha2 retrieves the AccessV1alpha2Client +func (c *Clientset) AccessV1alpha2() accessv1alpha2.AccessV1alpha2Interface { + return &fakeaccessv1alpha2.FakeAccessV1alpha2{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 344e412..a791177 100644 --- a/pkg/gen/client/access/clientset/versioned/fake/register.go +++ b/pkg/gen/client/access/clientset/versioned/fake/register.go @@ -18,6 +18,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" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,6 +31,7 @@ var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ accessv1alpha1.AddToScheme, + accessv1alpha2.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 c6c90c3..c83fea7 100644 --- a/pkg/gen/client/access/clientset/versioned/scheme/register.go +++ b/pkg/gen/client/access/clientset/versioned/scheme/register.go @@ -18,6 +18,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" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,6 +31,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ accessv1alpha1.AddToScheme, + accessv1alpha2.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/v1alpha2/access_client.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/access_client.go new file mode 100644 index 0000000..44d323a --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/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 v1alpha2 + +import ( + v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" + "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type AccessV1alpha2Interface interface { + RESTClient() rest.Interface + TrafficTargetsGetter +} + +// AccessV1alpha2Client is used to interact with features provided by the access.smi-spec.io group. +type AccessV1alpha2Client struct { + restClient rest.Interface +} + +func (c *AccessV1alpha2Client) TrafficTargets(namespace string) TrafficTargetInterface { + return newTrafficTargets(c, namespace) +} + +// NewForConfig creates a new AccessV1alpha2Client for the given config. +func NewForConfig(c *rest.Config) (*AccessV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &AccessV1alpha2Client{client}, nil +} + +// NewForConfigOrDie creates a new AccessV1alpha2Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AccessV1alpha2Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AccessV1alpha2Client for the given RESTClient. +func New(c rest.Interface) *AccessV1alpha2Client { + return &AccessV1alpha2Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha2.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 *AccessV1alpha2Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/doc.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/doc.go new file mode 100644 index 0000000..a742af4 --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/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 v1alpha2 diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake/doc.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake/doc.go new file mode 100644 index 0000000..3c48772 --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/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/v1alpha2/fake/fake_access_client.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake/fake_access_client.go new file mode 100644 index 0000000..7a2723c --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/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 ( + v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAccessV1alpha2 struct { + *testing.Fake +} + +func (c *FakeAccessV1alpha2) TrafficTargets(namespace string) v1alpha2.TrafficTargetInterface { + return &FakeTrafficTargets{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAccessV1alpha2) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake/fake_traffictarget.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/fake/fake_traffictarget.go new file mode 100644 index 0000000..1446e71 --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/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" + + v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeTrafficTargets implements TrafficTargetInterface +type FakeTrafficTargets struct { + Fake *FakeAccessV1alpha2 + ns string +} + +var traffictargetsResource = schema.GroupVersionResource{Group: "access.smi-spec.io", Version: "v1alpha2", Resource: "traffictargets"} + +var traffictargetsKind = schema.GroupVersionKind{Group: "access.smi-spec.io", Version: "v1alpha2", 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 *v1alpha2.TrafficTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(traffictargetsResource, c.ns, name), &v1alpha2.TrafficTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.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 *v1alpha2.TrafficTargetList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(traffictargetsResource, traffictargetsKind, c.ns, opts), &v1alpha2.TrafficTargetList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.TrafficTargetList{ListMeta: obj.(*v1alpha2.TrafficTargetList).ListMeta} + for _, item := range obj.(*v1alpha2.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 *v1alpha2.TrafficTarget, opts v1.CreateOptions) (result *v1alpha2.TrafficTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(traffictargetsResource, c.ns, trafficTarget), &v1alpha2.TrafficTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.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 *v1alpha2.TrafficTarget, opts v1.UpdateOptions) (result *v1alpha2.TrafficTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(traffictargetsResource, c.ns, trafficTarget), &v1alpha2.TrafficTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.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), &v1alpha2.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, &v1alpha2.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 *v1alpha2.TrafficTarget, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(traffictargetsResource, c.ns, name, pt, data, subresources...), &v1alpha2.TrafficTarget{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.TrafficTarget), err +} diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/generated_expansion.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/generated_expansion.go new file mode 100644 index 0000000..aff51f9 --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/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 v1alpha2 + +type TrafficTargetExpansion interface{} diff --git a/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/traffictarget.go b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/traffictarget.go new file mode 100644 index 0000000..ab8238d --- /dev/null +++ b/pkg/gen/client/access/clientset/versioned/typed/access/v1alpha2/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 v1alpha2 + +import ( + "context" + "time" + + v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" + 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 *v1alpha2.TrafficTarget, opts v1.CreateOptions) (*v1alpha2.TrafficTarget, error) + Update(ctx context.Context, trafficTarget *v1alpha2.TrafficTarget, opts v1.UpdateOptions) (*v1alpha2.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) (*v1alpha2.TrafficTarget, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.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 *v1alpha2.TrafficTarget, err error) + TrafficTargetExpansion +} + +// trafficTargets implements TrafficTargetInterface +type trafficTargets struct { + client rest.Interface + ns string +} + +// newTrafficTargets returns a TrafficTargets +func newTrafficTargets(c *AccessV1alpha2Client, 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 *v1alpha2.TrafficTarget, err error) { + result = &v1alpha2.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 *v1alpha2.TrafficTargetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.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 *v1alpha2.TrafficTarget, opts v1.CreateOptions) (result *v1alpha2.TrafficTarget, err error) { + result = &v1alpha2.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 *v1alpha2.TrafficTarget, opts v1.UpdateOptions) (result *v1alpha2.TrafficTarget, err error) { + result = &v1alpha2.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 *v1alpha2.TrafficTarget, err error) { + result = &v1alpha2.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 e259cb0..cbaf6e6 100644 --- a/pkg/gen/client/access/informers/externalversions/access/interface.go +++ b/pkg/gen/client/access/informers/externalversions/access/interface.go @@ -18,6 +18,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" internalinterfaces "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/informers/externalversions/internalinterfaces" ) @@ -25,6 +26,8 @@ import ( type Interface interface { // V1alpha1 provides access to shared informers for resources in V1alpha1. V1alpha1() v1alpha1.Interface + // V1alpha2 provides access to shared informers for resources in V1alpha2. + V1alpha2() v1alpha2.Interface } type group struct { @@ -42,3 +45,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha1() v1alpha1.Interface { return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1alpha2 returns a new v1alpha2.Interface. +func (g *group) V1alpha2() v1alpha2.Interface { + return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/gen/client/access/informers/externalversions/access/v1alpha2/interface.go b/pkg/gen/client/access/informers/externalversions/access/v1alpha2/interface.go new file mode 100644 index 0000000..46a2f37 --- /dev/null +++ b/pkg/gen/client/access/informers/externalversions/access/v1alpha2/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 v1alpha2 + +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/v1alpha2/traffictarget.go b/pkg/gen/client/access/informers/externalversions/access/v1alpha2/traffictarget.go new file mode 100644 index 0000000..5eb6f92 --- /dev/null +++ b/pkg/gen/client/access/informers/externalversions/access/v1alpha2/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 v1alpha2 + +import ( + "context" + time "time" + + accessv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" + 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" + v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/access/listers/access/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// TrafficTargetInformer provides access to a shared informer and lister for +// TrafficTargets. +type TrafficTargetInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.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.AccessV1alpha2().TrafficTargets(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AccessV1alpha2().TrafficTargets(namespace).Watch(context.TODO(), options) + }, + }, + &accessv1alpha2.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(&accessv1alpha2.TrafficTarget{}, f.defaultInformer) +} + +func (f *trafficTargetInformer) Lister() v1alpha2.TrafficTargetLister { + return v1alpha2.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 df0a3c1..bba20c6 100644 --- a/pkg/gen/client/access/informers/externalversions/generic.go +++ b/pkg/gen/client/access/informers/externalversions/generic.go @@ -20,6 +20,7 @@ import ( "fmt" v1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha1" + v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -54,6 +55,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("traffictargets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Access().V1alpha1().TrafficTargets().Informer()}, nil + // Group=access.smi-spec.io, Version=v1alpha2 + case v1alpha2.SchemeGroupVersion.WithResource("traffictargets"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Access().V1alpha2().TrafficTargets().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/gen/client/access/listers/access/v1alpha2/expansion_generated.go b/pkg/gen/client/access/listers/access/v1alpha2/expansion_generated.go new file mode 100644 index 0000000..d167801 --- /dev/null +++ b/pkg/gen/client/access/listers/access/v1alpha2/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 v1alpha2 + +// 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/v1alpha2/traffictarget.go b/pkg/gen/client/access/listers/access/v1alpha2/traffictarget.go new file mode 100644 index 0000000..8c5ed53 --- /dev/null +++ b/pkg/gen/client/access/listers/access/v1alpha2/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 v1alpha2 + +import ( + v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2" + "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 []*v1alpha2.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 []*v1alpha2.TrafficTarget, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.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 []*v1alpha2.TrafficTarget, err error) + // Get retrieves the TrafficTarget from the indexer for a given namespace and name. + Get(name string) (*v1alpha2.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 []*v1alpha2.TrafficTarget, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.TrafficTarget)) + }) + return ret, err +} + +// Get retrieves the TrafficTarget from the indexer for a given namespace and name. +func (s trafficTargetNamespaceLister) Get(name string) (*v1alpha2.TrafficTarget, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha2.Resource("traffictarget"), name) + } + return obj.(*v1alpha2.TrafficTarget), nil +} From 035e963d6e211978003c86aff6c6ea3ab7980c44 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sat, 27 Jun 2020 08:45:53 +0300 Subject: [PATCH 2/4] Add HttpRouteGroup and TCPRoute v1alpha3 Signed-off-by: stefanprodan --- crds/specs.yaml | 96 ++++---- hack/update-codegen.sh | 2 +- pkg/apis/specs/v1alpha3/doc.go | 4 + pkg/apis/specs/v1alpha3/helpers.go | 34 +++ pkg/apis/specs/v1alpha3/http_route.go | 83 +++++++ pkg/apis/specs/v1alpha3/register.go | 50 +++++ pkg/apis/specs/v1alpha3/tcp_route.go | 35 +++ .../specs/v1alpha3/zz_generated.deepcopy.go | 210 ++++++++++++++++++ .../specs/clientset/versioned/clientset.go | 14 ++ .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../versioned/typed/specs/v1alpha3/doc.go | 18 ++ .../typed/specs/v1alpha3/fake/doc.go | 18 ++ .../v1alpha3/fake/fake_httproutegroup.go | 128 +++++++++++ .../specs/v1alpha3/fake/fake_specs_client.go | 42 ++++ .../specs/v1alpha3/fake/fake_tcproute.go | 128 +++++++++++ .../specs/v1alpha3/generated_expansion.go | 21 ++ .../typed/specs/v1alpha3/httproutegroup.go | 176 +++++++++++++++ .../typed/specs/v1alpha3/specs_client.go | 92 ++++++++ .../typed/specs/v1alpha3/tcproute.go | 176 +++++++++++++++ .../informers/externalversions/generic.go | 7 + .../externalversions/specs/interface.go | 8 + .../specs/v1alpha3/httproutegroup.go | 88 ++++++++ .../specs/v1alpha3/interface.go | 50 +++++ .../specs/v1alpha3/tcproute.go | 88 ++++++++ .../specs/v1alpha3/expansion_generated.go | 33 +++ .../listers/specs/v1alpha3/httproutegroup.go | 92 ++++++++ .../specs/listers/specs/v1alpha3/tcproute.go | 92 ++++++++ 29 files changed, 1751 insertions(+), 45 deletions(-) create mode 100644 pkg/apis/specs/v1alpha3/doc.go create mode 100644 pkg/apis/specs/v1alpha3/helpers.go create mode 100644 pkg/apis/specs/v1alpha3/http_route.go create mode 100644 pkg/apis/specs/v1alpha3/register.go create mode 100644 pkg/apis/specs/v1alpha3/tcp_route.go create mode 100644 pkg/apis/specs/v1alpha3/zz_generated.deepcopy.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/doc.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/doc.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_httproutegroup.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_specs_client.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_tcproute.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/generated_expansion.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/httproutegroup.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/specs_client.go create mode 100644 pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/tcproute.go create mode 100644 pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/httproutegroup.go create mode 100644 pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/interface.go create mode 100644 pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/tcproute.go create mode 100644 pkg/gen/client/specs/listers/specs/v1alpha3/expansion_generated.go create mode 100644 pkg/gen/client/specs/listers/specs/v1alpha3/httproutegroup.go create mode 100644 pkg/gen/client/specs/listers/specs/v1alpha3/tcproute.go diff --git a/crds/specs.yaml b/crds/specs.yaml index 4f5a59a..c21756c 100644 --- a/crds/specs.yaml +++ b/crds/specs.yaml @@ -12,58 +12,63 @@ spec: - htr plural: httproutegroups singular: httproutegroup - version: v1alpha2 + version: v1alpha3 versions: - - name: v1alpha2 + - name: v1alpha3 served: true storage: true + - name: v1alpha2 + served: false + storage: false - name: v1alpha1 served: false storage: false validation: openAPIV3Schema: - required: - - matches properties: - matches: - description: Match conditions of this route group. - type: array - items: - type: object - required: - - name - properties: - name: - description: Name of the HTTP route. - type: string - pathRegex: - description: URI path regex of the HTTP route. - type: string - methods: - description: The HTTP methods of this HTTP route. - type: array - items: - type: string - description: The HTTP method of this HTTP route. - enum: - - '*' - - GET - - HEAD - - PUT - - POST - - DELETE - - CONNECT - - OPTIONS - - TRACE - - PATCH - headers: - description: Header match conditions of this route. - type: array - items: - description: Header match condition of this route. - type: object - additionalProperties: + spec: + required: + - matches + properties: + matches: + description: Match conditions of this route group. + type: array + items: + type: object + required: + - name + properties: + name: + description: Name of the HTTP route. + type: string + pathRegex: + description: URI path regex of the HTTP route. type: string + methods: + description: The HTTP methods of this HTTP route. + type: array + items: + type: string + description: The HTTP method of this HTTP route. + enum: + - '*' + - GET + - HEAD + - PUT + - POST + - DELETE + - CONNECT + - OPTIONS + - TRACE + - PATCH + headers: + description: Header match conditions of this route. + type: array + items: + description: Header match condition of this route. + type: object + additionalProperties: + type: string --- apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition @@ -78,11 +83,14 @@ spec: - tr plural: tcproutes singular: tcproute - version: v1alpha2 + version: v1alpha3 versions: - - name: v1alpha2 + - name: v1alpha3 served: true storage: true + - name: v1alpha2 + served: false + storage: false - name: v1alpha1 served: false storage: false diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index b32cca1..292ccb3 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -56,7 +56,7 @@ function generate_client() { } echo "##### Generating specs client ######" -generate_client "specs" "v1alpha1,v1alpha2" +generate_client "specs" "v1alpha1,v1alpha2,v1alpha3" echo "" echo "###### Generating split client ######" diff --git a/pkg/apis/specs/v1alpha3/doc.go b/pkg/apis/specs/v1alpha3/doc.go new file mode 100644 index 0000000..a9061cb --- /dev/null +++ b/pkg/apis/specs/v1alpha3/doc.go @@ -0,0 +1,4 @@ +// +k8s:deepcopy-gen=package +// +groupName=specs.smi-spec.io + +package v1alpha3 diff --git a/pkg/apis/specs/v1alpha3/helpers.go b/pkg/apis/specs/v1alpha3/helpers.go new file mode 100644 index 0000000..8c0b7fd --- /dev/null +++ b/pkg/apis/specs/v1alpha3/helpers.go @@ -0,0 +1,34 @@ +package v1alpha3 + +import ( + "encoding/json" + "errors" +) + +// UnmarshalJSON converts a given array of single value maps to one map +func (h *httpHeaders) UnmarshalJSON(b []byte) error { + *h = make(map[string]string) + var temp []map[string]string + if err := json.Unmarshal(b, &temp); err != nil { + return err + } + + for _, m := range temp { + if len(m) > 1 { + return errors.New("incorrect length of keyval") + } + for key, val := range m { + (*h)[key] = val + } + } + return nil +} + +// MarshalJSON converts a given map to array of single value maps +func (h httpHeaders) MarshalJSON() ([]byte, error) { + var returnArr []map[string]string + for key, val := range h { + returnArr = append(returnArr, map[string]string{key: val}) + } + return json.Marshal(returnArr) +} diff --git a/pkg/apis/specs/v1alpha3/http_route.go b/pkg/apis/specs/v1alpha3/http_route.go new file mode 100644 index 0000000..c7308f3 --- /dev/null +++ b/pkg/apis/specs/v1alpha3/http_route.go @@ -0,0 +1,83 @@ +package v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// HTTPRouteGroup is used to describe HTTP/1 and HTTP/2 traffic. +// It enumerates the routes that can be served by an application. +type HTTPRouteGroup 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 HTTPRouteGroupSpec `json:"spec"` +} + +// HTTPRouteGroupSpec is the specification for a HTTPRouteGroup +type HTTPRouteGroupSpec struct { + // Routes for inbound traffic + Matches []HTTPMatch `json:"matches,omitempty"` +} + +// HTTPMatch defines an individual route for HTTP traffic +type HTTPMatch struct { + // Name is the name of the match for referencing in a TrafficTarget + Name string `json:"name,omitempty"` + + // Methods for inbound traffic as defined in RFC 7231 + // https://tools.ietf.org/html/rfc7231#section-4 + Methods []string `json:"methods,omitempty"` + + // PathRegex is a regular expression defining the route + PathRegex string `json:"pathRegex,omitempty"` + + // Headers is a list of headers used to match HTTP traffic + Headers httpHeaders `json:"headers,omitempty"` +} + +// httpHeaders is a map of key/value pairs which match HTTP header name and value +type httpHeaders map[string]string + +// HTTPRouteMethod are methods allowed by the route +type HTTPRouteMethod string + +const ( + // HTTPRouteMethodAll is a wildcard for all HTTP methods + HTTPRouteMethodAll HTTPRouteMethod = "*" + // HTTPRouteMethodGet HTTP GET method + HTTPRouteMethodGet HTTPRouteMethod = "GET" + // HTTPRouteMethodHead HTTP HEAD method + HTTPRouteMethodHead HTTPRouteMethod = "HEAD" + // HTTPRouteMethodPut HTTP PUT method + HTTPRouteMethodPut HTTPRouteMethod = "PUT" + // HTTPRouteMethodPost HTTP POST method + HTTPRouteMethodPost HTTPRouteMethod = "POST" + // HTTPRouteMethodDelete HTTP DELETE method + HTTPRouteMethodDelete HTTPRouteMethod = "DELETE" + // HTTPRouteMethodConnect HTTP CONNECT method + HTTPRouteMethodConnect HTTPRouteMethod = "CONNECT" + // HTTPRouteMethodOptions HTTP OPTIONS method + HTTPRouteMethodOptions HTTPRouteMethod = "OPTIONS" + // HTTPRouteMethodTrace HTTP TRACE method + HTTPRouteMethodTrace HTTPRouteMethod = "TRACE" + // HTTPRouteMethodPatch HTTP PATCH method + HTTPRouteMethodPatch HTTPRouteMethod = "PATCH" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// HTTPRouteGroupList satisfy K8s code gen requirements +type HTTPRouteGroupList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []HTTPRouteGroup `json:"items"` +} diff --git a/pkg/apis/specs/v1alpha3/register.go b/pkg/apis/specs/v1alpha3/register.go new file mode 100644 index 0000000..de46b8c --- /dev/null +++ b/pkg/apis/specs/v1alpha3/register.go @@ -0,0 +1,50 @@ +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/specs" +) + +// 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, + &HTTPRouteGroup{}, + &HTTPRouteGroupList{}, + &TCPRoute{}, + &TCPRouteList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/specs/v1alpha3/tcp_route.go b/pkg/apis/specs/v1alpha3/tcp_route.go new file mode 100644 index 0000000..2becb05 --- /dev/null +++ b/pkg/apis/specs/v1alpha3/tcp_route.go @@ -0,0 +1,35 @@ +package v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TCPRoute is used to describe TCP inbound connections +type TCPRoute 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 TCPRouteSpec `json:"spec,omitempty"` +} + +// TCPRouteSpec is the specification of a TCPRoute +type TCPRouteSpec struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TCPRouteList satisfy K8s code gen requirements +type TCPRouteList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []TCPRoute `json:"items"` +} diff --git a/pkg/apis/specs/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/specs/v1alpha3/zz_generated.deepcopy.go new file mode 100644 index 0000000..22b6c26 --- /dev/null +++ b/pkg/apis/specs/v1alpha3/zz_generated.deepcopy.go @@ -0,0 +1,210 @@ +// +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 *HTTPMatch) DeepCopyInto(out *HTTPMatch) { + *out = *in + if in.Methods != nil { + in, out := &in.Methods, &out.Methods + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Headers != nil { + in, out := &in.Headers, &out.Headers + *out = make(httpHeaders, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPMatch. +func (in *HTTPMatch) DeepCopy() *HTTPMatch { + if in == nil { + return nil + } + out := new(HTTPMatch) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPRouteGroup) DeepCopyInto(out *HTTPRouteGroup) { + *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 HTTPRouteGroup. +func (in *HTTPRouteGroup) DeepCopy() *HTTPRouteGroup { + if in == nil { + return nil + } + out := new(HTTPRouteGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HTTPRouteGroup) 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 *HTTPRouteGroupList) DeepCopyInto(out *HTTPRouteGroupList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]HTTPRouteGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRouteGroupList. +func (in *HTTPRouteGroupList) DeepCopy() *HTTPRouteGroupList { + if in == nil { + return nil + } + out := new(HTTPRouteGroupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HTTPRouteGroupList) 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 *HTTPRouteGroupSpec) DeepCopyInto(out *HTTPRouteGroupSpec) { + *out = *in + if in.Matches != nil { + in, out := &in.Matches, &out.Matches + *out = make([]HTTPMatch, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRouteGroupSpec. +func (in *HTTPRouteGroupSpec) DeepCopy() *HTTPRouteGroupSpec { + if in == nil { + return nil + } + out := new(HTTPRouteGroupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TCPRoute) DeepCopyInto(out *TCPRoute) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPRoute. +func (in *TCPRoute) DeepCopy() *TCPRoute { + if in == nil { + return nil + } + out := new(TCPRoute) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TCPRoute) 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 *TCPRouteList) DeepCopyInto(out *TCPRouteList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TCPRoute, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPRouteList. +func (in *TCPRouteList) DeepCopy() *TCPRouteList { + if in == nil { + return nil + } + out := new(TCPRouteList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TCPRouteList) 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 *TCPRouteSpec) DeepCopyInto(out *TCPRouteSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPRouteSpec. +func (in *TCPRouteSpec) DeepCopy() *TCPRouteSpec { + if in == nil { + return nil + } + out := new(TCPRouteSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/gen/client/specs/clientset/versioned/clientset.go b/pkg/gen/client/specs/clientset/versioned/clientset.go index 82d2ae5..1810525 100644 --- a/pkg/gen/client/specs/clientset/versioned/clientset.go +++ b/pkg/gen/client/specs/clientset/versioned/clientset.go @@ -21,6 +21,7 @@ import ( specsv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha1" specsv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha2" + specsv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/typed/specs/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 SpecsV1alpha1() specsv1alpha1.SpecsV1alpha1Interface SpecsV1alpha2() specsv1alpha2.SpecsV1alpha2Interface + SpecsV1alpha3() specsv1alpha3.SpecsV1alpha3Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -38,6 +40,7 @@ type Clientset struct { *discovery.DiscoveryClient specsV1alpha1 *specsv1alpha1.SpecsV1alpha1Client specsV1alpha2 *specsv1alpha2.SpecsV1alpha2Client + specsV1alpha3 *specsv1alpha3.SpecsV1alpha3Client } // SpecsV1alpha1 retrieves the SpecsV1alpha1Client @@ -50,6 +53,11 @@ func (c *Clientset) SpecsV1alpha2() specsv1alpha2.SpecsV1alpha2Interface { return c.specsV1alpha2 } +// SpecsV1alpha3 retrieves the SpecsV1alpha3Client +func (c *Clientset) SpecsV1alpha3() specsv1alpha3.SpecsV1alpha3Interface { + return c.specsV1alpha3 +} + // 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.specsV1alpha3, err = specsv1alpha3.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.specsV1alpha1 = specsv1alpha1.NewForConfigOrDie(c) cs.specsV1alpha2 = specsv1alpha2.NewForConfigOrDie(c) + cs.specsV1alpha3 = specsv1alpha3.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -103,6 +116,7 @@ func New(c rest.Interface) *Clientset { var cs Clientset cs.specsV1alpha1 = specsv1alpha1.New(c) cs.specsV1alpha2 = specsv1alpha2.New(c) + cs.specsV1alpha3 = specsv1alpha3.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/gen/client/specs/clientset/versioned/fake/clientset_generated.go b/pkg/gen/client/specs/clientset/versioned/fake/clientset_generated.go index 33fd353..94da723 100644 --- a/pkg/gen/client/specs/clientset/versioned/fake/clientset_generated.go +++ b/pkg/gen/client/specs/clientset/versioned/fake/clientset_generated.go @@ -22,6 +22,8 @@ import ( fakespecsv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha1/fake" specsv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha2" fakespecsv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha2/fake" + specsv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3" + fakespecsv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -85,3 +87,8 @@ func (c *Clientset) SpecsV1alpha1() specsv1alpha1.SpecsV1alpha1Interface { func (c *Clientset) SpecsV1alpha2() specsv1alpha2.SpecsV1alpha2Interface { return &fakespecsv1alpha2.FakeSpecsV1alpha2{Fake: &c.Fake} } + +// SpecsV1alpha3 retrieves the SpecsV1alpha3Client +func (c *Clientset) SpecsV1alpha3() specsv1alpha3.SpecsV1alpha3Interface { + return &fakespecsv1alpha3.FakeSpecsV1alpha3{Fake: &c.Fake} +} diff --git a/pkg/gen/client/specs/clientset/versioned/fake/register.go b/pkg/gen/client/specs/clientset/versioned/fake/register.go index e1a84f5..6d002a6 100644 --- a/pkg/gen/client/specs/clientset/versioned/fake/register.go +++ b/pkg/gen/client/specs/clientset/versioned/fake/register.go @@ -19,6 +19,7 @@ package fake import ( specsv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha1" specsv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha2" + specsv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/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{ specsv1alpha1.AddToScheme, specsv1alpha2.AddToScheme, + specsv1alpha3.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/gen/client/specs/clientset/versioned/scheme/register.go b/pkg/gen/client/specs/clientset/versioned/scheme/register.go index d9e9b29..8fc4f74 100644 --- a/pkg/gen/client/specs/clientset/versioned/scheme/register.go +++ b/pkg/gen/client/specs/clientset/versioned/scheme/register.go @@ -19,6 +19,7 @@ package scheme import ( specsv1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha1" specsv1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha2" + specsv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/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{ specsv1alpha1.AddToScheme, specsv1alpha2.AddToScheme, + specsv1alpha3.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/doc.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/doc.go new file mode 100644 index 0000000..3207da3 --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/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/specs/clientset/versioned/typed/specs/v1alpha3/fake/doc.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/doc.go new file mode 100644 index 0000000..3c48772 --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/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/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_httproutegroup.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_httproutegroup.go new file mode 100644 index 0000000..5a5b984 --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_httproutegroup.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/specs/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" +) + +// FakeHTTPRouteGroups implements HTTPRouteGroupInterface +type FakeHTTPRouteGroups struct { + Fake *FakeSpecsV1alpha3 + ns string +} + +var httproutegroupsResource = schema.GroupVersionResource{Group: "specs.smi-spec.io", Version: "v1alpha3", Resource: "httproutegroups"} + +var httproutegroupsKind = schema.GroupVersionKind{Group: "specs.smi-spec.io", Version: "v1alpha3", Kind: "HTTPRouteGroup"} + +// Get takes name of the hTTPRouteGroup, and returns the corresponding hTTPRouteGroup object, and an error if there is any. +func (c *FakeHTTPRouteGroups) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.HTTPRouteGroup, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(httproutegroupsResource, c.ns, name), &v1alpha3.HTTPRouteGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.HTTPRouteGroup), err +} + +// List takes label and field selectors, and returns the list of HTTPRouteGroups that match those selectors. +func (c *FakeHTTPRouteGroups) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.HTTPRouteGroupList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(httproutegroupsResource, httproutegroupsKind, c.ns, opts), &v1alpha3.HTTPRouteGroupList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha3.HTTPRouteGroupList{ListMeta: obj.(*v1alpha3.HTTPRouteGroupList).ListMeta} + for _, item := range obj.(*v1alpha3.HTTPRouteGroupList).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 hTTPRouteGroups. +func (c *FakeHTTPRouteGroups) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(httproutegroupsResource, c.ns, opts)) + +} + +// Create takes the representation of a hTTPRouteGroup and creates it. Returns the server's representation of the hTTPRouteGroup, and an error, if there is any. +func (c *FakeHTTPRouteGroups) Create(ctx context.Context, hTTPRouteGroup *v1alpha3.HTTPRouteGroup, opts v1.CreateOptions) (result *v1alpha3.HTTPRouteGroup, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(httproutegroupsResource, c.ns, hTTPRouteGroup), &v1alpha3.HTTPRouteGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.HTTPRouteGroup), err +} + +// Update takes the representation of a hTTPRouteGroup and updates it. Returns the server's representation of the hTTPRouteGroup, and an error, if there is any. +func (c *FakeHTTPRouteGroups) Update(ctx context.Context, hTTPRouteGroup *v1alpha3.HTTPRouteGroup, opts v1.UpdateOptions) (result *v1alpha3.HTTPRouteGroup, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(httproutegroupsResource, c.ns, hTTPRouteGroup), &v1alpha3.HTTPRouteGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.HTTPRouteGroup), err +} + +// Delete takes name of the hTTPRouteGroup and deletes it. Returns an error if one occurs. +func (c *FakeHTTPRouteGroups) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(httproutegroupsResource, c.ns, name), &v1alpha3.HTTPRouteGroup{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeHTTPRouteGroups) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(httproutegroupsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha3.HTTPRouteGroupList{}) + return err +} + +// Patch applies the patch and returns the patched hTTPRouteGroup. +func (c *FakeHTTPRouteGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.HTTPRouteGroup, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(httproutegroupsResource, c.ns, name, pt, data, subresources...), &v1alpha3.HTTPRouteGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.HTTPRouteGroup), err +} diff --git a/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_specs_client.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_specs_client.go new file mode 100644 index 0000000..f8f3a75 --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_specs_client.go @@ -0,0 +1,42 @@ +/* +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/specs/clientset/versioned/typed/specs/v1alpha3" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeSpecsV1alpha3 struct { + *testing.Fake +} + +func (c *FakeSpecsV1alpha3) HTTPRouteGroups(namespace string) v1alpha3.HTTPRouteGroupInterface { + return &FakeHTTPRouteGroups{c, namespace} +} + +func (c *FakeSpecsV1alpha3) TCPRoutes(namespace string) v1alpha3.TCPRouteInterface { + return &FakeTCPRoutes{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSpecsV1alpha3) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_tcproute.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_tcproute.go new file mode 100644 index 0000000..10521af --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/fake/fake_tcproute.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/specs/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" +) + +// FakeTCPRoutes implements TCPRouteInterface +type FakeTCPRoutes struct { + Fake *FakeSpecsV1alpha3 + ns string +} + +var tcproutesResource = schema.GroupVersionResource{Group: "specs.smi-spec.io", Version: "v1alpha3", Resource: "tcproutes"} + +var tcproutesKind = schema.GroupVersionKind{Group: "specs.smi-spec.io", Version: "v1alpha3", Kind: "TCPRoute"} + +// Get takes name of the tCPRoute, and returns the corresponding tCPRoute object, and an error if there is any. +func (c *FakeTCPRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.TCPRoute, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(tcproutesResource, c.ns, name), &v1alpha3.TCPRoute{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.TCPRoute), err +} + +// List takes label and field selectors, and returns the list of TCPRoutes that match those selectors. +func (c *FakeTCPRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.TCPRouteList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(tcproutesResource, tcproutesKind, c.ns, opts), &v1alpha3.TCPRouteList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha3.TCPRouteList{ListMeta: obj.(*v1alpha3.TCPRouteList).ListMeta} + for _, item := range obj.(*v1alpha3.TCPRouteList).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 tCPRoutes. +func (c *FakeTCPRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(tcproutesResource, c.ns, opts)) + +} + +// Create takes the representation of a tCPRoute and creates it. Returns the server's representation of the tCPRoute, and an error, if there is any. +func (c *FakeTCPRoutes) Create(ctx context.Context, tCPRoute *v1alpha3.TCPRoute, opts v1.CreateOptions) (result *v1alpha3.TCPRoute, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(tcproutesResource, c.ns, tCPRoute), &v1alpha3.TCPRoute{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.TCPRoute), err +} + +// Update takes the representation of a tCPRoute and updates it. Returns the server's representation of the tCPRoute, and an error, if there is any. +func (c *FakeTCPRoutes) Update(ctx context.Context, tCPRoute *v1alpha3.TCPRoute, opts v1.UpdateOptions) (result *v1alpha3.TCPRoute, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(tcproutesResource, c.ns, tCPRoute), &v1alpha3.TCPRoute{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.TCPRoute), err +} + +// Delete takes name of the tCPRoute and deletes it. Returns an error if one occurs. +func (c *FakeTCPRoutes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(tcproutesResource, c.ns, name), &v1alpha3.TCPRoute{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTCPRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(tcproutesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha3.TCPRouteList{}) + return err +} + +// Patch applies the patch and returns the patched tCPRoute. +func (c *FakeTCPRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.TCPRoute, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(tcproutesResource, c.ns, name, pt, data, subresources...), &v1alpha3.TCPRoute{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.TCPRoute), err +} diff --git a/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/generated_expansion.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/generated_expansion.go new file mode 100644 index 0000000..ac631bb --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/generated_expansion.go @@ -0,0 +1,21 @@ +/* +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 HTTPRouteGroupExpansion interface{} + +type TCPRouteExpansion interface{} diff --git a/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/httproutegroup.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/httproutegroup.go new file mode 100644 index 0000000..25339b5 --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/httproutegroup.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/specs/v1alpha3" + scheme "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/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" +) + +// HTTPRouteGroupsGetter has a method to return a HTTPRouteGroupInterface. +// A group's client should implement this interface. +type HTTPRouteGroupsGetter interface { + HTTPRouteGroups(namespace string) HTTPRouteGroupInterface +} + +// HTTPRouteGroupInterface has methods to work with HTTPRouteGroup resources. +type HTTPRouteGroupInterface interface { + Create(ctx context.Context, hTTPRouteGroup *v1alpha3.HTTPRouteGroup, opts v1.CreateOptions) (*v1alpha3.HTTPRouteGroup, error) + Update(ctx context.Context, hTTPRouteGroup *v1alpha3.HTTPRouteGroup, opts v1.UpdateOptions) (*v1alpha3.HTTPRouteGroup, 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.HTTPRouteGroup, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha3.HTTPRouteGroupList, 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.HTTPRouteGroup, err error) + HTTPRouteGroupExpansion +} + +// hTTPRouteGroups implements HTTPRouteGroupInterface +type hTTPRouteGroups struct { + client rest.Interface + ns string +} + +// newHTTPRouteGroups returns a HTTPRouteGroups +func newHTTPRouteGroups(c *SpecsV1alpha3Client, namespace string) *hTTPRouteGroups { + return &hTTPRouteGroups{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the hTTPRouteGroup, and returns the corresponding hTTPRouteGroup object, and an error if there is any. +func (c *hTTPRouteGroups) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.HTTPRouteGroup, err error) { + result = &v1alpha3.HTTPRouteGroup{} + err = c.client.Get(). + Namespace(c.ns). + Resource("httproutegroups"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of HTTPRouteGroups that match those selectors. +func (c *hTTPRouteGroups) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.HTTPRouteGroupList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha3.HTTPRouteGroupList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("httproutegroups"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested hTTPRouteGroups. +func (c *hTTPRouteGroups) 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("httproutegroups"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a hTTPRouteGroup and creates it. Returns the server's representation of the hTTPRouteGroup, and an error, if there is any. +func (c *hTTPRouteGroups) Create(ctx context.Context, hTTPRouteGroup *v1alpha3.HTTPRouteGroup, opts v1.CreateOptions) (result *v1alpha3.HTTPRouteGroup, err error) { + result = &v1alpha3.HTTPRouteGroup{} + err = c.client.Post(). + Namespace(c.ns). + Resource("httproutegroups"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(hTTPRouteGroup). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a hTTPRouteGroup and updates it. Returns the server's representation of the hTTPRouteGroup, and an error, if there is any. +func (c *hTTPRouteGroups) Update(ctx context.Context, hTTPRouteGroup *v1alpha3.HTTPRouteGroup, opts v1.UpdateOptions) (result *v1alpha3.HTTPRouteGroup, err error) { + result = &v1alpha3.HTTPRouteGroup{} + err = c.client.Put(). + Namespace(c.ns). + Resource("httproutegroups"). + Name(hTTPRouteGroup.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(hTTPRouteGroup). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the hTTPRouteGroup and deletes it. Returns an error if one occurs. +func (c *hTTPRouteGroups) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("httproutegroups"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *hTTPRouteGroups) 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("httproutegroups"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched hTTPRouteGroup. +func (c *hTTPRouteGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.HTTPRouteGroup, err error) { + result = &v1alpha3.HTTPRouteGroup{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("httproutegroups"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/specs_client.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/specs_client.go new file mode 100644 index 0000000..063c2ba --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/specs_client.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 client-gen. DO NOT EDIT. + +package v1alpha3 + +import ( + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha3" + "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type SpecsV1alpha3Interface interface { + RESTClient() rest.Interface + HTTPRouteGroupsGetter + TCPRoutesGetter +} + +// SpecsV1alpha3Client is used to interact with features provided by the specs.smi-spec.io group. +type SpecsV1alpha3Client struct { + restClient rest.Interface +} + +func (c *SpecsV1alpha3Client) HTTPRouteGroups(namespace string) HTTPRouteGroupInterface { + return newHTTPRouteGroups(c, namespace) +} + +func (c *SpecsV1alpha3Client) TCPRoutes(namespace string) TCPRouteInterface { + return newTCPRoutes(c, namespace) +} + +// NewForConfig creates a new SpecsV1alpha3Client for the given config. +func NewForConfig(c *rest.Config) (*SpecsV1alpha3Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &SpecsV1alpha3Client{client}, nil +} + +// NewForConfigOrDie creates a new SpecsV1alpha3Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SpecsV1alpha3Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SpecsV1alpha3Client for the given RESTClient. +func New(c rest.Interface) *SpecsV1alpha3Client { + return &SpecsV1alpha3Client{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 *SpecsV1alpha3Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/tcproute.go b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/tcproute.go new file mode 100644 index 0000000..9693f75 --- /dev/null +++ b/pkg/gen/client/specs/clientset/versioned/typed/specs/v1alpha3/tcproute.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/specs/v1alpha3" + scheme "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/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" +) + +// TCPRoutesGetter has a method to return a TCPRouteInterface. +// A group's client should implement this interface. +type TCPRoutesGetter interface { + TCPRoutes(namespace string) TCPRouteInterface +} + +// TCPRouteInterface has methods to work with TCPRoute resources. +type TCPRouteInterface interface { + Create(ctx context.Context, tCPRoute *v1alpha3.TCPRoute, opts v1.CreateOptions) (*v1alpha3.TCPRoute, error) + Update(ctx context.Context, tCPRoute *v1alpha3.TCPRoute, opts v1.UpdateOptions) (*v1alpha3.TCPRoute, 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.TCPRoute, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha3.TCPRouteList, 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.TCPRoute, err error) + TCPRouteExpansion +} + +// tCPRoutes implements TCPRouteInterface +type tCPRoutes struct { + client rest.Interface + ns string +} + +// newTCPRoutes returns a TCPRoutes +func newTCPRoutes(c *SpecsV1alpha3Client, namespace string) *tCPRoutes { + return &tCPRoutes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the tCPRoute, and returns the corresponding tCPRoute object, and an error if there is any. +func (c *tCPRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.TCPRoute, err error) { + result = &v1alpha3.TCPRoute{} + err = c.client.Get(). + Namespace(c.ns). + Resource("tcproutes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of TCPRoutes that match those selectors. +func (c *tCPRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.TCPRouteList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha3.TCPRouteList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("tcproutes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested tCPRoutes. +func (c *tCPRoutes) 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("tcproutes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a tCPRoute and creates it. Returns the server's representation of the tCPRoute, and an error, if there is any. +func (c *tCPRoutes) Create(ctx context.Context, tCPRoute *v1alpha3.TCPRoute, opts v1.CreateOptions) (result *v1alpha3.TCPRoute, err error) { + result = &v1alpha3.TCPRoute{} + err = c.client.Post(). + Namespace(c.ns). + Resource("tcproutes"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(tCPRoute). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a tCPRoute and updates it. Returns the server's representation of the tCPRoute, and an error, if there is any. +func (c *tCPRoutes) Update(ctx context.Context, tCPRoute *v1alpha3.TCPRoute, opts v1.UpdateOptions) (result *v1alpha3.TCPRoute, err error) { + result = &v1alpha3.TCPRoute{} + err = c.client.Put(). + Namespace(c.ns). + Resource("tcproutes"). + Name(tCPRoute.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(tCPRoute). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the tCPRoute and deletes it. Returns an error if one occurs. +func (c *tCPRoutes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("tcproutes"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *tCPRoutes) 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("tcproutes"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched tCPRoute. +func (c *tCPRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.TCPRoute, err error) { + result = &v1alpha3.TCPRoute{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("tcproutes"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/gen/client/specs/informers/externalversions/generic.go b/pkg/gen/client/specs/informers/externalversions/generic.go index e7eecf3..5685dc5 100644 --- a/pkg/gen/client/specs/informers/externalversions/generic.go +++ b/pkg/gen/client/specs/informers/externalversions/generic.go @@ -21,6 +21,7 @@ import ( v1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha1" v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha2" + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha3" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -63,6 +64,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha2.SchemeGroupVersion.WithResource("tcproutes"): return &genericInformer{resource: resource.GroupResource(), informer: f.Specs().V1alpha2().TCPRoutes().Informer()}, nil + // Group=specs.smi-spec.io, Version=v1alpha3 + case v1alpha3.SchemeGroupVersion.WithResource("httproutegroups"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Specs().V1alpha3().HTTPRouteGroups().Informer()}, nil + case v1alpha3.SchemeGroupVersion.WithResource("tcproutes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Specs().V1alpha3().TCPRoutes().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/gen/client/specs/informers/externalversions/specs/interface.go b/pkg/gen/client/specs/informers/externalversions/specs/interface.go index 7f3a654..429bc78 100644 --- a/pkg/gen/client/specs/informers/externalversions/specs/interface.go +++ b/pkg/gen/client/specs/informers/externalversions/specs/interface.go @@ -20,6 +20,7 @@ import ( internalinterfaces "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/informers/externalversions/internalinterfaces" v1alpha1 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/informers/externalversions/specs/v1alpha1" v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/informers/externalversions/specs/v1alpha2" + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3" ) // Interface provides access to each of this group's versions. @@ -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/specs/informers/externalversions/specs/v1alpha3/httproutegroup.go b/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/httproutegroup.go new file mode 100644 index 0000000..4acc22e --- /dev/null +++ b/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/httproutegroup.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" + + specsv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha3" + versioned "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned" + internalinterfaces "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/informers/externalversions/internalinterfaces" + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/listers/specs/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" +) + +// HTTPRouteGroupInformer provides access to a shared informer and lister for +// HTTPRouteGroups. +type HTTPRouteGroupInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha3.HTTPRouteGroupLister +} + +type hTTPRouteGroupInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewHTTPRouteGroupInformer constructs a new informer for HTTPRouteGroup 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 NewHTTPRouteGroupInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredHTTPRouteGroupInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredHTTPRouteGroupInformer constructs a new informer for HTTPRouteGroup 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 NewFilteredHTTPRouteGroupInformer(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.SpecsV1alpha3().HTTPRouteGroups(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpecsV1alpha3().HTTPRouteGroups(namespace).Watch(context.TODO(), options) + }, + }, + &specsv1alpha3.HTTPRouteGroup{}, + resyncPeriod, + indexers, + ) +} + +func (f *hTTPRouteGroupInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredHTTPRouteGroupInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *hTTPRouteGroupInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&specsv1alpha3.HTTPRouteGroup{}, f.defaultInformer) +} + +func (f *hTTPRouteGroupInformer) Lister() v1alpha3.HTTPRouteGroupLister { + return v1alpha3.NewHTTPRouteGroupLister(f.Informer().GetIndexer()) +} diff --git a/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/interface.go b/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/interface.go new file mode 100644 index 0000000..27d2e3b --- /dev/null +++ b/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/interface.go @@ -0,0 +1,50 @@ +/* +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/specs/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // HTTPRouteGroups returns a HTTPRouteGroupInformer. + HTTPRouteGroups() HTTPRouteGroupInformer + // TCPRoutes returns a TCPRouteInformer. + TCPRoutes() TCPRouteInformer +} + +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} +} + +// HTTPRouteGroups returns a HTTPRouteGroupInformer. +func (v *version) HTTPRouteGroups() HTTPRouteGroupInformer { + return &hTTPRouteGroupInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// TCPRoutes returns a TCPRouteInformer. +func (v *version) TCPRoutes() TCPRouteInformer { + return &tCPRouteInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/tcproute.go b/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/tcproute.go new file mode 100644 index 0000000..460e272 --- /dev/null +++ b/pkg/gen/client/specs/informers/externalversions/specs/v1alpha3/tcproute.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" + + specsv1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha3" + versioned "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/clientset/versioned" + internalinterfaces "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/informers/externalversions/internalinterfaces" + v1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/specs/listers/specs/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" +) + +// TCPRouteInformer provides access to a shared informer and lister for +// TCPRoutes. +type TCPRouteInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha3.TCPRouteLister +} + +type tCPRouteInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTCPRouteInformer constructs a new informer for TCPRoute 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 NewTCPRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTCPRouteInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTCPRouteInformer constructs a new informer for TCPRoute 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 NewFilteredTCPRouteInformer(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.SpecsV1alpha3().TCPRoutes(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpecsV1alpha3().TCPRoutes(namespace).Watch(context.TODO(), options) + }, + }, + &specsv1alpha3.TCPRoute{}, + resyncPeriod, + indexers, + ) +} + +func (f *tCPRouteInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTCPRouteInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *tCPRouteInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&specsv1alpha3.TCPRoute{}, f.defaultInformer) +} + +func (f *tCPRouteInformer) Lister() v1alpha3.TCPRouteLister { + return v1alpha3.NewTCPRouteLister(f.Informer().GetIndexer()) +} diff --git a/pkg/gen/client/specs/listers/specs/v1alpha3/expansion_generated.go b/pkg/gen/client/specs/listers/specs/v1alpha3/expansion_generated.go new file mode 100644 index 0000000..66b06cb --- /dev/null +++ b/pkg/gen/client/specs/listers/specs/v1alpha3/expansion_generated.go @@ -0,0 +1,33 @@ +/* +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 + +// HTTPRouteGroupListerExpansion allows custom methods to be added to +// HTTPRouteGroupLister. +type HTTPRouteGroupListerExpansion interface{} + +// HTTPRouteGroupNamespaceListerExpansion allows custom methods to be added to +// HTTPRouteGroupNamespaceLister. +type HTTPRouteGroupNamespaceListerExpansion interface{} + +// TCPRouteListerExpansion allows custom methods to be added to +// TCPRouteLister. +type TCPRouteListerExpansion interface{} + +// TCPRouteNamespaceListerExpansion allows custom methods to be added to +// TCPRouteNamespaceLister. +type TCPRouteNamespaceListerExpansion interface{} diff --git a/pkg/gen/client/specs/listers/specs/v1alpha3/httproutegroup.go b/pkg/gen/client/specs/listers/specs/v1alpha3/httproutegroup.go new file mode 100644 index 0000000..12fd8e4 --- /dev/null +++ b/pkg/gen/client/specs/listers/specs/v1alpha3/httproutegroup.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/specs/v1alpha3" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// HTTPRouteGroupLister helps list HTTPRouteGroups. +type HTTPRouteGroupLister interface { + // List lists all HTTPRouteGroups in the indexer. + List(selector labels.Selector) (ret []*v1alpha3.HTTPRouteGroup, err error) + // HTTPRouteGroups returns an object that can list and get HTTPRouteGroups. + HTTPRouteGroups(namespace string) HTTPRouteGroupNamespaceLister + HTTPRouteGroupListerExpansion +} + +// hTTPRouteGroupLister implements the HTTPRouteGroupLister interface. +type hTTPRouteGroupLister struct { + indexer cache.Indexer +} + +// NewHTTPRouteGroupLister returns a new HTTPRouteGroupLister. +func NewHTTPRouteGroupLister(indexer cache.Indexer) HTTPRouteGroupLister { + return &hTTPRouteGroupLister{indexer: indexer} +} + +// List lists all HTTPRouteGroups in the indexer. +func (s *hTTPRouteGroupLister) List(selector labels.Selector) (ret []*v1alpha3.HTTPRouteGroup, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.HTTPRouteGroup)) + }) + return ret, err +} + +// HTTPRouteGroups returns an object that can list and get HTTPRouteGroups. +func (s *hTTPRouteGroupLister) HTTPRouteGroups(namespace string) HTTPRouteGroupNamespaceLister { + return hTTPRouteGroupNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// HTTPRouteGroupNamespaceLister helps list and get HTTPRouteGroups. +type HTTPRouteGroupNamespaceLister interface { + // List lists all HTTPRouteGroups in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha3.HTTPRouteGroup, err error) + // Get retrieves the HTTPRouteGroup from the indexer for a given namespace and name. + Get(name string) (*v1alpha3.HTTPRouteGroup, error) + HTTPRouteGroupNamespaceListerExpansion +} + +// hTTPRouteGroupNamespaceLister implements the HTTPRouteGroupNamespaceLister +// interface. +type hTTPRouteGroupNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all HTTPRouteGroups in the indexer for a given namespace. +func (s hTTPRouteGroupNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.HTTPRouteGroup, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.HTTPRouteGroup)) + }) + return ret, err +} + +// Get retrieves the HTTPRouteGroup from the indexer for a given namespace and name. +func (s hTTPRouteGroupNamespaceLister) Get(name string) (*v1alpha3.HTTPRouteGroup, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha3.Resource("httproutegroup"), name) + } + return obj.(*v1alpha3.HTTPRouteGroup), nil +} diff --git a/pkg/gen/client/specs/listers/specs/v1alpha3/tcproute.go b/pkg/gen/client/specs/listers/specs/v1alpha3/tcproute.go new file mode 100644 index 0000000..3c4f9da --- /dev/null +++ b/pkg/gen/client/specs/listers/specs/v1alpha3/tcproute.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/specs/v1alpha3" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// TCPRouteLister helps list TCPRoutes. +type TCPRouteLister interface { + // List lists all TCPRoutes in the indexer. + List(selector labels.Selector) (ret []*v1alpha3.TCPRoute, err error) + // TCPRoutes returns an object that can list and get TCPRoutes. + TCPRoutes(namespace string) TCPRouteNamespaceLister + TCPRouteListerExpansion +} + +// tCPRouteLister implements the TCPRouteLister interface. +type tCPRouteLister struct { + indexer cache.Indexer +} + +// NewTCPRouteLister returns a new TCPRouteLister. +func NewTCPRouteLister(indexer cache.Indexer) TCPRouteLister { + return &tCPRouteLister{indexer: indexer} +} + +// List lists all TCPRoutes in the indexer. +func (s *tCPRouteLister) List(selector labels.Selector) (ret []*v1alpha3.TCPRoute, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.TCPRoute)) + }) + return ret, err +} + +// TCPRoutes returns an object that can list and get TCPRoutes. +func (s *tCPRouteLister) TCPRoutes(namespace string) TCPRouteNamespaceLister { + return tCPRouteNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TCPRouteNamespaceLister helps list and get TCPRoutes. +type TCPRouteNamespaceLister interface { + // List lists all TCPRoutes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha3.TCPRoute, err error) + // Get retrieves the TCPRoute from the indexer for a given namespace and name. + Get(name string) (*v1alpha3.TCPRoute, error) + TCPRouteNamespaceListerExpansion +} + +// tCPRouteNamespaceLister implements the TCPRouteNamespaceLister +// interface. +type tCPRouteNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all TCPRoutes in the indexer for a given namespace. +func (s tCPRouteNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.TCPRoute, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.TCPRoute)) + }) + return ret, err +} + +// Get retrieves the TCPRoute from the indexer for a given namespace and name. +func (s tCPRouteNamespaceLister) Get(name string) (*v1alpha3.TCPRoute, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha3.Resource("tcproute"), name) + } + return obj.(*v1alpha3.TCPRoute), nil +} From d4e76b1cd7a33ead5f38d1262dd838a31c80f4e5 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sat, 27 Jun 2020 08:46:51 +0300 Subject: [PATCH 3/4] Fix TrafficSplit schema validation Signed-off-by: stefanprodan --- crds/split.yaml | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/crds/split.yaml b/crds/split.yaml index 8839cb1..e2cd681 100644 --- a/crds/split.yaml +++ b/crds/split.yaml @@ -31,8 +31,6 @@ spec: JSONPath: .spec.service validation: openAPIV3Schema: - required: - - spec properties: spec: type: object @@ -43,6 +41,21 @@ spec: service: description: The apex service of this split. type: string + matches: + description: The HTTP route groups that this traffic split should match. + type: array + items: + type: object + required: ['kind', 'name'] + properties: + kind: + description: Kind of the matching group. + type: string + enum: + - HTTPRouteGroup + name: + description: Name of the matching group. + type: string backends: description: The backend services of this split. type: array @@ -56,18 +69,3 @@ spec: weight: description: Traffic weight value of this backend. type: number - matches: - description: The HTTP route groups that this traffic split should match. - type: array - items: - type: object - required: ['kind', 'name'] - properties: - kind: - description: Kind of the matching group. - type: string - enum: - - HTTPRouteGroup - name: - description: Name of the matching group. - type: string From 41764b0174378714f890022bf8aa40a404e5bbb7 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Tue, 14 Jul 2020 10:01:01 +0300 Subject: [PATCH 4/4] Fix optional API fields Signed-off-by: stefanprodan --- pkg/apis/access/v1alpha2/traffic_target.go | 18 ++++++++++++++---- .../access/v1alpha2/zz_generated.deepcopy.go | 11 +++++++++-- pkg/apis/split/v1alpha3/traffic_split.go | 16 ++++++++++++---- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/pkg/apis/access/v1alpha2/traffic_target.go b/pkg/apis/access/v1alpha2/traffic_target.go index d3484a2..fff17a9 100644 --- a/pkg/apis/access/v1alpha2/traffic_target.go +++ b/pkg/apis/access/v1alpha2/traffic_target.go @@ -31,19 +31,24 @@ type TrafficTargetSpec struct { Destination IdentityBindingSubject `json:"destination"` // Sources are the pod or group of pods to allow ingress traffic - Sources []IdentityBindingSubject `json:"sources"` + // +optional + Sources []IdentityBindingSubject `json:"sources,omitempty"` - // Rules are the traffic rules to allow (HTTPRoutes | TCPRoute), - Rules []TrafficTargetRule `json:"rules"` + // Rules are the traffic rules to allow (HTTPRoutes | TCPRoute) + // +optional + 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"` } @@ -51,12 +56,17 @@ type TrafficTargetRule struct { 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 - Port int `json:"port,omitempty"` + // +optional + Port *int `json:"port,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/access/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/access/v1alpha2/zz_generated.deepcopy.go index ca8416a..3943228 100644 --- a/pkg/apis/access/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/access/v1alpha2/zz_generated.deepcopy.go @@ -25,6 +25,11 @@ import ( // 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 } @@ -128,11 +133,13 @@ func (in *TrafficTargetRule) DeepCopy() *TrafficTargetRule { // 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 - out.Destination = in.Destination + in.Destination.DeepCopyInto(&out.Destination) if in.Sources != nil { in, out := &in.Sources, &out.Sources *out = make([]IdentityBindingSubject, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.Rules != nil { in, out := &in.Rules, &out.Rules diff --git a/pkg/apis/split/v1alpha3/traffic_split.go b/pkg/apis/split/v1alpha3/traffic_split.go index 6ee48d7..6d09fae 100644 --- a/pkg/apis/split/v1alpha3/traffic_split.go +++ b/pkg/apis/split/v1alpha3/traffic_split.go @@ -28,18 +28,26 @@ type TrafficSplit struct { // TrafficSplitSpec is the specification for a TrafficSplit type TrafficSplitSpec struct { - Service string `json:"service,omitempty"` - Backends []TrafficSplitBackend `json:"backends,omitempty"` + // Service represents the apex service + Service string `json:"service"` + + // Backends defines a list of Kubernetes services + // used as the traffic split destination + Backends []TrafficSplitBackend `json:"backends"` - // Matches allows defining a list of HTTP route groups that this traffic split object should match + // Matches allows defining a list of HTTP route groups + // that this traffic split object should match // +optional Matches []corev1.TypedLocalObjectReference `json:"matches,omitempty"` } // TrafficSplitBackend defines a backend type TrafficSplitBackend struct { + // Service is the name of a Kubernetes service Service string `json:"service"` - Weight int `json:"weight"` + + // Weight defines the traffic split percentage + Weight int `json:"weight"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object