Add route table codegen

Signed-off-by: Kevin Dorosh <kcdorosh@gmail.com>
This commit is contained in:
Kevin Dorosh
2020-12-22 10:05:29 -05:00
parent e6aefb8f4b
commit f4aeb98744
18 changed files with 662 additions and 77 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
// +k8s:deepcopy-gen=package
// Package v1 is the v1 version of the API.
// +groupName=gloo.solo.io
// +groupName=gateway.solo.io
package v1
+27 -8
View File
@@ -7,16 +7,35 @@ import (
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// UpstreamGroup is a specification for a Gloo UpstreamGroup resource
type UpstreamGroup struct {
// RouteTable is a specification for a Gloo RouteTable resource
type RouteTable struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec UpstreamGroupSpec `json:"spec"`
Spec RouteTableSpec `json:"spec"`
}
type UpstreamGroupSpec struct {
Destinations []WeightedDestination `json:"destinations,omitempty"`
type RouteTableSpec struct {
Routes []Route `json:"destinations,omitempty"`
}
type Route struct {
Matchers []Matcher `json:"destinations,omitempty"`
Action RouteAction `json:"action,omitempty"`
}
type Matcher struct {
PathSpecifier Matcher_Prefix `json:"path_specifier,omitempty"`
}
type Matcher_Prefix struct {
// If specified, the route is a prefix rule meaning that the prefix must
// match the beginning of the *:path* header.
Prefix string `prefix:"path_specifier,omitempty"`
}
type RouteAction struct {
Destination WeightedDestination `json:"destination,omitempty"`
}
// WeightedDestination attaches a weight to a single destination.
@@ -40,10 +59,10 @@ type ResourceRef struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// UpstreamGroupList is a list of UpstreamGroup resources
type UpstreamGroupList struct {
// RouteTableList is a list of RouteTable resources
type RouteTableList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []UpstreamGroup `json:"items"`
Items []RouteTable `json:"items"`
}
+93 -19
View File
@@ -41,6 +41,39 @@ func (in *Destination) DeepCopy() *Destination {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Matcher) DeepCopyInto(out *Matcher) {
*out = *in
out.PathSpecifier = in.PathSpecifier
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Matcher.
func (in *Matcher) DeepCopy() *Matcher {
if in == nil {
return nil
}
out := new(Matcher)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Matcher_Prefix) DeepCopyInto(out *Matcher_Prefix) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Matcher_Prefix.
func (in *Matcher_Prefix) DeepCopy() *Matcher_Prefix {
if in == nil {
return nil
}
out := new(Matcher_Prefix)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceRef) DeepCopyInto(out *ResourceRef) {
*out = *in
@@ -58,7 +91,46 @@ func (in *ResourceRef) DeepCopy() *ResourceRef {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *UpstreamGroup) DeepCopyInto(out *UpstreamGroup) {
func (in *Route) DeepCopyInto(out *Route) {
*out = *in
if in.Matchers != nil {
in, out := &in.Matchers, &out.Matchers
*out = make([]Matcher, len(*in))
copy(*out, *in)
}
out.Action = in.Action
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Route.
func (in *Route) DeepCopy() *Route {
if in == nil {
return nil
}
out := new(Route)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RouteAction) DeepCopyInto(out *RouteAction) {
*out = *in
out.Destination = in.Destination
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteAction.
func (in *RouteAction) DeepCopy() *RouteAction {
if in == nil {
return nil
}
out := new(RouteAction)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RouteTable) DeepCopyInto(out *RouteTable) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
@@ -66,18 +138,18 @@ func (in *UpstreamGroup) DeepCopyInto(out *UpstreamGroup) {
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamGroup.
func (in *UpstreamGroup) DeepCopy() *UpstreamGroup {
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteTable.
func (in *RouteTable) DeepCopy() *RouteTable {
if in == nil {
return nil
}
out := new(UpstreamGroup)
out := new(RouteTable)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *UpstreamGroup) DeepCopyObject() runtime.Object {
func (in *RouteTable) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
@@ -85,13 +157,13 @@ func (in *UpstreamGroup) DeepCopyObject() runtime.Object {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *UpstreamGroupList) DeepCopyInto(out *UpstreamGroupList) {
func (in *RouteTableList) DeepCopyInto(out *RouteTableList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]UpstreamGroup, len(*in))
*out = make([]RouteTable, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
@@ -99,18 +171,18 @@ func (in *UpstreamGroupList) DeepCopyInto(out *UpstreamGroupList) {
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamGroupList.
func (in *UpstreamGroupList) DeepCopy() *UpstreamGroupList {
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteTableList.
func (in *RouteTableList) DeepCopy() *RouteTableList {
if in == nil {
return nil
}
out := new(UpstreamGroupList)
out := new(RouteTableList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *UpstreamGroupList) DeepCopyObject() runtime.Object {
func (in *RouteTableList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
@@ -118,22 +190,24 @@ func (in *UpstreamGroupList) DeepCopyObject() runtime.Object {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *UpstreamGroupSpec) DeepCopyInto(out *UpstreamGroupSpec) {
func (in *RouteTableSpec) DeepCopyInto(out *RouteTableSpec) {
*out = *in
if in.Destinations != nil {
in, out := &in.Destinations, &out.Destinations
*out = make([]WeightedDestination, len(*in))
copy(*out, *in)
if in.Routes != nil {
in, out := &in.Routes, &out.Routes
*out = make([]Route, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamGroupSpec.
func (in *UpstreamGroupSpec) DeepCopy() *UpstreamGroupSpec {
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteTableSpec.
func (in *RouteTableSpec) DeepCopy() *RouteTableSpec {
if in == nil {
return nil
}
out := new(UpstreamGroupSpec)
out := new(RouteTableSpec)
in.DeepCopyInto(out)
return out
}
+8 -8
View File
@@ -40,7 +40,7 @@ type Interface interface {
AppmeshV1beta2() appmeshv1beta2.AppmeshV1beta2Interface
AppmeshV1beta1() appmeshv1beta1.AppmeshV1beta1Interface
FlaggerV1beta1() flaggerv1beta1.FlaggerV1beta1Interface
GlooV1() gloov1.GlooV1Interface
GatewayV1() gatewayv1.GatewayV1Interface
NetworkingV1alpha3() networkingv1alpha3.NetworkingV1alpha3Interface
ProjectcontourV1() projectcontourv1.ProjectcontourV1Interface
SplitV1alpha1() splitv1alpha1.SplitV1alpha1Interface
@@ -55,7 +55,7 @@ type Clientset struct {
appmeshV1beta2 *appmeshv1beta2.AppmeshV1beta2Client
appmeshV1beta1 *appmeshv1beta1.AppmeshV1beta1Client
flaggerV1beta1 *flaggerv1beta1.FlaggerV1beta1Client
glooV1 *gloov1.GlooV1Client
gatewayV1 *gatewayv1.GatewayV1Client
networkingV1alpha3 *networkingv1alpha3.NetworkingV1alpha3Client
projectcontourV1 *projectcontourv1.ProjectcontourV1Client
splitV1alpha1 *splitv1alpha1.SplitV1alpha1Client
@@ -78,9 +78,9 @@ func (c *Clientset) FlaggerV1beta1() flaggerv1beta1.FlaggerV1beta1Interface {
return c.flaggerV1beta1
}
// GlooV1 retrieves the GlooV1Client
func (c *Clientset) GlooV1() gloov1.GlooV1Interface {
return c.glooV1
// GatewayV1 retrieves the GatewayV1Client
func (c *Clientset) GatewayV1() gatewayv1.GatewayV1Interface {
return c.gatewayV1
}
// NetworkingV1alpha3 retrieves the NetworkingV1alpha3Client
@@ -141,7 +141,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil {
return nil, err
}
cs.glooV1, err = gloov1.NewForConfig(&configShallowCopy)
cs.gatewayV1, err = gatewayv1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
@@ -180,7 +180,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
cs.appmeshV1beta2 = appmeshv1beta2.NewForConfigOrDie(c)
cs.appmeshV1beta1 = appmeshv1beta1.NewForConfigOrDie(c)
cs.flaggerV1beta1 = flaggerv1beta1.NewForConfigOrDie(c)
cs.glooV1 = gloov1.NewForConfigOrDie(c)
cs.gatewayV1 = gatewayv1.NewForConfigOrDie(c)
cs.networkingV1alpha3 = networkingv1alpha3.NewForConfigOrDie(c)
cs.projectcontourV1 = projectcontourv1.NewForConfigOrDie(c)
cs.splitV1alpha1 = splitv1alpha1.NewForConfigOrDie(c)
@@ -197,7 +197,7 @@ func New(c rest.Interface) *Clientset {
cs.appmeshV1beta2 = appmeshv1beta2.New(c)
cs.appmeshV1beta1 = appmeshv1beta1.New(c)
cs.flaggerV1beta1 = flaggerv1beta1.New(c)
cs.glooV1 = gloov1.New(c)
cs.gatewayV1 = gatewayv1.New(c)
cs.networkingV1alpha3 = networkingv1alpha3.New(c)
cs.projectcontourV1 = projectcontourv1.New(c)
cs.splitV1alpha1 = splitv1alpha1.New(c)
@@ -107,9 +107,9 @@ func (c *Clientset) FlaggerV1beta1() flaggerv1beta1.FlaggerV1beta1Interface {
return &fakeflaggerv1beta1.FakeFlaggerV1beta1{Fake: &c.Fake}
}
// GlooV1 retrieves the GlooV1Client
func (c *Clientset) GlooV1() gloov1.GlooV1Interface {
return &fakegloov1.FakeGlooV1{Fake: &c.Fake}
// GatewayV1 retrieves the GatewayV1Client
func (c *Clientset) GatewayV1() gatewayv1.GatewayV1Interface {
return &fakegatewayv1.FakeGatewayV1{Fake: &c.Fake}
}
// NetworkingV1alpha3 retrieves the NetworkingV1alpha3Client
@@ -42,7 +42,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
appmeshv1beta2.AddToScheme,
appmeshv1beta1.AddToScheme,
flaggerv1beta1.AddToScheme,
gloov1.AddToScheme,
gatewayv1.AddToScheme,
networkingv1alpha3.AddToScheme,
projectcontourv1.AddToScheme,
splitv1alpha1.AddToScheme,
@@ -42,7 +42,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
appmeshv1beta2.AddToScheme,
appmeshv1beta1.AddToScheme,
flaggerv1beta1.AddToScheme,
gloov1.AddToScheme,
gatewayv1.AddToScheme,
networkingv1alpha3.AddToScheme,
projectcontourv1.AddToScheme,
splitv1alpha1.AddToScheme,
@@ -24,17 +24,17 @@ import (
testing "k8s.io/client-go/testing"
)
type FakeGlooV1 struct {
type FakeGatewayV1 struct {
*testing.Fake
}
func (c *FakeGlooV1) UpstreamGroups(namespace string) v1.UpstreamGroupInterface {
return &FakeUpstreamGroups{c, namespace}
func (c *FakeGatewayV1) RouteTables(namespace string) v1.RouteTableInterface {
return &FakeRouteTables{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeGlooV1) RESTClient() rest.Interface {
func (c *FakeGatewayV1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}
@@ -0,0 +1,130 @@
/*
Copyright The Flagger Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
gloov1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1"
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"
)
// FakeRouteTables implements RouteTableInterface
type FakeRouteTables struct {
Fake *FakeGatewayV1
ns string
}
var routetablesResource = schema.GroupVersionResource{Group: "gateway.solo.io", Version: "v1", Resource: "routetables"}
var routetablesKind = schema.GroupVersionKind{Group: "gateway.solo.io", Version: "v1", Kind: "RouteTable"}
// Get takes name of the routeTable, and returns the corresponding routeTable object, and an error if there is any.
func (c *FakeRouteTables) Get(ctx context.Context, name string, options v1.GetOptions) (result *gloov1.RouteTable, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(routetablesResource, c.ns, name), &gloov1.RouteTable{})
if obj == nil {
return nil, err
}
return obj.(*gloov1.RouteTable), err
}
// List takes label and field selectors, and returns the list of RouteTables that match those selectors.
func (c *FakeRouteTables) List(ctx context.Context, opts v1.ListOptions) (result *gloov1.RouteTableList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(routetablesResource, routetablesKind, c.ns, opts), &gloov1.RouteTableList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &gloov1.RouteTableList{ListMeta: obj.(*gloov1.RouteTableList).ListMeta}
for _, item := range obj.(*gloov1.RouteTableList).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 routeTables.
func (c *FakeRouteTables) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(routetablesResource, c.ns, opts))
}
// Create takes the representation of a routeTable and creates it. Returns the server's representation of the routeTable, and an error, if there is any.
func (c *FakeRouteTables) Create(ctx context.Context, routeTable *gloov1.RouteTable, opts v1.CreateOptions) (result *gloov1.RouteTable, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(routetablesResource, c.ns, routeTable), &gloov1.RouteTable{})
if obj == nil {
return nil, err
}
return obj.(*gloov1.RouteTable), err
}
// Update takes the representation of a routeTable and updates it. Returns the server's representation of the routeTable, and an error, if there is any.
func (c *FakeRouteTables) Update(ctx context.Context, routeTable *gloov1.RouteTable, opts v1.UpdateOptions) (result *gloov1.RouteTable, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(routetablesResource, c.ns, routeTable), &gloov1.RouteTable{})
if obj == nil {
return nil, err
}
return obj.(*gloov1.RouteTable), err
}
// Delete takes name of the routeTable and deletes it. Returns an error if one occurs.
func (c *FakeRouteTables) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(routetablesResource, c.ns, name), &gloov1.RouteTable{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeRouteTables) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(routetablesResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &gloov1.RouteTableList{})
return err
}
// Patch applies the patch and returns the patched routeTable.
func (c *FakeRouteTables) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *gloov1.RouteTable, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(routetablesResource, c.ns, name, pt, data, subresources...), &gloov1.RouteTable{})
if obj == nil {
return nil, err
}
return obj.(*gloov1.RouteTable), err
}
@@ -18,4 +18,4 @@ limitations under the License.
package v1
type UpstreamGroupExpansion interface{}
type RouteTableExpansion interface{}
@@ -24,22 +24,22 @@ import (
rest "k8s.io/client-go/rest"
)
type GlooV1Interface interface {
type GatewayV1Interface interface {
RESTClient() rest.Interface
UpstreamGroupsGetter
RouteTablesGetter
}
// GlooV1Client is used to interact with features provided by the gloo.solo.io group.
type GlooV1Client struct {
// GatewayV1Client is used to interact with features provided by the gateway.solo.io group.
type GatewayV1Client struct {
restClient rest.Interface
}
func (c *GlooV1Client) UpstreamGroups(namespace string) UpstreamGroupInterface {
return newUpstreamGroups(c, namespace)
func (c *GatewayV1Client) RouteTables(namespace string) RouteTableInterface {
return newRouteTables(c, namespace)
}
// NewForConfig creates a new GlooV1Client for the given config.
func NewForConfig(c *rest.Config) (*GlooV1Client, error) {
// NewForConfig creates a new GatewayV1Client for the given config.
func NewForConfig(c *rest.Config) (*GatewayV1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
@@ -48,12 +48,12 @@ func NewForConfig(c *rest.Config) (*GlooV1Client, error) {
if err != nil {
return nil, err
}
return &GlooV1Client{client}, nil
return &GatewayV1Client{client}, nil
}
// NewForConfigOrDie creates a new GlooV1Client for the given config and
// NewForConfigOrDie creates a new GatewayV1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *GlooV1Client {
func NewForConfigOrDie(c *rest.Config) *GatewayV1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
@@ -61,9 +61,9 @@ func NewForConfigOrDie(c *rest.Config) *GlooV1Client {
return client
}
// New creates a new GlooV1Client for the given RESTClient.
func New(c rest.Interface) *GlooV1Client {
return &GlooV1Client{c}
// New creates a new GatewayV1Client for the given RESTClient.
func New(c rest.Interface) *GatewayV1Client {
return &GatewayV1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
@@ -81,7 +81,7 @@ func setConfigDefaults(config *rest.Config) error {
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *GlooV1Client) RESTClient() rest.Interface {
func (c *GatewayV1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
@@ -0,0 +1,178 @@
/*
Copyright The Flagger Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
"context"
"time"
v1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1"
scheme "github.com/weaveworks/flagger/pkg/client/clientset/versioned/scheme"
metav1 "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"
)
// RouteTablesGetter has a method to return a RouteTableInterface.
// A group's client should implement this interface.
type RouteTablesGetter interface {
RouteTables(namespace string) RouteTableInterface
}
// RouteTableInterface has methods to work with RouteTable resources.
type RouteTableInterface interface {
Create(ctx context.Context, routeTable *v1.RouteTable, opts metav1.CreateOptions) (*v1.RouteTable, error)
Update(ctx context.Context, routeTable *v1.RouteTable, opts metav1.UpdateOptions) (*v1.RouteTable, error)
Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.RouteTable, error)
List(ctx context.Context, opts metav1.ListOptions) (*v1.RouteTableList, error)
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.RouteTable, err error)
RouteTableExpansion
}
// routeTables implements RouteTableInterface
type routeTables struct {
client rest.Interface
ns string
}
// newRouteTables returns a RouteTables
func newRouteTables(c *GatewayV1Client, namespace string) *routeTables {
return &routeTables{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the routeTable, and returns the corresponding routeTable object, and an error if there is any.
func (c *routeTables) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.RouteTable, err error) {
result = &v1.RouteTable{}
err = c.client.Get().
Namespace(c.ns).
Resource("routetables").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of RouteTables that match those selectors.
func (c *routeTables) List(ctx context.Context, opts metav1.ListOptions) (result *v1.RouteTableList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.RouteTableList{}
err = c.client.Get().
Namespace(c.ns).
Resource("routetables").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested routeTables.
func (c *routeTables) Watch(ctx context.Context, opts metav1.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("routetables").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a routeTable and creates it. Returns the server's representation of the routeTable, and an error, if there is any.
func (c *routeTables) Create(ctx context.Context, routeTable *v1.RouteTable, opts metav1.CreateOptions) (result *v1.RouteTable, err error) {
result = &v1.RouteTable{}
err = c.client.Post().
Namespace(c.ns).
Resource("routetables").
VersionedParams(&opts, scheme.ParameterCodec).
Body(routeTable).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a routeTable and updates it. Returns the server's representation of the routeTable, and an error, if there is any.
func (c *routeTables) Update(ctx context.Context, routeTable *v1.RouteTable, opts metav1.UpdateOptions) (result *v1.RouteTable, err error) {
result = &v1.RouteTable{}
err = c.client.Put().
Namespace(c.ns).
Resource("routetables").
Name(routeTable.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(routeTable).
Do(ctx).
Into(result)
return
}
// Delete takes name of the routeTable and deletes it. Returns an error if one occurs.
func (c *routeTables) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("routetables").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *routeTables) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.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("routetables").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched routeTable.
func (c *routeTables) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.RouteTable, err error) {
result = &v1.RouteTable{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("routetables").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
@@ -180,7 +180,7 @@ type SharedInformerFactory interface {
Appmesh() appmesh.Interface
Flagger() flagger.Interface
Gloo() gloo.Interface
Gateway() gloo.Interface
Networking() istio.Interface
Projectcontour() projectcontour.Interface
Split() smi.Interface
@@ -195,7 +195,7 @@ func (f *sharedInformerFactory) Flagger() flagger.Interface {
return flagger.New(f, f.namespace, f.tweakListOptions)
}
func (f *sharedInformerFactory) Gloo() gloo.Interface {
func (f *sharedInformerFactory) Gateway() gloo.Interface {
return gloo.New(f, f.namespace, f.tweakListOptions)
}
@@ -84,9 +84,9 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case flaggerv1beta1.SchemeGroupVersion.WithResource("metrictemplates"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Flagger().V1beta1().MetricTemplates().Informer()}, nil
// Group=gloo.solo.io, Version=v1
case v1.SchemeGroupVersion.WithResource("upstreamgroups"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Gloo().V1().UpstreamGroups().Informer()}, nil
// Group=gateway.solo.io, Version=v1
case v1.SchemeGroupVersion.WithResource("routetables"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Gateway().V1().RouteTables().Informer()}, nil
// Group=networking.istio.io, Version=v1alpha3
case v1alpha3.SchemeGroupVersion.WithResource("destinationrules"):
@@ -24,8 +24,8 @@ import (
// Interface provides access to all the informers in this group version.
type Interface interface {
// UpstreamGroups returns a UpstreamGroupInformer.
UpstreamGroups() UpstreamGroupInformer
// RouteTables returns a RouteTableInformer.
RouteTables() RouteTableInformer
}
type version struct {
@@ -39,7 +39,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// UpstreamGroups returns a UpstreamGroupInformer.
func (v *version) UpstreamGroups() UpstreamGroupInformer {
return &upstreamGroupInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
// RouteTables returns a RouteTableInformer.
func (v *version) RouteTables() RouteTableInformer {
return &routeTableInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
@@ -0,0 +1,90 @@
/*
Copyright The Flagger Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
"context"
time "time"
gloov1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1"
versioned "github.com/weaveworks/flagger/pkg/client/clientset/versioned"
internalinterfaces "github.com/weaveworks/flagger/pkg/client/informers/externalversions/internalinterfaces"
v1 "github.com/weaveworks/flagger/pkg/client/listers/gloo/v1"
metav1 "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"
)
// RouteTableInformer provides access to a shared informer and lister for
// RouteTables.
type RouteTableInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.RouteTableLister
}
type routeTableInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewRouteTableInformer constructs a new informer for RouteTable 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 NewRouteTableInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredRouteTableInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredRouteTableInformer constructs a new informer for RouteTable 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 NewFilteredRouteTableInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.GatewayV1().RouteTables(namespace).List(context.TODO(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.GatewayV1().RouteTables(namespace).Watch(context.TODO(), options)
},
},
&gloov1.RouteTable{},
resyncPeriod,
indexers,
)
}
func (f *routeTableInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredRouteTableInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *routeTableInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&gloov1.RouteTable{}, f.defaultInformer)
}
func (f *routeTableInformer) Lister() v1.RouteTableLister {
return v1.NewRouteTableLister(f.Informer().GetIndexer())
}
@@ -18,10 +18,10 @@ limitations under the License.
package v1
// UpstreamGroupListerExpansion allows custom methods to be added to
// UpstreamGroupLister.
type UpstreamGroupListerExpansion interface{}
// RouteTableListerExpansion allows custom methods to be added to
// RouteTableLister.
type RouteTableListerExpansion interface{}
// UpstreamGroupNamespaceListerExpansion allows custom methods to be added to
// UpstreamGroupNamespaceLister.
type UpstreamGroupNamespaceListerExpansion interface{}
// RouteTableNamespaceListerExpansion allows custom methods to be added to
// RouteTableNamespaceLister.
type RouteTableNamespaceListerExpansion interface{}
+94
View File
@@ -0,0 +1,94 @@
/*
Copyright The Flagger Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1
import (
v1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// RouteTableLister helps list RouteTables.
type RouteTableLister interface {
// List lists all RouteTables in the indexer.
List(selector labels.Selector) (ret []*v1.RouteTable, err error)
// RouteTables returns an object that can list and get RouteTables.
RouteTables(namespace string) RouteTableNamespaceLister
RouteTableListerExpansion
}
// routeTableLister implements the RouteTableLister interface.
type routeTableLister struct {
indexer cache.Indexer
}
// NewRouteTableLister returns a new RouteTableLister.
func NewRouteTableLister(indexer cache.Indexer) RouteTableLister {
return &routeTableLister{indexer: indexer}
}
// List lists all RouteTables in the indexer.
func (s *routeTableLister) List(selector labels.Selector) (ret []*v1.RouteTable, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.RouteTable))
})
return ret, err
}
// RouteTables returns an object that can list and get RouteTables.
func (s *routeTableLister) RouteTables(namespace string) RouteTableNamespaceLister {
return routeTableNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// RouteTableNamespaceLister helps list and get RouteTables.
type RouteTableNamespaceLister interface {
// List lists all RouteTables in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1.RouteTable, err error)
// Get retrieves the RouteTable from the indexer for a given namespace and name.
Get(name string) (*v1.RouteTable, error)
RouteTableNamespaceListerExpansion
}
// routeTableNamespaceLister implements the RouteTableNamespaceLister
// interface.
type routeTableNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all RouteTables in the indexer for a given namespace.
func (s routeTableNamespaceLister) List(selector labels.Selector) (ret []*v1.RouteTable, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1.RouteTable))
})
return ret, err
}
// Get retrieves the RouteTable from the indexer for a given namespace and name.
func (s routeTableNamespaceLister) Get(name string) (*v1.RouteTable, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1.Resource("routetable"), name)
}
return obj.(*v1.RouteTable), nil
}