From 6d4a1ec0f6a34c36cb3c4f9fa667e99d371fc9fd Mon Sep 17 00:00:00 2001 From: Omar Hammami <58956785+puertomontt@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:40:07 -0600 Subject: [PATCH] add istio types (#42) --- codegen/istio_groups.go | 19 + .../extensions.istio.io/v1alpha1/clients.go | 214 +++++++ .../v1alpha1/controller/event_handlers.go | 125 ++++ .../controller/mocks/event_handlers.go | 136 ++++ .../mocks/multicluster_reconcilers.go | 131 ++++ .../v1alpha1/controller/mocks/reconcilers.go | 199 ++++++ .../controller/multicluster_reconcilers.go | 90 +++ .../v1alpha1/controller/reconcilers.go | 135 ++++ .../v1alpha1/mocks/clients.go | 594 ++++++++++++++++++ .../v1alpha1/providers/client_providers.go | 46 ++ .../v1alpha1/sets/mocks/sets.go | 272 ++++++++ .../extensions.istio.io/v1alpha1/sets/sets.go | 237 +++++++ .../v1alpha1/type_helpers.go | 11 + .../networking.istio.io/v1beta1/clients.go | 149 +++++ .../v1beta1/controller/event_handlers.go | 107 ++++ .../controller/mocks/event_handlers.go | 121 ++++ .../mocks/multicluster_reconcilers.go | 115 ++++ .../v1beta1/controller/mocks/reconcilers.go | 183 ++++++ .../controller/multicluster_reconcilers.go | 71 +++ .../v1beta1/controller/reconcilers.go | 117 ++++ .../v1beta1/mocks/clients.go | 518 +++++++++++++++ .../v1beta1/providers/client_providers.go | 28 + .../v1beta1/sets/mocks/sets.go | 256 ++++++++ .../networking.istio.io/v1beta1/sets/sets.go | 223 +++++++ .../v1beta1/type_helpers.go | 3 + .../security.istio.io/v1beta1/clients.go | 149 +++++ .../v1beta1/controller/event_handlers.go | 107 ++++ .../controller/mocks/event_handlers.go | 121 ++++ .../mocks/multicluster_reconcilers.go | 115 ++++ .../v1beta1/controller/mocks/reconcilers.go | 183 ++++++ .../controller/multicluster_reconcilers.go | 71 +++ .../v1beta1/controller/reconcilers.go | 117 ++++ .../v1beta1/mocks/clients.go | 518 +++++++++++++++ .../v1beta1/providers/client_providers.go | 28 + .../v1beta1/sets/mocks/sets.go | 256 ++++++++ .../security.istio.io/v1beta1/sets/sets.go | 223 +++++++ .../security.istio.io/v1beta1/type_helpers.go | 3 + 37 files changed, 5991 insertions(+) create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/clients.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/controller/event_handlers.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/event_handlers.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/multicluster_reconcilers.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/reconcilers.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/controller/multicluster_reconcilers.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/controller/reconcilers.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/mocks/clients.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/providers/client_providers.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/sets/mocks/sets.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/sets/sets.go create mode 100644 pkg/api/istio/extensions.istio.io/v1alpha1/type_helpers.go diff --git a/codegen/istio_groups.go b/codegen/istio_groups.go index 2664436..53c2fe3 100644 --- a/codegen/istio_groups.go +++ b/codegen/istio_groups.go @@ -2,6 +2,7 @@ package codegen import ( "github.com/solo-io/skv2/codegen/model" + extensionsv1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" networkingv1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3" networkingv1beta1 "istio.io/client-go/pkg/apis/networking/v1beta1" "istio.io/client-go/pkg/apis/security/v1beta1" @@ -30,6 +31,9 @@ func istioGroups() []model.Group { { Kind: "Gateway", }, + { + Kind: "ProxyConfig", + }, { Kind: "ServiceEntry", }, @@ -72,6 +76,9 @@ func istioGroups() []model.Group { { Kind: "PeerAuthentication", }, + { + Kind: "RequestAuthentication", + }, }, CustomTypesImportPath: "istio.io/client-go/pkg/apis/security/v1beta1", ApiRoot: istioApiRoot, @@ -100,5 +107,17 @@ func istioGroups() []model.Group { ApiRoot: istioApiRoot, PointerSlices: true, }, + { + GroupVersion: extensionsv1alpha1.SchemeGroupVersion, + Module: istioModule, + Resources: []model.Resource{ + { + Kind: "WasmPlugin", + }, + }, + CustomTypesImportPath: "istio.io/client-go/pkg/apis/extensions/v1alpha1", + ApiRoot: istioApiRoot, + PointerSlices: true, + }, } } diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/clients.go b/pkg/api/istio/extensions.istio.io/v1alpha1/clients.go new file mode 100644 index 0000000..93b2cad --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/clients.go @@ -0,0 +1,214 @@ +// Code generated by skv2. DO NOT EDIT. + +//go:generate mockgen -source ./clients.go -destination mocks/clients.go + +package v1alpha1 + +import ( + "context" + + "github.com/solo-io/skv2/pkg/controllerutils" + "github.com/solo-io/skv2/pkg/multicluster" + extensions_istio_io_v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// MulticlusterClientset for the extensions.istio.io/v1alpha1 APIs +type MulticlusterClientset interface { + // Cluster returns a Clientset for the given cluster + Cluster(cluster string) (Clientset, error) +} + +type multiclusterClientset struct { + client multicluster.Client +} + +func NewMulticlusterClientset(client multicluster.Client) MulticlusterClientset { + return &multiclusterClientset{client: client} +} + +func (m *multiclusterClientset) Cluster(cluster string) (Clientset, error) { + client, err := m.client.Cluster(cluster) + if err != nil { + return nil, err + } + return NewClientset(client), nil +} + +// clienset for the extensions.istio.io/v1alpha1 APIs +type Clientset interface { + // clienset for the extensions.istio.io/v1alpha1/v1alpha1 APIs + WasmPlugins() WasmPluginClient +} + +type clientSet struct { + client client.Client +} + +func NewClientsetFromConfig(cfg *rest.Config) (Clientset, error) { + scheme := scheme.Scheme + if err := extensions_istio_io_v1alpha1.SchemeBuilder.AddToScheme(scheme); err != nil { + return nil, err + } + client, err := client.New(cfg, client.Options{ + Scheme: scheme, + }) + if err != nil { + return nil, err + } + return NewClientset(client), nil +} + +func NewClientset(client client.Client) Clientset { + return &clientSet{client: client} +} + +// clienset for the extensions.istio.io/v1alpha1/v1alpha1 APIs +func (c *clientSet) WasmPlugins() WasmPluginClient { + return NewWasmPluginClient(c.client) +} + +// Reader knows how to read and list WasmPlugins. +type WasmPluginReader interface { + // Get retrieves a WasmPlugin for the given object key + GetWasmPlugin(ctx context.Context, key client.ObjectKey) (*extensions_istio_io_v1alpha1.WasmPlugin, error) + + // List retrieves list of WasmPlugins for a given namespace and list options. + ListWasmPlugin(ctx context.Context, opts ...client.ListOption) (*extensions_istio_io_v1alpha1.WasmPluginList, error) +} + +// WasmPluginTransitionFunction instructs the WasmPluginWriter how to transition between an existing +// WasmPlugin object and a desired on an Upsert +type WasmPluginTransitionFunction func(existing, desired *extensions_istio_io_v1alpha1.WasmPlugin) error + +// Writer knows how to create, delete, and update WasmPlugins. +type WasmPluginWriter interface { + // Create saves the WasmPlugin object. + CreateWasmPlugin(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, opts ...client.CreateOption) error + + // Delete deletes the WasmPlugin object. + DeleteWasmPlugin(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error + + // Update updates the given WasmPlugin object. + UpdateWasmPlugin(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, opts ...client.UpdateOption) error + + // Patch patches the given WasmPlugin object. + PatchWasmPlugin(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, patch client.Patch, opts ...client.PatchOption) error + + // DeleteAllOf deletes all WasmPlugin objects matching the given options. + DeleteAllOfWasmPlugin(ctx context.Context, opts ...client.DeleteAllOfOption) error + + // Create or Update the WasmPlugin object. + UpsertWasmPlugin(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, transitionFuncs ...WasmPluginTransitionFunction) error +} + +// StatusWriter knows how to update status subresource of a WasmPlugin object. +type WasmPluginStatusWriter interface { + // Update updates the fields corresponding to the status subresource for the + // given WasmPlugin object. + UpdateWasmPluginStatus(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, opts ...client.SubResourceUpdateOption) error + + // Patch patches the given WasmPlugin object's subresource. + PatchWasmPluginStatus(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, patch client.Patch, opts ...client.SubResourcePatchOption) error +} + +// Client knows how to perform CRUD operations on WasmPlugins. +type WasmPluginClient interface { + WasmPluginReader + WasmPluginWriter + WasmPluginStatusWriter +} + +type wasmPluginClient struct { + client client.Client +} + +func NewWasmPluginClient(client client.Client) *wasmPluginClient { + return &wasmPluginClient{client: client} +} + +func (c *wasmPluginClient) GetWasmPlugin(ctx context.Context, key client.ObjectKey) (*extensions_istio_io_v1alpha1.WasmPlugin, error) { + obj := &extensions_istio_io_v1alpha1.WasmPlugin{} + if err := c.client.Get(ctx, key, obj); err != nil { + return nil, err + } + return obj, nil +} + +func (c *wasmPluginClient) ListWasmPlugin(ctx context.Context, opts ...client.ListOption) (*extensions_istio_io_v1alpha1.WasmPluginList, error) { + list := &extensions_istio_io_v1alpha1.WasmPluginList{} + if err := c.client.List(ctx, list, opts...); err != nil { + return nil, err + } + return list, nil +} + +func (c *wasmPluginClient) CreateWasmPlugin(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, opts ...client.CreateOption) error { + return c.client.Create(ctx, obj, opts...) +} + +func (c *wasmPluginClient) DeleteWasmPlugin(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + obj := &extensions_istio_io_v1alpha1.WasmPlugin{} + obj.SetName(key.Name) + obj.SetNamespace(key.Namespace) + return c.client.Delete(ctx, obj, opts...) +} + +func (c *wasmPluginClient) UpdateWasmPlugin(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, opts ...client.UpdateOption) error { + return c.client.Update(ctx, obj, opts...) +} + +func (c *wasmPluginClient) PatchWasmPlugin(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, patch client.Patch, opts ...client.PatchOption) error { + return c.client.Patch(ctx, obj, patch, opts...) +} + +func (c *wasmPluginClient) DeleteAllOfWasmPlugin(ctx context.Context, opts ...client.DeleteAllOfOption) error { + obj := &extensions_istio_io_v1alpha1.WasmPlugin{} + return c.client.DeleteAllOf(ctx, obj, opts...) +} + +func (c *wasmPluginClient) UpsertWasmPlugin(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, transitionFuncs ...WasmPluginTransitionFunction) error { + genericTxFunc := func(existing, desired runtime.Object) error { + for _, txFunc := range transitionFuncs { + if err := txFunc(existing.(*extensions_istio_io_v1alpha1.WasmPlugin), desired.(*extensions_istio_io_v1alpha1.WasmPlugin)); err != nil { + return err + } + } + return nil + } + _, err := controllerutils.Upsert(ctx, c.client, obj, genericTxFunc) + return err +} + +func (c *wasmPluginClient) UpdateWasmPluginStatus(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, opts ...client.SubResourceUpdateOption) error { + return c.client.Status().Update(ctx, obj, opts...) +} + +func (c *wasmPluginClient) PatchWasmPluginStatus(ctx context.Context, obj *extensions_istio_io_v1alpha1.WasmPlugin, patch client.Patch, opts ...client.SubResourcePatchOption) error { + return c.client.Status().Patch(ctx, obj, patch, opts...) +} + +// Provides WasmPluginClients for multiple clusters. +type MulticlusterWasmPluginClient interface { + // Cluster returns a WasmPluginClient for the given cluster + Cluster(cluster string) (WasmPluginClient, error) +} + +type multiclusterWasmPluginClient struct { + client multicluster.Client +} + +func NewMulticlusterWasmPluginClient(client multicluster.Client) MulticlusterWasmPluginClient { + return &multiclusterWasmPluginClient{client: client} +} + +func (m *multiclusterWasmPluginClient) Cluster(cluster string) (WasmPluginClient, error) { + client, err := m.client.Cluster(cluster) + if err != nil { + return nil, err + } + return NewWasmPluginClient(client), nil +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/controller/event_handlers.go b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/event_handlers.go new file mode 100644 index 0000000..ca9ebf3 --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/event_handlers.go @@ -0,0 +1,125 @@ +// Code generated by skv2. DO NOT EDIT. + +//go:generate mockgen -source ./event_handlers.go -destination mocks/event_handlers.go + +// Definitions for the Kubernetes Controllers +package controller + +import ( + "context" + + extensions_istio_io_v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + + "github.com/pkg/errors" + "github.com/solo-io/skv2/pkg/events" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +// Handle events for the WasmPlugin Resource +// DEPRECATED: Prefer reconciler pattern. +type WasmPluginEventHandler interface { + CreateWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) error + UpdateWasmPlugin(old, new *extensions_istio_io_v1alpha1.WasmPlugin) error + DeleteWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) error + GenericWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) error +} + +type WasmPluginEventHandlerFuncs struct { + OnCreate func(obj *extensions_istio_io_v1alpha1.WasmPlugin) error + OnUpdate func(old, new *extensions_istio_io_v1alpha1.WasmPlugin) error + OnDelete func(obj *extensions_istio_io_v1alpha1.WasmPlugin) error + OnGeneric func(obj *extensions_istio_io_v1alpha1.WasmPlugin) error +} + +func (f *WasmPluginEventHandlerFuncs) CreateWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) error { + if f.OnCreate == nil { + return nil + } + return f.OnCreate(obj) +} + +func (f *WasmPluginEventHandlerFuncs) DeleteWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) error { + if f.OnDelete == nil { + return nil + } + return f.OnDelete(obj) +} + +func (f *WasmPluginEventHandlerFuncs) UpdateWasmPlugin(objOld, objNew *extensions_istio_io_v1alpha1.WasmPlugin) error { + if f.OnUpdate == nil { + return nil + } + return f.OnUpdate(objOld, objNew) +} + +func (f *WasmPluginEventHandlerFuncs) GenericWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) error { + if f.OnGeneric == nil { + return nil + } + return f.OnGeneric(obj) +} + +type WasmPluginEventWatcher interface { + AddEventHandler(ctx context.Context, h WasmPluginEventHandler, predicates ...predicate.Predicate) error +} + +type wasmPluginEventWatcher struct { + watcher events.EventWatcher +} + +func NewWasmPluginEventWatcher(name string, mgr manager.Manager) WasmPluginEventWatcher { + return &wasmPluginEventWatcher{ + watcher: events.NewWatcher(name, mgr, &extensions_istio_io_v1alpha1.WasmPlugin{}), + } +} + +func (c *wasmPluginEventWatcher) AddEventHandler(ctx context.Context, h WasmPluginEventHandler, predicates ...predicate.Predicate) error { + handler := genericWasmPluginHandler{handler: h} + if err := c.watcher.Watch(ctx, handler, predicates...); err != nil { + return err + } + return nil +} + +// genericWasmPluginHandler implements a generic events.EventHandler +type genericWasmPluginHandler struct { + handler WasmPluginEventHandler +} + +func (h genericWasmPluginHandler) Create(object client.Object) error { + obj, ok := object.(*extensions_istio_io_v1alpha1.WasmPlugin) + if !ok { + return errors.Errorf("internal error: WasmPlugin handler received event for %T", object) + } + return h.handler.CreateWasmPlugin(obj) +} + +func (h genericWasmPluginHandler) Delete(object client.Object) error { + obj, ok := object.(*extensions_istio_io_v1alpha1.WasmPlugin) + if !ok { + return errors.Errorf("internal error: WasmPlugin handler received event for %T", object) + } + return h.handler.DeleteWasmPlugin(obj) +} + +func (h genericWasmPluginHandler) Update(old, new client.Object) error { + objOld, ok := old.(*extensions_istio_io_v1alpha1.WasmPlugin) + if !ok { + return errors.Errorf("internal error: WasmPlugin handler received event for %T", old) + } + objNew, ok := new.(*extensions_istio_io_v1alpha1.WasmPlugin) + if !ok { + return errors.Errorf("internal error: WasmPlugin handler received event for %T", new) + } + return h.handler.UpdateWasmPlugin(objOld, objNew) +} + +func (h genericWasmPluginHandler) Generic(object client.Object) error { + obj, ok := object.(*extensions_istio_io_v1alpha1.WasmPlugin) + if !ok { + return errors.Errorf("internal error: WasmPlugin handler received event for %T", object) + } + return h.handler.GenericWasmPlugin(obj) +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/event_handlers.go b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/event_handlers.go new file mode 100644 index 0000000..a0c8a36 --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/event_handlers.go @@ -0,0 +1,136 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./event_handlers.go + +// Package mock_controller is a generated GoMock package. +package mock_controller + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + controller "github.com/solo-io/external-apis/pkg/api/istio/extensions.istio.io/v1alpha1/controller" + v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + predicate "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +// MockWasmPluginEventHandler is a mock of WasmPluginEventHandler interface. +type MockWasmPluginEventHandler struct { + ctrl *gomock.Controller + recorder *MockWasmPluginEventHandlerMockRecorder +} + +// MockWasmPluginEventHandlerMockRecorder is the mock recorder for MockWasmPluginEventHandler. +type MockWasmPluginEventHandlerMockRecorder struct { + mock *MockWasmPluginEventHandler +} + +// NewMockWasmPluginEventHandler creates a new mock instance. +func NewMockWasmPluginEventHandler(ctrl *gomock.Controller) *MockWasmPluginEventHandler { + mock := &MockWasmPluginEventHandler{ctrl: ctrl} + mock.recorder = &MockWasmPluginEventHandlerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginEventHandler) EXPECT() *MockWasmPluginEventHandlerMockRecorder { + return m.recorder +} + +// CreateWasmPlugin mocks base method. +func (m *MockWasmPluginEventHandler) CreateWasmPlugin(obj *v1alpha1.WasmPlugin) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWasmPlugin", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateWasmPlugin indicates an expected call of CreateWasmPlugin. +func (mr *MockWasmPluginEventHandlerMockRecorder) CreateWasmPlugin(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWasmPlugin", reflect.TypeOf((*MockWasmPluginEventHandler)(nil).CreateWasmPlugin), obj) +} + +// DeleteWasmPlugin mocks base method. +func (m *MockWasmPluginEventHandler) DeleteWasmPlugin(obj *v1alpha1.WasmPlugin) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteWasmPlugin", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteWasmPlugin indicates an expected call of DeleteWasmPlugin. +func (mr *MockWasmPluginEventHandlerMockRecorder) DeleteWasmPlugin(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteWasmPlugin", reflect.TypeOf((*MockWasmPluginEventHandler)(nil).DeleteWasmPlugin), obj) +} + +// GenericWasmPlugin mocks base method. +func (m *MockWasmPluginEventHandler) GenericWasmPlugin(obj *v1alpha1.WasmPlugin) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GenericWasmPlugin", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// GenericWasmPlugin indicates an expected call of GenericWasmPlugin. +func (mr *MockWasmPluginEventHandlerMockRecorder) GenericWasmPlugin(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenericWasmPlugin", reflect.TypeOf((*MockWasmPluginEventHandler)(nil).GenericWasmPlugin), obj) +} + +// UpdateWasmPlugin mocks base method. +func (m *MockWasmPluginEventHandler) UpdateWasmPlugin(old, new *v1alpha1.WasmPlugin) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateWasmPlugin", old, new) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWasmPlugin indicates an expected call of UpdateWasmPlugin. +func (mr *MockWasmPluginEventHandlerMockRecorder) UpdateWasmPlugin(old, new interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWasmPlugin", reflect.TypeOf((*MockWasmPluginEventHandler)(nil).UpdateWasmPlugin), old, new) +} + +// MockWasmPluginEventWatcher is a mock of WasmPluginEventWatcher interface. +type MockWasmPluginEventWatcher struct { + ctrl *gomock.Controller + recorder *MockWasmPluginEventWatcherMockRecorder +} + +// MockWasmPluginEventWatcherMockRecorder is the mock recorder for MockWasmPluginEventWatcher. +type MockWasmPluginEventWatcherMockRecorder struct { + mock *MockWasmPluginEventWatcher +} + +// NewMockWasmPluginEventWatcher creates a new mock instance. +func NewMockWasmPluginEventWatcher(ctrl *gomock.Controller) *MockWasmPluginEventWatcher { + mock := &MockWasmPluginEventWatcher{ctrl: ctrl} + mock.recorder = &MockWasmPluginEventWatcherMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginEventWatcher) EXPECT() *MockWasmPluginEventWatcherMockRecorder { + return m.recorder +} + +// AddEventHandler mocks base method. +func (m *MockWasmPluginEventWatcher) AddEventHandler(ctx context.Context, h controller.WasmPluginEventHandler, predicates ...predicate.Predicate) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, h} + for _, a := range predicates { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AddEventHandler", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddEventHandler indicates an expected call of AddEventHandler. +func (mr *MockWasmPluginEventWatcherMockRecorder) AddEventHandler(ctx, h interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, h}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddEventHandler", reflect.TypeOf((*MockWasmPluginEventWatcher)(nil).AddEventHandler), varargs...) +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/multicluster_reconcilers.go b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/multicluster_reconcilers.go new file mode 100644 index 0000000..4172718 --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/multicluster_reconcilers.go @@ -0,0 +1,131 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./multicluster_reconcilers.go + +// Package mock_controller is a generated GoMock package. +package mock_controller + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + controller "github.com/solo-io/external-apis/pkg/api/istio/extensions.istio.io/v1alpha1/controller" + reconcile "github.com/solo-io/skv2/pkg/reconcile" + v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + predicate "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +// MockMulticlusterWasmPluginReconciler is a mock of MulticlusterWasmPluginReconciler interface. +type MockMulticlusterWasmPluginReconciler struct { + ctrl *gomock.Controller + recorder *MockMulticlusterWasmPluginReconcilerMockRecorder +} + +// MockMulticlusterWasmPluginReconcilerMockRecorder is the mock recorder for MockMulticlusterWasmPluginReconciler. +type MockMulticlusterWasmPluginReconcilerMockRecorder struct { + mock *MockMulticlusterWasmPluginReconciler +} + +// NewMockMulticlusterWasmPluginReconciler creates a new mock instance. +func NewMockMulticlusterWasmPluginReconciler(ctrl *gomock.Controller) *MockMulticlusterWasmPluginReconciler { + mock := &MockMulticlusterWasmPluginReconciler{ctrl: ctrl} + mock.recorder = &MockMulticlusterWasmPluginReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterWasmPluginReconciler) EXPECT() *MockMulticlusterWasmPluginReconcilerMockRecorder { + return m.recorder +} + +// ReconcileWasmPlugin mocks base method. +func (m *MockMulticlusterWasmPluginReconciler) ReconcileWasmPlugin(clusterName string, obj *v1alpha1.WasmPlugin) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileWasmPlugin", clusterName, obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileWasmPlugin indicates an expected call of ReconcileWasmPlugin. +func (mr *MockMulticlusterWasmPluginReconcilerMockRecorder) ReconcileWasmPlugin(clusterName, obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileWasmPlugin", reflect.TypeOf((*MockMulticlusterWasmPluginReconciler)(nil).ReconcileWasmPlugin), clusterName, obj) +} + +// MockMulticlusterWasmPluginDeletionReconciler is a mock of MulticlusterWasmPluginDeletionReconciler interface. +type MockMulticlusterWasmPluginDeletionReconciler struct { + ctrl *gomock.Controller + recorder *MockMulticlusterWasmPluginDeletionReconcilerMockRecorder +} + +// MockMulticlusterWasmPluginDeletionReconcilerMockRecorder is the mock recorder for MockMulticlusterWasmPluginDeletionReconciler. +type MockMulticlusterWasmPluginDeletionReconcilerMockRecorder struct { + mock *MockMulticlusterWasmPluginDeletionReconciler +} + +// NewMockMulticlusterWasmPluginDeletionReconciler creates a new mock instance. +func NewMockMulticlusterWasmPluginDeletionReconciler(ctrl *gomock.Controller) *MockMulticlusterWasmPluginDeletionReconciler { + mock := &MockMulticlusterWasmPluginDeletionReconciler{ctrl: ctrl} + mock.recorder = &MockMulticlusterWasmPluginDeletionReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterWasmPluginDeletionReconciler) EXPECT() *MockMulticlusterWasmPluginDeletionReconcilerMockRecorder { + return m.recorder +} + +// ReconcileWasmPluginDeletion mocks base method. +func (m *MockMulticlusterWasmPluginDeletionReconciler) ReconcileWasmPluginDeletion(clusterName string, req reconcile.Request) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileWasmPluginDeletion", clusterName, req) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReconcileWasmPluginDeletion indicates an expected call of ReconcileWasmPluginDeletion. +func (mr *MockMulticlusterWasmPluginDeletionReconcilerMockRecorder) ReconcileWasmPluginDeletion(clusterName, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileWasmPluginDeletion", reflect.TypeOf((*MockMulticlusterWasmPluginDeletionReconciler)(nil).ReconcileWasmPluginDeletion), clusterName, req) +} + +// MockMulticlusterWasmPluginReconcileLoop is a mock of MulticlusterWasmPluginReconcileLoop interface. +type MockMulticlusterWasmPluginReconcileLoop struct { + ctrl *gomock.Controller + recorder *MockMulticlusterWasmPluginReconcileLoopMockRecorder +} + +// MockMulticlusterWasmPluginReconcileLoopMockRecorder is the mock recorder for MockMulticlusterWasmPluginReconcileLoop. +type MockMulticlusterWasmPluginReconcileLoopMockRecorder struct { + mock *MockMulticlusterWasmPluginReconcileLoop +} + +// NewMockMulticlusterWasmPluginReconcileLoop creates a new mock instance. +func NewMockMulticlusterWasmPluginReconcileLoop(ctrl *gomock.Controller) *MockMulticlusterWasmPluginReconcileLoop { + mock := &MockMulticlusterWasmPluginReconcileLoop{ctrl: ctrl} + mock.recorder = &MockMulticlusterWasmPluginReconcileLoopMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterWasmPluginReconcileLoop) EXPECT() *MockMulticlusterWasmPluginReconcileLoopMockRecorder { + return m.recorder +} + +// AddMulticlusterWasmPluginReconciler mocks base method. +func (m *MockMulticlusterWasmPluginReconcileLoop) AddMulticlusterWasmPluginReconciler(ctx context.Context, rec controller.MulticlusterWasmPluginReconciler, predicates ...predicate.Predicate) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, rec} + for _, a := range predicates { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "AddMulticlusterWasmPluginReconciler", varargs...) +} + +// AddMulticlusterWasmPluginReconciler indicates an expected call of AddMulticlusterWasmPluginReconciler. +func (mr *MockMulticlusterWasmPluginReconcileLoopMockRecorder) AddMulticlusterWasmPluginReconciler(ctx, rec interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, rec}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMulticlusterWasmPluginReconciler", reflect.TypeOf((*MockMulticlusterWasmPluginReconcileLoop)(nil).AddMulticlusterWasmPluginReconciler), varargs...) +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/reconcilers.go b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/reconcilers.go new file mode 100644 index 0000000..3737a1a --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/mocks/reconcilers.go @@ -0,0 +1,199 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./reconcilers.go + +// Package mock_controller is a generated GoMock package. +package mock_controller + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + controller "github.com/solo-io/external-apis/pkg/api/istio/extensions.istio.io/v1alpha1/controller" + reconcile "github.com/solo-io/skv2/pkg/reconcile" + v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + predicate "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +// MockWasmPluginReconciler is a mock of WasmPluginReconciler interface. +type MockWasmPluginReconciler struct { + ctrl *gomock.Controller + recorder *MockWasmPluginReconcilerMockRecorder +} + +// MockWasmPluginReconcilerMockRecorder is the mock recorder for MockWasmPluginReconciler. +type MockWasmPluginReconcilerMockRecorder struct { + mock *MockWasmPluginReconciler +} + +// NewMockWasmPluginReconciler creates a new mock instance. +func NewMockWasmPluginReconciler(ctrl *gomock.Controller) *MockWasmPluginReconciler { + mock := &MockWasmPluginReconciler{ctrl: ctrl} + mock.recorder = &MockWasmPluginReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginReconciler) EXPECT() *MockWasmPluginReconcilerMockRecorder { + return m.recorder +} + +// ReconcileWasmPlugin mocks base method. +func (m *MockWasmPluginReconciler) ReconcileWasmPlugin(obj *v1alpha1.WasmPlugin) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileWasmPlugin", obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileWasmPlugin indicates an expected call of ReconcileWasmPlugin. +func (mr *MockWasmPluginReconcilerMockRecorder) ReconcileWasmPlugin(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileWasmPlugin", reflect.TypeOf((*MockWasmPluginReconciler)(nil).ReconcileWasmPlugin), obj) +} + +// MockWasmPluginDeletionReconciler is a mock of WasmPluginDeletionReconciler interface. +type MockWasmPluginDeletionReconciler struct { + ctrl *gomock.Controller + recorder *MockWasmPluginDeletionReconcilerMockRecorder +} + +// MockWasmPluginDeletionReconcilerMockRecorder is the mock recorder for MockWasmPluginDeletionReconciler. +type MockWasmPluginDeletionReconcilerMockRecorder struct { + mock *MockWasmPluginDeletionReconciler +} + +// NewMockWasmPluginDeletionReconciler creates a new mock instance. +func NewMockWasmPluginDeletionReconciler(ctrl *gomock.Controller) *MockWasmPluginDeletionReconciler { + mock := &MockWasmPluginDeletionReconciler{ctrl: ctrl} + mock.recorder = &MockWasmPluginDeletionReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginDeletionReconciler) EXPECT() *MockWasmPluginDeletionReconcilerMockRecorder { + return m.recorder +} + +// ReconcileWasmPluginDeletion mocks base method. +func (m *MockWasmPluginDeletionReconciler) ReconcileWasmPluginDeletion(req reconcile.Request) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileWasmPluginDeletion", req) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReconcileWasmPluginDeletion indicates an expected call of ReconcileWasmPluginDeletion. +func (mr *MockWasmPluginDeletionReconcilerMockRecorder) ReconcileWasmPluginDeletion(req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileWasmPluginDeletion", reflect.TypeOf((*MockWasmPluginDeletionReconciler)(nil).ReconcileWasmPluginDeletion), req) +} + +// MockWasmPluginFinalizer is a mock of WasmPluginFinalizer interface. +type MockWasmPluginFinalizer struct { + ctrl *gomock.Controller + recorder *MockWasmPluginFinalizerMockRecorder +} + +// MockWasmPluginFinalizerMockRecorder is the mock recorder for MockWasmPluginFinalizer. +type MockWasmPluginFinalizerMockRecorder struct { + mock *MockWasmPluginFinalizer +} + +// NewMockWasmPluginFinalizer creates a new mock instance. +func NewMockWasmPluginFinalizer(ctrl *gomock.Controller) *MockWasmPluginFinalizer { + mock := &MockWasmPluginFinalizer{ctrl: ctrl} + mock.recorder = &MockWasmPluginFinalizerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginFinalizer) EXPECT() *MockWasmPluginFinalizerMockRecorder { + return m.recorder +} + +// FinalizeWasmPlugin mocks base method. +func (m *MockWasmPluginFinalizer) FinalizeWasmPlugin(obj *v1alpha1.WasmPlugin) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FinalizeWasmPlugin", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// FinalizeWasmPlugin indicates an expected call of FinalizeWasmPlugin. +func (mr *MockWasmPluginFinalizerMockRecorder) FinalizeWasmPlugin(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FinalizeWasmPlugin", reflect.TypeOf((*MockWasmPluginFinalizer)(nil).FinalizeWasmPlugin), obj) +} + +// ReconcileWasmPlugin mocks base method. +func (m *MockWasmPluginFinalizer) ReconcileWasmPlugin(obj *v1alpha1.WasmPlugin) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileWasmPlugin", obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileWasmPlugin indicates an expected call of ReconcileWasmPlugin. +func (mr *MockWasmPluginFinalizerMockRecorder) ReconcileWasmPlugin(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileWasmPlugin", reflect.TypeOf((*MockWasmPluginFinalizer)(nil).ReconcileWasmPlugin), obj) +} + +// WasmPluginFinalizerName mocks base method. +func (m *MockWasmPluginFinalizer) WasmPluginFinalizerName() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WasmPluginFinalizerName") + ret0, _ := ret[0].(string) + return ret0 +} + +// WasmPluginFinalizerName indicates an expected call of WasmPluginFinalizerName. +func (mr *MockWasmPluginFinalizerMockRecorder) WasmPluginFinalizerName() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WasmPluginFinalizerName", reflect.TypeOf((*MockWasmPluginFinalizer)(nil).WasmPluginFinalizerName)) +} + +// MockWasmPluginReconcileLoop is a mock of WasmPluginReconcileLoop interface. +type MockWasmPluginReconcileLoop struct { + ctrl *gomock.Controller + recorder *MockWasmPluginReconcileLoopMockRecorder +} + +// MockWasmPluginReconcileLoopMockRecorder is the mock recorder for MockWasmPluginReconcileLoop. +type MockWasmPluginReconcileLoopMockRecorder struct { + mock *MockWasmPluginReconcileLoop +} + +// NewMockWasmPluginReconcileLoop creates a new mock instance. +func NewMockWasmPluginReconcileLoop(ctrl *gomock.Controller) *MockWasmPluginReconcileLoop { + mock := &MockWasmPluginReconcileLoop{ctrl: ctrl} + mock.recorder = &MockWasmPluginReconcileLoopMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginReconcileLoop) EXPECT() *MockWasmPluginReconcileLoopMockRecorder { + return m.recorder +} + +// RunWasmPluginReconciler mocks base method. +func (m *MockWasmPluginReconcileLoop) RunWasmPluginReconciler(ctx context.Context, rec controller.WasmPluginReconciler, predicates ...predicate.Predicate) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, rec} + for _, a := range predicates { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "RunWasmPluginReconciler", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// RunWasmPluginReconciler indicates an expected call of RunWasmPluginReconciler. +func (mr *MockWasmPluginReconcileLoopMockRecorder) RunWasmPluginReconciler(ctx, rec interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, rec}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunWasmPluginReconciler", reflect.TypeOf((*MockWasmPluginReconcileLoop)(nil).RunWasmPluginReconciler), varargs...) +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/controller/multicluster_reconcilers.go b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/multicluster_reconcilers.go new file mode 100644 index 0000000..db503b6 --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/multicluster_reconcilers.go @@ -0,0 +1,90 @@ +// Code generated by skv2. DO NOT EDIT. + +//go:generate mockgen -source ./multicluster_reconcilers.go -destination mocks/multicluster_reconcilers.go + +// Definitions for the multicluster Kubernetes Controllers +package controller + +import ( + "context" + + extensions_istio_io_v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + + "github.com/pkg/errors" + "github.com/solo-io/skv2/pkg/ezkube" + "github.com/solo-io/skv2/pkg/multicluster" + mc_reconcile "github.com/solo-io/skv2/pkg/multicluster/reconcile" + "github.com/solo-io/skv2/pkg/reconcile" + "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +// Reconcile Upsert events for the WasmPlugin Resource across clusters. +// implemented by the user +type MulticlusterWasmPluginReconciler interface { + ReconcileWasmPlugin(clusterName string, obj *extensions_istio_io_v1alpha1.WasmPlugin) (reconcile.Result, error) +} + +// Reconcile deletion events for the WasmPlugin Resource across clusters. +// Deletion receives a reconcile.Request as we cannot guarantee the last state of the object +// before being deleted. +// implemented by the user +type MulticlusterWasmPluginDeletionReconciler interface { + ReconcileWasmPluginDeletion(clusterName string, req reconcile.Request) error +} + +type MulticlusterWasmPluginReconcilerFuncs struct { + OnReconcileWasmPlugin func(clusterName string, obj *extensions_istio_io_v1alpha1.WasmPlugin) (reconcile.Result, error) + OnReconcileWasmPluginDeletion func(clusterName string, req reconcile.Request) error +} + +func (f *MulticlusterWasmPluginReconcilerFuncs) ReconcileWasmPlugin(clusterName string, obj *extensions_istio_io_v1alpha1.WasmPlugin) (reconcile.Result, error) { + if f.OnReconcileWasmPlugin == nil { + return reconcile.Result{}, nil + } + return f.OnReconcileWasmPlugin(clusterName, obj) +} + +func (f *MulticlusterWasmPluginReconcilerFuncs) ReconcileWasmPluginDeletion(clusterName string, req reconcile.Request) error { + if f.OnReconcileWasmPluginDeletion == nil { + return nil + } + return f.OnReconcileWasmPluginDeletion(clusterName, req) +} + +type MulticlusterWasmPluginReconcileLoop interface { + // AddMulticlusterWasmPluginReconciler adds a MulticlusterWasmPluginReconciler to the MulticlusterWasmPluginReconcileLoop. + AddMulticlusterWasmPluginReconciler(ctx context.Context, rec MulticlusterWasmPluginReconciler, predicates ...predicate.Predicate) +} + +type multiclusterWasmPluginReconcileLoop struct { + loop multicluster.Loop +} + +func (m *multiclusterWasmPluginReconcileLoop) AddMulticlusterWasmPluginReconciler(ctx context.Context, rec MulticlusterWasmPluginReconciler, predicates ...predicate.Predicate) { + genericReconciler := genericWasmPluginMulticlusterReconciler{reconciler: rec} + + m.loop.AddReconciler(ctx, genericReconciler, predicates...) +} + +func NewMulticlusterWasmPluginReconcileLoop(name string, cw multicluster.ClusterWatcher, options reconcile.Options) MulticlusterWasmPluginReconcileLoop { + return &multiclusterWasmPluginReconcileLoop{loop: mc_reconcile.NewLoop(name, cw, &extensions_istio_io_v1alpha1.WasmPlugin{}, options)} +} + +type genericWasmPluginMulticlusterReconciler struct { + reconciler MulticlusterWasmPluginReconciler +} + +func (g genericWasmPluginMulticlusterReconciler) ReconcileDeletion(cluster string, req reconcile.Request) error { + if deletionReconciler, ok := g.reconciler.(MulticlusterWasmPluginDeletionReconciler); ok { + return deletionReconciler.ReconcileWasmPluginDeletion(cluster, req) + } + return nil +} + +func (g genericWasmPluginMulticlusterReconciler) Reconcile(cluster string, object ezkube.Object) (reconcile.Result, error) { + obj, ok := object.(*extensions_istio_io_v1alpha1.WasmPlugin) + if !ok { + return reconcile.Result{}, errors.Errorf("internal error: WasmPlugin handler received event for %T", object) + } + return g.reconciler.ReconcileWasmPlugin(cluster, obj) +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/controller/reconcilers.go b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/reconcilers.go new file mode 100644 index 0000000..2b60223 --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/controller/reconcilers.go @@ -0,0 +1,135 @@ +// Code generated by skv2. DO NOT EDIT. + +//go:generate mockgen -source ./reconcilers.go -destination mocks/reconcilers.go + +// Definitions for the Kubernetes Controllers +package controller + +import ( + "context" + + extensions_istio_io_v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + + "github.com/pkg/errors" + "github.com/solo-io/skv2/pkg/ezkube" + "github.com/solo-io/skv2/pkg/reconcile" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +// Reconcile Upsert events for the WasmPlugin Resource. +// implemented by the user +type WasmPluginReconciler interface { + ReconcileWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) (reconcile.Result, error) +} + +// Reconcile deletion events for the WasmPlugin Resource. +// Deletion receives a reconcile.Request as we cannot guarantee the last state of the object +// before being deleted. +// implemented by the user +type WasmPluginDeletionReconciler interface { + ReconcileWasmPluginDeletion(req reconcile.Request) error +} + +type WasmPluginReconcilerFuncs struct { + OnReconcileWasmPlugin func(obj *extensions_istio_io_v1alpha1.WasmPlugin) (reconcile.Result, error) + OnReconcileWasmPluginDeletion func(req reconcile.Request) error +} + +func (f *WasmPluginReconcilerFuncs) ReconcileWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) (reconcile.Result, error) { + if f.OnReconcileWasmPlugin == nil { + return reconcile.Result{}, nil + } + return f.OnReconcileWasmPlugin(obj) +} + +func (f *WasmPluginReconcilerFuncs) ReconcileWasmPluginDeletion(req reconcile.Request) error { + if f.OnReconcileWasmPluginDeletion == nil { + return nil + } + return f.OnReconcileWasmPluginDeletion(req) +} + +// Reconcile and finalize the WasmPlugin Resource +// implemented by the user +type WasmPluginFinalizer interface { + WasmPluginReconciler + + // name of the finalizer used by this handler. + // finalizer names should be unique for a single task + WasmPluginFinalizerName() string + + // finalize the object before it is deleted. + // Watchers created with a finalizing handler will a + FinalizeWasmPlugin(obj *extensions_istio_io_v1alpha1.WasmPlugin) error +} + +type WasmPluginReconcileLoop interface { + RunWasmPluginReconciler(ctx context.Context, rec WasmPluginReconciler, predicates ...predicate.Predicate) error +} + +type wasmPluginReconcileLoop struct { + loop reconcile.Loop +} + +func NewWasmPluginReconcileLoop(name string, mgr manager.Manager, options reconcile.Options) WasmPluginReconcileLoop { + return &wasmPluginReconcileLoop{ + // empty cluster indicates this reconciler is built for the local cluster + loop: reconcile.NewLoop(name, "", mgr, &extensions_istio_io_v1alpha1.WasmPlugin{}, options), + } +} + +func (c *wasmPluginReconcileLoop) RunWasmPluginReconciler(ctx context.Context, reconciler WasmPluginReconciler, predicates ...predicate.Predicate) error { + genericReconciler := genericWasmPluginReconciler{ + reconciler: reconciler, + } + + var reconcilerWrapper reconcile.Reconciler + if finalizingReconciler, ok := reconciler.(WasmPluginFinalizer); ok { + reconcilerWrapper = genericWasmPluginFinalizer{ + genericWasmPluginReconciler: genericReconciler, + finalizingReconciler: finalizingReconciler, + } + } else { + reconcilerWrapper = genericReconciler + } + return c.loop.RunReconciler(ctx, reconcilerWrapper, predicates...) +} + +// genericWasmPluginHandler implements a generic reconcile.Reconciler +type genericWasmPluginReconciler struct { + reconciler WasmPluginReconciler +} + +func (r genericWasmPluginReconciler) Reconcile(object ezkube.Object) (reconcile.Result, error) { + obj, ok := object.(*extensions_istio_io_v1alpha1.WasmPlugin) + if !ok { + return reconcile.Result{}, errors.Errorf("internal error: WasmPlugin handler received event for %T", object) + } + return r.reconciler.ReconcileWasmPlugin(obj) +} + +func (r genericWasmPluginReconciler) ReconcileDeletion(request reconcile.Request) error { + if deletionReconciler, ok := r.reconciler.(WasmPluginDeletionReconciler); ok { + return deletionReconciler.ReconcileWasmPluginDeletion(request) + } + return nil +} + +// genericWasmPluginFinalizer implements a generic reconcile.FinalizingReconciler +type genericWasmPluginFinalizer struct { + genericWasmPluginReconciler + finalizingReconciler WasmPluginFinalizer +} + +func (r genericWasmPluginFinalizer) FinalizerName() string { + return r.finalizingReconciler.WasmPluginFinalizerName() +} + +func (r genericWasmPluginFinalizer) Finalize(object ezkube.Object) error { + obj, ok := object.(*extensions_istio_io_v1alpha1.WasmPlugin) + if !ok { + return errors.Errorf("internal error: WasmPlugin handler received event for %T", object) + } + return r.finalizingReconciler.FinalizeWasmPlugin(obj) +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/mocks/clients.go b/pkg/api/istio/extensions.istio.io/v1alpha1/mocks/clients.go new file mode 100644 index 0000000..f881d2b --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/mocks/clients.go @@ -0,0 +1,594 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./clients.go + +// Package mock_v1alpha1 is a generated GoMock package. +package mock_v1alpha1 + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + v1alpha1 "github.com/solo-io/external-apis/pkg/api/istio/extensions.istio.io/v1alpha1" + v1alpha10 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + client "sigs.k8s.io/controller-runtime/pkg/client" +) + +// MockMulticlusterClientset is a mock of MulticlusterClientset interface. +type MockMulticlusterClientset struct { + ctrl *gomock.Controller + recorder *MockMulticlusterClientsetMockRecorder +} + +// MockMulticlusterClientsetMockRecorder is the mock recorder for MockMulticlusterClientset. +type MockMulticlusterClientsetMockRecorder struct { + mock *MockMulticlusterClientset +} + +// NewMockMulticlusterClientset creates a new mock instance. +func NewMockMulticlusterClientset(ctrl *gomock.Controller) *MockMulticlusterClientset { + mock := &MockMulticlusterClientset{ctrl: ctrl} + mock.recorder = &MockMulticlusterClientsetMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterClientset) EXPECT() *MockMulticlusterClientsetMockRecorder { + return m.recorder +} + +// Cluster mocks base method. +func (m *MockMulticlusterClientset) Cluster(cluster string) (v1alpha1.Clientset, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Cluster", cluster) + ret0, _ := ret[0].(v1alpha1.Clientset) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Cluster indicates an expected call of Cluster. +func (mr *MockMulticlusterClientsetMockRecorder) Cluster(cluster interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cluster", reflect.TypeOf((*MockMulticlusterClientset)(nil).Cluster), cluster) +} + +// MockClientset is a mock of Clientset interface. +type MockClientset struct { + ctrl *gomock.Controller + recorder *MockClientsetMockRecorder +} + +// MockClientsetMockRecorder is the mock recorder for MockClientset. +type MockClientsetMockRecorder struct { + mock *MockClientset +} + +// NewMockClientset creates a new mock instance. +func NewMockClientset(ctrl *gomock.Controller) *MockClientset { + mock := &MockClientset{ctrl: ctrl} + mock.recorder = &MockClientsetMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockClientset) EXPECT() *MockClientsetMockRecorder { + return m.recorder +} + +// WasmPlugins mocks base method. +func (m *MockClientset) WasmPlugins() v1alpha1.WasmPluginClient { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WasmPlugins") + ret0, _ := ret[0].(v1alpha1.WasmPluginClient) + return ret0 +} + +// WasmPlugins indicates an expected call of WasmPlugins. +func (mr *MockClientsetMockRecorder) WasmPlugins() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WasmPlugins", reflect.TypeOf((*MockClientset)(nil).WasmPlugins)) +} + +// MockWasmPluginReader is a mock of WasmPluginReader interface. +type MockWasmPluginReader struct { + ctrl *gomock.Controller + recorder *MockWasmPluginReaderMockRecorder +} + +// MockWasmPluginReaderMockRecorder is the mock recorder for MockWasmPluginReader. +type MockWasmPluginReaderMockRecorder struct { + mock *MockWasmPluginReader +} + +// NewMockWasmPluginReader creates a new mock instance. +func NewMockWasmPluginReader(ctrl *gomock.Controller) *MockWasmPluginReader { + mock := &MockWasmPluginReader{ctrl: ctrl} + mock.recorder = &MockWasmPluginReaderMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginReader) EXPECT() *MockWasmPluginReaderMockRecorder { + return m.recorder +} + +// GetWasmPlugin mocks base method. +func (m *MockWasmPluginReader) GetWasmPlugin(ctx context.Context, key client.ObjectKey) (*v1alpha10.WasmPlugin, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetWasmPlugin", ctx, key) + ret0, _ := ret[0].(*v1alpha10.WasmPlugin) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWasmPlugin indicates an expected call of GetWasmPlugin. +func (mr *MockWasmPluginReaderMockRecorder) GetWasmPlugin(ctx, key interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWasmPlugin", reflect.TypeOf((*MockWasmPluginReader)(nil).GetWasmPlugin), ctx, key) +} + +// ListWasmPlugin mocks base method. +func (m *MockWasmPluginReader) ListWasmPlugin(ctx context.Context, opts ...client.ListOption) (*v1alpha10.WasmPluginList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListWasmPlugin", varargs...) + ret0, _ := ret[0].(*v1alpha10.WasmPluginList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListWasmPlugin indicates an expected call of ListWasmPlugin. +func (mr *MockWasmPluginReaderMockRecorder) ListWasmPlugin(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWasmPlugin", reflect.TypeOf((*MockWasmPluginReader)(nil).ListWasmPlugin), varargs...) +} + +// MockWasmPluginWriter is a mock of WasmPluginWriter interface. +type MockWasmPluginWriter struct { + ctrl *gomock.Controller + recorder *MockWasmPluginWriterMockRecorder +} + +// MockWasmPluginWriterMockRecorder is the mock recorder for MockWasmPluginWriter. +type MockWasmPluginWriterMockRecorder struct { + mock *MockWasmPluginWriter +} + +// NewMockWasmPluginWriter creates a new mock instance. +func NewMockWasmPluginWriter(ctrl *gomock.Controller) *MockWasmPluginWriter { + mock := &MockWasmPluginWriter{ctrl: ctrl} + mock.recorder = &MockWasmPluginWriterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginWriter) EXPECT() *MockWasmPluginWriterMockRecorder { + return m.recorder +} + +// CreateWasmPlugin mocks base method. +func (m *MockWasmPluginWriter) CreateWasmPlugin(ctx context.Context, obj *v1alpha10.WasmPlugin, opts ...client.CreateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateWasmPlugin indicates an expected call of CreateWasmPlugin. +func (mr *MockWasmPluginWriterMockRecorder) CreateWasmPlugin(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWasmPlugin", reflect.TypeOf((*MockWasmPluginWriter)(nil).CreateWasmPlugin), varargs...) +} + +// DeleteAllOfWasmPlugin mocks base method. +func (m *MockWasmPluginWriter) DeleteAllOfWasmPlugin(ctx context.Context, opts ...client.DeleteAllOfOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteAllOfWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteAllOfWasmPlugin indicates an expected call of DeleteAllOfWasmPlugin. +func (mr *MockWasmPluginWriterMockRecorder) DeleteAllOfWasmPlugin(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllOfWasmPlugin", reflect.TypeOf((*MockWasmPluginWriter)(nil).DeleteAllOfWasmPlugin), varargs...) +} + +// DeleteWasmPlugin mocks base method. +func (m *MockWasmPluginWriter) DeleteWasmPlugin(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, key} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteWasmPlugin indicates an expected call of DeleteWasmPlugin. +func (mr *MockWasmPluginWriterMockRecorder) DeleteWasmPlugin(ctx, key interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, key}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteWasmPlugin", reflect.TypeOf((*MockWasmPluginWriter)(nil).DeleteWasmPlugin), varargs...) +} + +// PatchWasmPlugin mocks base method. +func (m *MockWasmPluginWriter) PatchWasmPlugin(ctx context.Context, obj *v1alpha10.WasmPlugin, patch client.Patch, opts ...client.PatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchWasmPlugin indicates an expected call of PatchWasmPlugin. +func (mr *MockWasmPluginWriterMockRecorder) PatchWasmPlugin(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchWasmPlugin", reflect.TypeOf((*MockWasmPluginWriter)(nil).PatchWasmPlugin), varargs...) +} + +// UpdateWasmPlugin mocks base method. +func (m *MockWasmPluginWriter) UpdateWasmPlugin(ctx context.Context, obj *v1alpha10.WasmPlugin, opts ...client.UpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWasmPlugin indicates an expected call of UpdateWasmPlugin. +func (mr *MockWasmPluginWriterMockRecorder) UpdateWasmPlugin(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWasmPlugin", reflect.TypeOf((*MockWasmPluginWriter)(nil).UpdateWasmPlugin), varargs...) +} + +// UpsertWasmPlugin mocks base method. +func (m *MockWasmPluginWriter) UpsertWasmPlugin(ctx context.Context, obj *v1alpha10.WasmPlugin, transitionFuncs ...v1alpha1.WasmPluginTransitionFunction) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range transitionFuncs { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpsertWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpsertWasmPlugin indicates an expected call of UpsertWasmPlugin. +func (mr *MockWasmPluginWriterMockRecorder) UpsertWasmPlugin(ctx, obj interface{}, transitionFuncs ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, transitionFuncs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertWasmPlugin", reflect.TypeOf((*MockWasmPluginWriter)(nil).UpsertWasmPlugin), varargs...) +} + +// MockWasmPluginStatusWriter is a mock of WasmPluginStatusWriter interface. +type MockWasmPluginStatusWriter struct { + ctrl *gomock.Controller + recorder *MockWasmPluginStatusWriterMockRecorder +} + +// MockWasmPluginStatusWriterMockRecorder is the mock recorder for MockWasmPluginStatusWriter. +type MockWasmPluginStatusWriterMockRecorder struct { + mock *MockWasmPluginStatusWriter +} + +// NewMockWasmPluginStatusWriter creates a new mock instance. +func NewMockWasmPluginStatusWriter(ctrl *gomock.Controller) *MockWasmPluginStatusWriter { + mock := &MockWasmPluginStatusWriter{ctrl: ctrl} + mock.recorder = &MockWasmPluginStatusWriterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginStatusWriter) EXPECT() *MockWasmPluginStatusWriterMockRecorder { + return m.recorder +} + +// PatchWasmPluginStatus mocks base method. +func (m *MockWasmPluginStatusWriter) PatchWasmPluginStatus(ctx context.Context, obj *v1alpha10.WasmPlugin, patch client.Patch, opts ...client.SubResourcePatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchWasmPluginStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchWasmPluginStatus indicates an expected call of PatchWasmPluginStatus. +func (mr *MockWasmPluginStatusWriterMockRecorder) PatchWasmPluginStatus(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchWasmPluginStatus", reflect.TypeOf((*MockWasmPluginStatusWriter)(nil).PatchWasmPluginStatus), varargs...) +} + +// UpdateWasmPluginStatus mocks base method. +func (m *MockWasmPluginStatusWriter) UpdateWasmPluginStatus(ctx context.Context, obj *v1alpha10.WasmPlugin, opts ...client.SubResourceUpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateWasmPluginStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWasmPluginStatus indicates an expected call of UpdateWasmPluginStatus. +func (mr *MockWasmPluginStatusWriterMockRecorder) UpdateWasmPluginStatus(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWasmPluginStatus", reflect.TypeOf((*MockWasmPluginStatusWriter)(nil).UpdateWasmPluginStatus), varargs...) +} + +// MockWasmPluginClient is a mock of WasmPluginClient interface. +type MockWasmPluginClient struct { + ctrl *gomock.Controller + recorder *MockWasmPluginClientMockRecorder +} + +// MockWasmPluginClientMockRecorder is the mock recorder for MockWasmPluginClient. +type MockWasmPluginClientMockRecorder struct { + mock *MockWasmPluginClient +} + +// NewMockWasmPluginClient creates a new mock instance. +func NewMockWasmPluginClient(ctrl *gomock.Controller) *MockWasmPluginClient { + mock := &MockWasmPluginClient{ctrl: ctrl} + mock.recorder = &MockWasmPluginClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginClient) EXPECT() *MockWasmPluginClientMockRecorder { + return m.recorder +} + +// CreateWasmPlugin mocks base method. +func (m *MockWasmPluginClient) CreateWasmPlugin(ctx context.Context, obj *v1alpha10.WasmPlugin, opts ...client.CreateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateWasmPlugin indicates an expected call of CreateWasmPlugin. +func (mr *MockWasmPluginClientMockRecorder) CreateWasmPlugin(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWasmPlugin", reflect.TypeOf((*MockWasmPluginClient)(nil).CreateWasmPlugin), varargs...) +} + +// DeleteAllOfWasmPlugin mocks base method. +func (m *MockWasmPluginClient) DeleteAllOfWasmPlugin(ctx context.Context, opts ...client.DeleteAllOfOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteAllOfWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteAllOfWasmPlugin indicates an expected call of DeleteAllOfWasmPlugin. +func (mr *MockWasmPluginClientMockRecorder) DeleteAllOfWasmPlugin(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllOfWasmPlugin", reflect.TypeOf((*MockWasmPluginClient)(nil).DeleteAllOfWasmPlugin), varargs...) +} + +// DeleteWasmPlugin mocks base method. +func (m *MockWasmPluginClient) DeleteWasmPlugin(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, key} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteWasmPlugin indicates an expected call of DeleteWasmPlugin. +func (mr *MockWasmPluginClientMockRecorder) DeleteWasmPlugin(ctx, key interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, key}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteWasmPlugin", reflect.TypeOf((*MockWasmPluginClient)(nil).DeleteWasmPlugin), varargs...) +} + +// GetWasmPlugin mocks base method. +func (m *MockWasmPluginClient) GetWasmPlugin(ctx context.Context, key client.ObjectKey) (*v1alpha10.WasmPlugin, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetWasmPlugin", ctx, key) + ret0, _ := ret[0].(*v1alpha10.WasmPlugin) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWasmPlugin indicates an expected call of GetWasmPlugin. +func (mr *MockWasmPluginClientMockRecorder) GetWasmPlugin(ctx, key interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWasmPlugin", reflect.TypeOf((*MockWasmPluginClient)(nil).GetWasmPlugin), ctx, key) +} + +// ListWasmPlugin mocks base method. +func (m *MockWasmPluginClient) ListWasmPlugin(ctx context.Context, opts ...client.ListOption) (*v1alpha10.WasmPluginList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListWasmPlugin", varargs...) + ret0, _ := ret[0].(*v1alpha10.WasmPluginList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListWasmPlugin indicates an expected call of ListWasmPlugin. +func (mr *MockWasmPluginClientMockRecorder) ListWasmPlugin(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWasmPlugin", reflect.TypeOf((*MockWasmPluginClient)(nil).ListWasmPlugin), varargs...) +} + +// PatchWasmPlugin mocks base method. +func (m *MockWasmPluginClient) PatchWasmPlugin(ctx context.Context, obj *v1alpha10.WasmPlugin, patch client.Patch, opts ...client.PatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchWasmPlugin indicates an expected call of PatchWasmPlugin. +func (mr *MockWasmPluginClientMockRecorder) PatchWasmPlugin(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchWasmPlugin", reflect.TypeOf((*MockWasmPluginClient)(nil).PatchWasmPlugin), varargs...) +} + +// PatchWasmPluginStatus mocks base method. +func (m *MockWasmPluginClient) PatchWasmPluginStatus(ctx context.Context, obj *v1alpha10.WasmPlugin, patch client.Patch, opts ...client.SubResourcePatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchWasmPluginStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchWasmPluginStatus indicates an expected call of PatchWasmPluginStatus. +func (mr *MockWasmPluginClientMockRecorder) PatchWasmPluginStatus(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchWasmPluginStatus", reflect.TypeOf((*MockWasmPluginClient)(nil).PatchWasmPluginStatus), varargs...) +} + +// UpdateWasmPlugin mocks base method. +func (m *MockWasmPluginClient) UpdateWasmPlugin(ctx context.Context, obj *v1alpha10.WasmPlugin, opts ...client.UpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWasmPlugin indicates an expected call of UpdateWasmPlugin. +func (mr *MockWasmPluginClientMockRecorder) UpdateWasmPlugin(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWasmPlugin", reflect.TypeOf((*MockWasmPluginClient)(nil).UpdateWasmPlugin), varargs...) +} + +// UpdateWasmPluginStatus mocks base method. +func (m *MockWasmPluginClient) UpdateWasmPluginStatus(ctx context.Context, obj *v1alpha10.WasmPlugin, opts ...client.SubResourceUpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateWasmPluginStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWasmPluginStatus indicates an expected call of UpdateWasmPluginStatus. +func (mr *MockWasmPluginClientMockRecorder) UpdateWasmPluginStatus(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWasmPluginStatus", reflect.TypeOf((*MockWasmPluginClient)(nil).UpdateWasmPluginStatus), varargs...) +} + +// UpsertWasmPlugin mocks base method. +func (m *MockWasmPluginClient) UpsertWasmPlugin(ctx context.Context, obj *v1alpha10.WasmPlugin, transitionFuncs ...v1alpha1.WasmPluginTransitionFunction) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range transitionFuncs { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpsertWasmPlugin", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpsertWasmPlugin indicates an expected call of UpsertWasmPlugin. +func (mr *MockWasmPluginClientMockRecorder) UpsertWasmPlugin(ctx, obj interface{}, transitionFuncs ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, transitionFuncs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertWasmPlugin", reflect.TypeOf((*MockWasmPluginClient)(nil).UpsertWasmPlugin), varargs...) +} + +// MockMulticlusterWasmPluginClient is a mock of MulticlusterWasmPluginClient interface. +type MockMulticlusterWasmPluginClient struct { + ctrl *gomock.Controller + recorder *MockMulticlusterWasmPluginClientMockRecorder +} + +// MockMulticlusterWasmPluginClientMockRecorder is the mock recorder for MockMulticlusterWasmPluginClient. +type MockMulticlusterWasmPluginClientMockRecorder struct { + mock *MockMulticlusterWasmPluginClient +} + +// NewMockMulticlusterWasmPluginClient creates a new mock instance. +func NewMockMulticlusterWasmPluginClient(ctrl *gomock.Controller) *MockMulticlusterWasmPluginClient { + mock := &MockMulticlusterWasmPluginClient{ctrl: ctrl} + mock.recorder = &MockMulticlusterWasmPluginClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterWasmPluginClient) EXPECT() *MockMulticlusterWasmPluginClientMockRecorder { + return m.recorder +} + +// Cluster mocks base method. +func (m *MockMulticlusterWasmPluginClient) Cluster(cluster string) (v1alpha1.WasmPluginClient, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Cluster", cluster) + ret0, _ := ret[0].(v1alpha1.WasmPluginClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Cluster indicates an expected call of Cluster. +func (mr *MockMulticlusterWasmPluginClientMockRecorder) Cluster(cluster interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cluster", reflect.TypeOf((*MockMulticlusterWasmPluginClient)(nil).Cluster), cluster) +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/providers/client_providers.go b/pkg/api/istio/extensions.istio.io/v1alpha1/providers/client_providers.go new file mode 100644 index 0000000..188a6ec --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/providers/client_providers.go @@ -0,0 +1,46 @@ +// Code generated by skv2. DO NOT EDIT. + +package v1alpha1 + +import ( + extensions_istio_io_v1alpha1 "github.com/solo-io/external-apis/pkg/api/istio/extensions.istio.io/v1alpha1" + + "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +/* + The intention of these providers are to be used for Mocking. + They expose the Clients as interfaces, as well as factories to provide mocked versions + of the clients when they require building within a component. + + See package `github.com/solo-io/skv2/pkg/multicluster/register` for example +*/ + +// Provider for WasmPluginClient from Clientset +func WasmPluginClientFromClientsetProvider(clients extensions_istio_io_v1alpha1.Clientset) extensions_istio_io_v1alpha1.WasmPluginClient { + return clients.WasmPlugins() +} + +// Provider for WasmPlugin Client from Client +func WasmPluginClientProvider(client client.Client) extensions_istio_io_v1alpha1.WasmPluginClient { + return extensions_istio_io_v1alpha1.NewWasmPluginClient(client) +} + +type WasmPluginClientFactory func(client client.Client) extensions_istio_io_v1alpha1.WasmPluginClient + +func WasmPluginClientFactoryProvider() WasmPluginClientFactory { + return WasmPluginClientProvider +} + +type WasmPluginClientFromConfigFactory func(cfg *rest.Config) (extensions_istio_io_v1alpha1.WasmPluginClient, error) + +func WasmPluginClientFromConfigFactoryProvider() WasmPluginClientFromConfigFactory { + return func(cfg *rest.Config) (extensions_istio_io_v1alpha1.WasmPluginClient, error) { + clients, err := extensions_istio_io_v1alpha1.NewClientsetFromConfig(cfg) + if err != nil { + return nil, err + } + return clients.WasmPlugins(), nil + } +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/sets/mocks/sets.go b/pkg/api/istio/extensions.istio.io/v1alpha1/sets/mocks/sets.go new file mode 100644 index 0000000..48b8887 --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/sets/mocks/sets.go @@ -0,0 +1,272 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./sets.go + +// Package mock_v1alpha1sets is a generated GoMock package. +package mock_v1alpha1sets + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + v1alpha1sets "github.com/solo-io/external-apis/pkg/api/istio/extensions.istio.io/v1alpha1/sets" + sets "github.com/solo-io/skv2/contrib/pkg/sets" + ezkube "github.com/solo-io/skv2/pkg/ezkube" + v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + sets0 "k8s.io/apimachinery/pkg/util/sets" +) + +// MockWasmPluginSet is a mock of WasmPluginSet interface. +type MockWasmPluginSet struct { + ctrl *gomock.Controller + recorder *MockWasmPluginSetMockRecorder +} + +// MockWasmPluginSetMockRecorder is the mock recorder for MockWasmPluginSet. +type MockWasmPluginSetMockRecorder struct { + mock *MockWasmPluginSet +} + +// NewMockWasmPluginSet creates a new mock instance. +func NewMockWasmPluginSet(ctrl *gomock.Controller) *MockWasmPluginSet { + mock := &MockWasmPluginSet{ctrl: ctrl} + mock.recorder = &MockWasmPluginSetMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWasmPluginSet) EXPECT() *MockWasmPluginSetMockRecorder { + return m.recorder +} + +// Clone mocks base method. +func (m *MockWasmPluginSet) Clone() v1alpha1sets.WasmPluginSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Clone") + ret0, _ := ret[0].(v1alpha1sets.WasmPluginSet) + return ret0 +} + +// Clone indicates an expected call of Clone. +func (mr *MockWasmPluginSetMockRecorder) Clone() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clone", reflect.TypeOf((*MockWasmPluginSet)(nil).Clone)) +} + +// Delete mocks base method. +func (m *MockWasmPluginSet) Delete(wasmPlugin ezkube.ResourceId) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Delete", wasmPlugin) +} + +// Delete indicates an expected call of Delete. +func (mr *MockWasmPluginSetMockRecorder) Delete(wasmPlugin interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockWasmPluginSet)(nil).Delete), wasmPlugin) +} + +// Delta mocks base method. +func (m *MockWasmPluginSet) Delta(newSet v1alpha1sets.WasmPluginSet) sets.ResourceDelta { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delta", newSet) + ret0, _ := ret[0].(sets.ResourceDelta) + return ret0 +} + +// Delta indicates an expected call of Delta. +func (mr *MockWasmPluginSetMockRecorder) Delta(newSet interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delta", reflect.TypeOf((*MockWasmPluginSet)(nil).Delta), newSet) +} + +// Difference mocks base method. +func (m *MockWasmPluginSet) Difference(set v1alpha1sets.WasmPluginSet) v1alpha1sets.WasmPluginSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Difference", set) + ret0, _ := ret[0].(v1alpha1sets.WasmPluginSet) + return ret0 +} + +// Difference indicates an expected call of Difference. +func (mr *MockWasmPluginSetMockRecorder) Difference(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Difference", reflect.TypeOf((*MockWasmPluginSet)(nil).Difference), set) +} + +// Equal mocks base method. +func (m *MockWasmPluginSet) Equal(wasmPluginSet v1alpha1sets.WasmPluginSet) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Equal", wasmPluginSet) + ret0, _ := ret[0].(bool) + return ret0 +} + +// Equal indicates an expected call of Equal. +func (mr *MockWasmPluginSetMockRecorder) Equal(wasmPluginSet interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Equal", reflect.TypeOf((*MockWasmPluginSet)(nil).Equal), wasmPluginSet) +} + +// Find mocks base method. +func (m *MockWasmPluginSet) Find(id ezkube.ResourceId) (*v1alpha1.WasmPlugin, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Find", id) + ret0, _ := ret[0].(*v1alpha1.WasmPlugin) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Find indicates an expected call of Find. +func (mr *MockWasmPluginSetMockRecorder) Find(id interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockWasmPluginSet)(nil).Find), id) +} + +// Generic mocks base method. +func (m *MockWasmPluginSet) Generic() sets.ResourceSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Generic") + ret0, _ := ret[0].(sets.ResourceSet) + return ret0 +} + +// Generic indicates an expected call of Generic. +func (mr *MockWasmPluginSetMockRecorder) Generic() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Generic", reflect.TypeOf((*MockWasmPluginSet)(nil).Generic)) +} + +// Has mocks base method. +func (m *MockWasmPluginSet) Has(wasmPlugin ezkube.ResourceId) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Has", wasmPlugin) + ret0, _ := ret[0].(bool) + return ret0 +} + +// Has indicates an expected call of Has. +func (mr *MockWasmPluginSetMockRecorder) Has(wasmPlugin interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Has", reflect.TypeOf((*MockWasmPluginSet)(nil).Has), wasmPlugin) +} + +// Insert mocks base method. +func (m *MockWasmPluginSet) Insert(wasmPlugin ...*v1alpha1.WasmPlugin) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range wasmPlugin { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Insert", varargs...) +} + +// Insert indicates an expected call of Insert. +func (mr *MockWasmPluginSetMockRecorder) Insert(wasmPlugin ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockWasmPluginSet)(nil).Insert), wasmPlugin...) +} + +// Intersection mocks base method. +func (m *MockWasmPluginSet) Intersection(set v1alpha1sets.WasmPluginSet) v1alpha1sets.WasmPluginSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Intersection", set) + ret0, _ := ret[0].(v1alpha1sets.WasmPluginSet) + return ret0 +} + +// Intersection indicates an expected call of Intersection. +func (mr *MockWasmPluginSetMockRecorder) Intersection(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Intersection", reflect.TypeOf((*MockWasmPluginSet)(nil).Intersection), set) +} + +// Keys mocks base method. +func (m *MockWasmPluginSet) Keys() sets0.String { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Keys") + ret0, _ := ret[0].(sets0.String) + return ret0 +} + +// Keys indicates an expected call of Keys. +func (mr *MockWasmPluginSetMockRecorder) Keys() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Keys", reflect.TypeOf((*MockWasmPluginSet)(nil).Keys)) +} + +// Length mocks base method. +func (m *MockWasmPluginSet) Length() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Length") + ret0, _ := ret[0].(int) + return ret0 +} + +// Length indicates an expected call of Length. +func (mr *MockWasmPluginSetMockRecorder) Length() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Length", reflect.TypeOf((*MockWasmPluginSet)(nil).Length)) +} + +// List mocks base method. +func (m *MockWasmPluginSet) List(filterResource ...func(*v1alpha1.WasmPlugin) bool) []*v1alpha1.WasmPlugin { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range filterResource { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].([]*v1alpha1.WasmPlugin) + return ret0 +} + +// List indicates an expected call of List. +func (mr *MockWasmPluginSetMockRecorder) List(filterResource ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockWasmPluginSet)(nil).List), filterResource...) +} + +// Map mocks base method. +func (m *MockWasmPluginSet) Map() map[string]*v1alpha1.WasmPlugin { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Map") + ret0, _ := ret[0].(map[string]*v1alpha1.WasmPlugin) + return ret0 +} + +// Map indicates an expected call of Map. +func (mr *MockWasmPluginSetMockRecorder) Map() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Map", reflect.TypeOf((*MockWasmPluginSet)(nil).Map)) +} + +// Union mocks base method. +func (m *MockWasmPluginSet) Union(set v1alpha1sets.WasmPluginSet) v1alpha1sets.WasmPluginSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Union", set) + ret0, _ := ret[0].(v1alpha1sets.WasmPluginSet) + return ret0 +} + +// Union indicates an expected call of Union. +func (mr *MockWasmPluginSetMockRecorder) Union(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Union", reflect.TypeOf((*MockWasmPluginSet)(nil).Union), set) +} + +// UnsortedList mocks base method. +func (m *MockWasmPluginSet) UnsortedList(filterResource ...func(*v1alpha1.WasmPlugin) bool) []*v1alpha1.WasmPlugin { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range filterResource { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UnsortedList", varargs...) + ret0, _ := ret[0].([]*v1alpha1.WasmPlugin) + return ret0 +} + +// UnsortedList indicates an expected call of UnsortedList. +func (mr *MockWasmPluginSetMockRecorder) UnsortedList(filterResource ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnsortedList", reflect.TypeOf((*MockWasmPluginSet)(nil).UnsortedList), filterResource...) +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/sets/sets.go b/pkg/api/istio/extensions.istio.io/v1alpha1/sets/sets.go new file mode 100644 index 0000000..c56ebe0 --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/sets/sets.go @@ -0,0 +1,237 @@ +// Code generated by skv2. DO NOT EDIT. + +//go:generate mockgen -source ./sets.go -destination mocks/sets.go + +package v1alpha1sets + +import ( + extensions_istio_io_v1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" + + "github.com/rotisserie/eris" + sksets "github.com/solo-io/skv2/contrib/pkg/sets" + "github.com/solo-io/skv2/pkg/ezkube" + "k8s.io/apimachinery/pkg/util/sets" +) + +type WasmPluginSet interface { + // Get the set stored keys + Keys() sets.String + // List of resources stored in the set. Pass an optional filter function to filter on the list. + // The filter function should return false to keep the resource, true to drop it. + List(filterResource ...func(*extensions_istio_io_v1alpha1.WasmPlugin) bool) []*extensions_istio_io_v1alpha1.WasmPlugin + // Unsorted list of resources stored in the set. Pass an optional filter function to filter on the list. + // The filter function should return false to keep the resource, true to drop it. + UnsortedList(filterResource ...func(*extensions_istio_io_v1alpha1.WasmPlugin) bool) []*extensions_istio_io_v1alpha1.WasmPlugin + // Return the Set as a map of key to resource. + Map() map[string]*extensions_istio_io_v1alpha1.WasmPlugin + // Insert a resource into the set. + Insert(wasmPlugin ...*extensions_istio_io_v1alpha1.WasmPlugin) + // Compare the equality of the keys in two sets (not the resources themselves) + Equal(wasmPluginSet WasmPluginSet) bool + // Check if the set contains a key matching the resource (not the resource itself) + Has(wasmPlugin ezkube.ResourceId) bool + // Delete the key matching the resource + Delete(wasmPlugin ezkube.ResourceId) + // Return the union with the provided set + Union(set WasmPluginSet) WasmPluginSet + // Return the difference with the provided set + Difference(set WasmPluginSet) WasmPluginSet + // Return the intersection with the provided set + Intersection(set WasmPluginSet) WasmPluginSet + // Find the resource with the given ID + Find(id ezkube.ResourceId) (*extensions_istio_io_v1alpha1.WasmPlugin, error) + // Get the length of the set + Length() int + // returns the generic implementation of the set + Generic() sksets.ResourceSet + // returns the delta between this and and another WasmPluginSet + Delta(newSet WasmPluginSet) sksets.ResourceDelta + // Create a deep copy of the current WasmPluginSet + Clone() WasmPluginSet +} + +func makeGenericWasmPluginSet(wasmPluginList []*extensions_istio_io_v1alpha1.WasmPlugin) sksets.ResourceSet { + var genericResources []ezkube.ResourceId + for _, obj := range wasmPluginList { + genericResources = append(genericResources, obj) + } + return sksets.NewResourceSet(genericResources...) +} + +type wasmPluginSet struct { + set sksets.ResourceSet +} + +func NewWasmPluginSet(wasmPluginList ...*extensions_istio_io_v1alpha1.WasmPlugin) WasmPluginSet { + return &wasmPluginSet{set: makeGenericWasmPluginSet(wasmPluginList)} +} + +func NewWasmPluginSetFromList(wasmPluginList *extensions_istio_io_v1alpha1.WasmPluginList) WasmPluginSet { + list := make([]*extensions_istio_io_v1alpha1.WasmPlugin, 0, len(wasmPluginList.Items)) + for idx := range wasmPluginList.Items { + list = append(list, wasmPluginList.Items[idx]) + } + return &wasmPluginSet{set: makeGenericWasmPluginSet(list)} +} + +func (s *wasmPluginSet) Keys() sets.String { + if s == nil { + return sets.String{} + } + return s.Generic().Keys() +} + +func (s *wasmPluginSet) List(filterResource ...func(*extensions_istio_io_v1alpha1.WasmPlugin) bool) []*extensions_istio_io_v1alpha1.WasmPlugin { + if s == nil { + return nil + } + var genericFilters []func(ezkube.ResourceId) bool + for _, filter := range filterResource { + filter := filter + genericFilters = append(genericFilters, func(obj ezkube.ResourceId) bool { + return filter(obj.(*extensions_istio_io_v1alpha1.WasmPlugin)) + }) + } + + objs := s.Generic().List(genericFilters...) + wasmPluginList := make([]*extensions_istio_io_v1alpha1.WasmPlugin, 0, len(objs)) + for _, obj := range objs { + wasmPluginList = append(wasmPluginList, obj.(*extensions_istio_io_v1alpha1.WasmPlugin)) + } + return wasmPluginList +} + +func (s *wasmPluginSet) UnsortedList(filterResource ...func(*extensions_istio_io_v1alpha1.WasmPlugin) bool) []*extensions_istio_io_v1alpha1.WasmPlugin { + if s == nil { + return nil + } + var genericFilters []func(ezkube.ResourceId) bool + for _, filter := range filterResource { + filter := filter + genericFilters = append(genericFilters, func(obj ezkube.ResourceId) bool { + return filter(obj.(*extensions_istio_io_v1alpha1.WasmPlugin)) + }) + } + + var wasmPluginList []*extensions_istio_io_v1alpha1.WasmPlugin + for _, obj := range s.Generic().UnsortedList(genericFilters...) { + wasmPluginList = append(wasmPluginList, obj.(*extensions_istio_io_v1alpha1.WasmPlugin)) + } + return wasmPluginList +} + +func (s *wasmPluginSet) Map() map[string]*extensions_istio_io_v1alpha1.WasmPlugin { + if s == nil { + return nil + } + + newMap := map[string]*extensions_istio_io_v1alpha1.WasmPlugin{} + for k, v := range s.Generic().Map() { + newMap[k] = v.(*extensions_istio_io_v1alpha1.WasmPlugin) + } + return newMap +} + +func (s *wasmPluginSet) Insert( + wasmPluginList ...*extensions_istio_io_v1alpha1.WasmPlugin, +) { + if s == nil { + panic("cannot insert into nil set") + } + + for _, obj := range wasmPluginList { + s.Generic().Insert(obj) + } +} + +func (s *wasmPluginSet) Has(wasmPlugin ezkube.ResourceId) bool { + if s == nil { + return false + } + return s.Generic().Has(wasmPlugin) +} + +func (s *wasmPluginSet) Equal( + wasmPluginSet WasmPluginSet, +) bool { + if s == nil { + return wasmPluginSet == nil + } + return s.Generic().Equal(wasmPluginSet.Generic()) +} + +func (s *wasmPluginSet) Delete(WasmPlugin ezkube.ResourceId) { + if s == nil { + return + } + s.Generic().Delete(WasmPlugin) +} + +func (s *wasmPluginSet) Union(set WasmPluginSet) WasmPluginSet { + if s == nil { + return set + } + return NewWasmPluginSet(append(s.List(), set.List()...)...) +} + +func (s *wasmPluginSet) Difference(set WasmPluginSet) WasmPluginSet { + if s == nil { + return set + } + newSet := s.Generic().Difference(set.Generic()) + return &wasmPluginSet{set: newSet} +} + +func (s *wasmPluginSet) Intersection(set WasmPluginSet) WasmPluginSet { + if s == nil { + return nil + } + newSet := s.Generic().Intersection(set.Generic()) + var wasmPluginList []*extensions_istio_io_v1alpha1.WasmPlugin + for _, obj := range newSet.List() { + wasmPluginList = append(wasmPluginList, obj.(*extensions_istio_io_v1alpha1.WasmPlugin)) + } + return NewWasmPluginSet(wasmPluginList...) +} + +func (s *wasmPluginSet) Find(id ezkube.ResourceId) (*extensions_istio_io_v1alpha1.WasmPlugin, error) { + if s == nil { + return nil, eris.Errorf("empty set, cannot find WasmPlugin %v", sksets.Key(id)) + } + obj, err := s.Generic().Find(&extensions_istio_io_v1alpha1.WasmPlugin{}, id) + if err != nil { + return nil, err + } + + return obj.(*extensions_istio_io_v1alpha1.WasmPlugin), nil +} + +func (s *wasmPluginSet) Length() int { + if s == nil { + return 0 + } + return s.Generic().Length() +} + +func (s *wasmPluginSet) Generic() sksets.ResourceSet { + if s == nil { + return nil + } + return s.set +} + +func (s *wasmPluginSet) Delta(newSet WasmPluginSet) sksets.ResourceDelta { + if s == nil { + return sksets.ResourceDelta{ + Inserted: newSet.Generic(), + } + } + return s.Generic().Delta(newSet.Generic()) +} + +func (s *wasmPluginSet) Clone() WasmPluginSet { + if s == nil { + return nil + } + return &wasmPluginSet{set: sksets.NewResourceSet(s.Generic().Clone().List()...)} +} diff --git a/pkg/api/istio/extensions.istio.io/v1alpha1/type_helpers.go b/pkg/api/istio/extensions.istio.io/v1alpha1/type_helpers.go new file mode 100644 index 0000000..b289296 --- /dev/null +++ b/pkg/api/istio/extensions.istio.io/v1alpha1/type_helpers.go @@ -0,0 +1,11 @@ +// Code generated by skv2. DO NOT EDIT. + +// Definitions for the Kubernetes types +package v1alpha1 + +import ( + . "istio.io/client-go/pkg/apis/extensions/v1alpha1" +) + +// WasmPluginSlice represents a slice of *WasmPlugin +type WasmPluginSlice []*WasmPlugin diff --git a/pkg/api/istio/networking.istio.io/v1beta1/clients.go b/pkg/api/istio/networking.istio.io/v1beta1/clients.go index 78730e5..764bec2 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/clients.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/clients.go @@ -45,6 +45,8 @@ type Clientset interface { // clienset for the networking.istio.io/v1beta1/v1beta1 APIs Gateways() GatewayClient // clienset for the networking.istio.io/v1beta1/v1beta1 APIs + ProxyConfigs() ProxyConfigClient + // clienset for the networking.istio.io/v1beta1/v1beta1 APIs ServiceEntries() ServiceEntryClient // clienset for the networking.istio.io/v1beta1/v1beta1 APIs WorkloadEntries() WorkloadEntryClient @@ -88,6 +90,11 @@ func (c *clientSet) Gateways() GatewayClient { return NewGatewayClient(c.client) } +// clienset for the networking.istio.io/v1beta1/v1beta1 APIs +func (c *clientSet) ProxyConfigs() ProxyConfigClient { + return NewProxyConfigClient(c.client) +} + // clienset for the networking.istio.io/v1beta1/v1beta1 APIs func (c *clientSet) ServiceEntries() ServiceEntryClient { return NewServiceEntryClient(c.client) @@ -397,6 +404,148 @@ func (m *multiclusterGatewayClient) Cluster(cluster string) (GatewayClient, erro return NewGatewayClient(client), nil } +// Reader knows how to read and list ProxyConfigs. +type ProxyConfigReader interface { + // Get retrieves a ProxyConfig for the given object key + GetProxyConfig(ctx context.Context, key client.ObjectKey) (*networking_istio_io_v1beta1.ProxyConfig, error) + + // List retrieves list of ProxyConfigs for a given namespace and list options. + ListProxyConfig(ctx context.Context, opts ...client.ListOption) (*networking_istio_io_v1beta1.ProxyConfigList, error) +} + +// ProxyConfigTransitionFunction instructs the ProxyConfigWriter how to transition between an existing +// ProxyConfig object and a desired on an Upsert +type ProxyConfigTransitionFunction func(existing, desired *networking_istio_io_v1beta1.ProxyConfig) error + +// Writer knows how to create, delete, and update ProxyConfigs. +type ProxyConfigWriter interface { + // Create saves the ProxyConfig object. + CreateProxyConfig(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, opts ...client.CreateOption) error + + // Delete deletes the ProxyConfig object. + DeleteProxyConfig(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error + + // Update updates the given ProxyConfig object. + UpdateProxyConfig(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, opts ...client.UpdateOption) error + + // Patch patches the given ProxyConfig object. + PatchProxyConfig(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, patch client.Patch, opts ...client.PatchOption) error + + // DeleteAllOf deletes all ProxyConfig objects matching the given options. + DeleteAllOfProxyConfig(ctx context.Context, opts ...client.DeleteAllOfOption) error + + // Create or Update the ProxyConfig object. + UpsertProxyConfig(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, transitionFuncs ...ProxyConfigTransitionFunction) error +} + +// StatusWriter knows how to update status subresource of a ProxyConfig object. +type ProxyConfigStatusWriter interface { + // Update updates the fields corresponding to the status subresource for the + // given ProxyConfig object. + UpdateProxyConfigStatus(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, opts ...client.SubResourceUpdateOption) error + + // Patch patches the given ProxyConfig object's subresource. + PatchProxyConfigStatus(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, patch client.Patch, opts ...client.SubResourcePatchOption) error +} + +// Client knows how to perform CRUD operations on ProxyConfigs. +type ProxyConfigClient interface { + ProxyConfigReader + ProxyConfigWriter + ProxyConfigStatusWriter +} + +type proxyConfigClient struct { + client client.Client +} + +func NewProxyConfigClient(client client.Client) *proxyConfigClient { + return &proxyConfigClient{client: client} +} + +func (c *proxyConfigClient) GetProxyConfig(ctx context.Context, key client.ObjectKey) (*networking_istio_io_v1beta1.ProxyConfig, error) { + obj := &networking_istio_io_v1beta1.ProxyConfig{} + if err := c.client.Get(ctx, key, obj); err != nil { + return nil, err + } + return obj, nil +} + +func (c *proxyConfigClient) ListProxyConfig(ctx context.Context, opts ...client.ListOption) (*networking_istio_io_v1beta1.ProxyConfigList, error) { + list := &networking_istio_io_v1beta1.ProxyConfigList{} + if err := c.client.List(ctx, list, opts...); err != nil { + return nil, err + } + return list, nil +} + +func (c *proxyConfigClient) CreateProxyConfig(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, opts ...client.CreateOption) error { + return c.client.Create(ctx, obj, opts...) +} + +func (c *proxyConfigClient) DeleteProxyConfig(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + obj := &networking_istio_io_v1beta1.ProxyConfig{} + obj.SetName(key.Name) + obj.SetNamespace(key.Namespace) + return c.client.Delete(ctx, obj, opts...) +} + +func (c *proxyConfigClient) UpdateProxyConfig(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, opts ...client.UpdateOption) error { + return c.client.Update(ctx, obj, opts...) +} + +func (c *proxyConfigClient) PatchProxyConfig(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, patch client.Patch, opts ...client.PatchOption) error { + return c.client.Patch(ctx, obj, patch, opts...) +} + +func (c *proxyConfigClient) DeleteAllOfProxyConfig(ctx context.Context, opts ...client.DeleteAllOfOption) error { + obj := &networking_istio_io_v1beta1.ProxyConfig{} + return c.client.DeleteAllOf(ctx, obj, opts...) +} + +func (c *proxyConfigClient) UpsertProxyConfig(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, transitionFuncs ...ProxyConfigTransitionFunction) error { + genericTxFunc := func(existing, desired runtime.Object) error { + for _, txFunc := range transitionFuncs { + if err := txFunc(existing.(*networking_istio_io_v1beta1.ProxyConfig), desired.(*networking_istio_io_v1beta1.ProxyConfig)); err != nil { + return err + } + } + return nil + } + _, err := controllerutils.Upsert(ctx, c.client, obj, genericTxFunc) + return err +} + +func (c *proxyConfigClient) UpdateProxyConfigStatus(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, opts ...client.SubResourceUpdateOption) error { + return c.client.Status().Update(ctx, obj, opts...) +} + +func (c *proxyConfigClient) PatchProxyConfigStatus(ctx context.Context, obj *networking_istio_io_v1beta1.ProxyConfig, patch client.Patch, opts ...client.SubResourcePatchOption) error { + return c.client.Status().Patch(ctx, obj, patch, opts...) +} + +// Provides ProxyConfigClients for multiple clusters. +type MulticlusterProxyConfigClient interface { + // Cluster returns a ProxyConfigClient for the given cluster + Cluster(cluster string) (ProxyConfigClient, error) +} + +type multiclusterProxyConfigClient struct { + client multicluster.Client +} + +func NewMulticlusterProxyConfigClient(client multicluster.Client) MulticlusterProxyConfigClient { + return &multiclusterProxyConfigClient{client: client} +} + +func (m *multiclusterProxyConfigClient) Cluster(cluster string) (ProxyConfigClient, error) { + client, err := m.client.Cluster(cluster) + if err != nil { + return nil, err + } + return NewProxyConfigClient(client), nil +} + // Reader knows how to read and list ServiceEntrys. type ServiceEntryReader interface { // Get retrieves a ServiceEntry for the given object key diff --git a/pkg/api/istio/networking.istio.io/v1beta1/controller/event_handlers.go b/pkg/api/istio/networking.istio.io/v1beta1/controller/event_handlers.go index 9eb2bf2..0115c14 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/controller/event_handlers.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/controller/event_handlers.go @@ -231,6 +231,113 @@ func (h genericGatewayHandler) Generic(object client.Object) error { return h.handler.GenericGateway(obj) } +// Handle events for the ProxyConfig Resource +// DEPRECATED: Prefer reconciler pattern. +type ProxyConfigEventHandler interface { + CreateProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) error + UpdateProxyConfig(old, new *networking_istio_io_v1beta1.ProxyConfig) error + DeleteProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) error + GenericProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) error +} + +type ProxyConfigEventHandlerFuncs struct { + OnCreate func(obj *networking_istio_io_v1beta1.ProxyConfig) error + OnUpdate func(old, new *networking_istio_io_v1beta1.ProxyConfig) error + OnDelete func(obj *networking_istio_io_v1beta1.ProxyConfig) error + OnGeneric func(obj *networking_istio_io_v1beta1.ProxyConfig) error +} + +func (f *ProxyConfigEventHandlerFuncs) CreateProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) error { + if f.OnCreate == nil { + return nil + } + return f.OnCreate(obj) +} + +func (f *ProxyConfigEventHandlerFuncs) DeleteProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) error { + if f.OnDelete == nil { + return nil + } + return f.OnDelete(obj) +} + +func (f *ProxyConfigEventHandlerFuncs) UpdateProxyConfig(objOld, objNew *networking_istio_io_v1beta1.ProxyConfig) error { + if f.OnUpdate == nil { + return nil + } + return f.OnUpdate(objOld, objNew) +} + +func (f *ProxyConfigEventHandlerFuncs) GenericProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) error { + if f.OnGeneric == nil { + return nil + } + return f.OnGeneric(obj) +} + +type ProxyConfigEventWatcher interface { + AddEventHandler(ctx context.Context, h ProxyConfigEventHandler, predicates ...predicate.Predicate) error +} + +type proxyConfigEventWatcher struct { + watcher events.EventWatcher +} + +func NewProxyConfigEventWatcher(name string, mgr manager.Manager) ProxyConfigEventWatcher { + return &proxyConfigEventWatcher{ + watcher: events.NewWatcher(name, mgr, &networking_istio_io_v1beta1.ProxyConfig{}), + } +} + +func (c *proxyConfigEventWatcher) AddEventHandler(ctx context.Context, h ProxyConfigEventHandler, predicates ...predicate.Predicate) error { + handler := genericProxyConfigHandler{handler: h} + if err := c.watcher.Watch(ctx, handler, predicates...); err != nil { + return err + } + return nil +} + +// genericProxyConfigHandler implements a generic events.EventHandler +type genericProxyConfigHandler struct { + handler ProxyConfigEventHandler +} + +func (h genericProxyConfigHandler) Create(object client.Object) error { + obj, ok := object.(*networking_istio_io_v1beta1.ProxyConfig) + if !ok { + return errors.Errorf("internal error: ProxyConfig handler received event for %T", object) + } + return h.handler.CreateProxyConfig(obj) +} + +func (h genericProxyConfigHandler) Delete(object client.Object) error { + obj, ok := object.(*networking_istio_io_v1beta1.ProxyConfig) + if !ok { + return errors.Errorf("internal error: ProxyConfig handler received event for %T", object) + } + return h.handler.DeleteProxyConfig(obj) +} + +func (h genericProxyConfigHandler) Update(old, new client.Object) error { + objOld, ok := old.(*networking_istio_io_v1beta1.ProxyConfig) + if !ok { + return errors.Errorf("internal error: ProxyConfig handler received event for %T", old) + } + objNew, ok := new.(*networking_istio_io_v1beta1.ProxyConfig) + if !ok { + return errors.Errorf("internal error: ProxyConfig handler received event for %T", new) + } + return h.handler.UpdateProxyConfig(objOld, objNew) +} + +func (h genericProxyConfigHandler) Generic(object client.Object) error { + obj, ok := object.(*networking_istio_io_v1beta1.ProxyConfig) + if !ok { + return errors.Errorf("internal error: ProxyConfig handler received event for %T", object) + } + return h.handler.GenericProxyConfig(obj) +} + // Handle events for the ServiceEntry Resource // DEPRECATED: Prefer reconciler pattern. type ServiceEntryEventHandler interface { diff --git a/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/event_handlers.go b/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/event_handlers.go index 4ec4206..7952d71 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/event_handlers.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/event_handlers.go @@ -256,6 +256,127 @@ func (mr *MockGatewayEventWatcherMockRecorder) AddEventHandler(ctx, h interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddEventHandler", reflect.TypeOf((*MockGatewayEventWatcher)(nil).AddEventHandler), varargs...) } +// MockProxyConfigEventHandler is a mock of ProxyConfigEventHandler interface. +type MockProxyConfigEventHandler struct { + ctrl *gomock.Controller + recorder *MockProxyConfigEventHandlerMockRecorder +} + +// MockProxyConfigEventHandlerMockRecorder is the mock recorder for MockProxyConfigEventHandler. +type MockProxyConfigEventHandlerMockRecorder struct { + mock *MockProxyConfigEventHandler +} + +// NewMockProxyConfigEventHandler creates a new mock instance. +func NewMockProxyConfigEventHandler(ctrl *gomock.Controller) *MockProxyConfigEventHandler { + mock := &MockProxyConfigEventHandler{ctrl: ctrl} + mock.recorder = &MockProxyConfigEventHandlerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigEventHandler) EXPECT() *MockProxyConfigEventHandlerMockRecorder { + return m.recorder +} + +// CreateProxyConfig mocks base method. +func (m *MockProxyConfigEventHandler) CreateProxyConfig(obj *v1beta1.ProxyConfig) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateProxyConfig", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateProxyConfig indicates an expected call of CreateProxyConfig. +func (mr *MockProxyConfigEventHandlerMockRecorder) CreateProxyConfig(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateProxyConfig", reflect.TypeOf((*MockProxyConfigEventHandler)(nil).CreateProxyConfig), obj) +} + +// DeleteProxyConfig mocks base method. +func (m *MockProxyConfigEventHandler) DeleteProxyConfig(obj *v1beta1.ProxyConfig) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteProxyConfig", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteProxyConfig indicates an expected call of DeleteProxyConfig. +func (mr *MockProxyConfigEventHandlerMockRecorder) DeleteProxyConfig(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteProxyConfig", reflect.TypeOf((*MockProxyConfigEventHandler)(nil).DeleteProxyConfig), obj) +} + +// GenericProxyConfig mocks base method. +func (m *MockProxyConfigEventHandler) GenericProxyConfig(obj *v1beta1.ProxyConfig) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GenericProxyConfig", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// GenericProxyConfig indicates an expected call of GenericProxyConfig. +func (mr *MockProxyConfigEventHandlerMockRecorder) GenericProxyConfig(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenericProxyConfig", reflect.TypeOf((*MockProxyConfigEventHandler)(nil).GenericProxyConfig), obj) +} + +// UpdateProxyConfig mocks base method. +func (m *MockProxyConfigEventHandler) UpdateProxyConfig(old, new *v1beta1.ProxyConfig) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateProxyConfig", old, new) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateProxyConfig indicates an expected call of UpdateProxyConfig. +func (mr *MockProxyConfigEventHandlerMockRecorder) UpdateProxyConfig(old, new interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateProxyConfig", reflect.TypeOf((*MockProxyConfigEventHandler)(nil).UpdateProxyConfig), old, new) +} + +// MockProxyConfigEventWatcher is a mock of ProxyConfigEventWatcher interface. +type MockProxyConfigEventWatcher struct { + ctrl *gomock.Controller + recorder *MockProxyConfigEventWatcherMockRecorder +} + +// MockProxyConfigEventWatcherMockRecorder is the mock recorder for MockProxyConfigEventWatcher. +type MockProxyConfigEventWatcherMockRecorder struct { + mock *MockProxyConfigEventWatcher +} + +// NewMockProxyConfigEventWatcher creates a new mock instance. +func NewMockProxyConfigEventWatcher(ctrl *gomock.Controller) *MockProxyConfigEventWatcher { + mock := &MockProxyConfigEventWatcher{ctrl: ctrl} + mock.recorder = &MockProxyConfigEventWatcherMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigEventWatcher) EXPECT() *MockProxyConfigEventWatcherMockRecorder { + return m.recorder +} + +// AddEventHandler mocks base method. +func (m *MockProxyConfigEventWatcher) AddEventHandler(ctx context.Context, h controller.ProxyConfigEventHandler, predicates ...predicate.Predicate) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, h} + for _, a := range predicates { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AddEventHandler", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddEventHandler indicates an expected call of AddEventHandler. +func (mr *MockProxyConfigEventWatcherMockRecorder) AddEventHandler(ctx, h interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, h}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddEventHandler", reflect.TypeOf((*MockProxyConfigEventWatcher)(nil).AddEventHandler), varargs...) +} + // MockServiceEntryEventHandler is a mock of ServiceEntryEventHandler interface. type MockServiceEntryEventHandler struct { ctrl *gomock.Controller diff --git a/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/multicluster_reconcilers.go b/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/multicluster_reconcilers.go index 5f32c8a..fcf3838 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/multicluster_reconcilers.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/multicluster_reconcilers.go @@ -245,6 +245,121 @@ func (mr *MockMulticlusterGatewayReconcileLoopMockRecorder) AddMulticlusterGatew return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMulticlusterGatewayReconciler", reflect.TypeOf((*MockMulticlusterGatewayReconcileLoop)(nil).AddMulticlusterGatewayReconciler), varargs...) } +// MockMulticlusterProxyConfigReconciler is a mock of MulticlusterProxyConfigReconciler interface. +type MockMulticlusterProxyConfigReconciler struct { + ctrl *gomock.Controller + recorder *MockMulticlusterProxyConfigReconcilerMockRecorder +} + +// MockMulticlusterProxyConfigReconcilerMockRecorder is the mock recorder for MockMulticlusterProxyConfigReconciler. +type MockMulticlusterProxyConfigReconcilerMockRecorder struct { + mock *MockMulticlusterProxyConfigReconciler +} + +// NewMockMulticlusterProxyConfigReconciler creates a new mock instance. +func NewMockMulticlusterProxyConfigReconciler(ctrl *gomock.Controller) *MockMulticlusterProxyConfigReconciler { + mock := &MockMulticlusterProxyConfigReconciler{ctrl: ctrl} + mock.recorder = &MockMulticlusterProxyConfigReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterProxyConfigReconciler) EXPECT() *MockMulticlusterProxyConfigReconcilerMockRecorder { + return m.recorder +} + +// ReconcileProxyConfig mocks base method. +func (m *MockMulticlusterProxyConfigReconciler) ReconcileProxyConfig(clusterName string, obj *v1beta1.ProxyConfig) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileProxyConfig", clusterName, obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileProxyConfig indicates an expected call of ReconcileProxyConfig. +func (mr *MockMulticlusterProxyConfigReconcilerMockRecorder) ReconcileProxyConfig(clusterName, obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileProxyConfig", reflect.TypeOf((*MockMulticlusterProxyConfigReconciler)(nil).ReconcileProxyConfig), clusterName, obj) +} + +// MockMulticlusterProxyConfigDeletionReconciler is a mock of MulticlusterProxyConfigDeletionReconciler interface. +type MockMulticlusterProxyConfigDeletionReconciler struct { + ctrl *gomock.Controller + recorder *MockMulticlusterProxyConfigDeletionReconcilerMockRecorder +} + +// MockMulticlusterProxyConfigDeletionReconcilerMockRecorder is the mock recorder for MockMulticlusterProxyConfigDeletionReconciler. +type MockMulticlusterProxyConfigDeletionReconcilerMockRecorder struct { + mock *MockMulticlusterProxyConfigDeletionReconciler +} + +// NewMockMulticlusterProxyConfigDeletionReconciler creates a new mock instance. +func NewMockMulticlusterProxyConfigDeletionReconciler(ctrl *gomock.Controller) *MockMulticlusterProxyConfigDeletionReconciler { + mock := &MockMulticlusterProxyConfigDeletionReconciler{ctrl: ctrl} + mock.recorder = &MockMulticlusterProxyConfigDeletionReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterProxyConfigDeletionReconciler) EXPECT() *MockMulticlusterProxyConfigDeletionReconcilerMockRecorder { + return m.recorder +} + +// ReconcileProxyConfigDeletion mocks base method. +func (m *MockMulticlusterProxyConfigDeletionReconciler) ReconcileProxyConfigDeletion(clusterName string, req reconcile.Request) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileProxyConfigDeletion", clusterName, req) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReconcileProxyConfigDeletion indicates an expected call of ReconcileProxyConfigDeletion. +func (mr *MockMulticlusterProxyConfigDeletionReconcilerMockRecorder) ReconcileProxyConfigDeletion(clusterName, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileProxyConfigDeletion", reflect.TypeOf((*MockMulticlusterProxyConfigDeletionReconciler)(nil).ReconcileProxyConfigDeletion), clusterName, req) +} + +// MockMulticlusterProxyConfigReconcileLoop is a mock of MulticlusterProxyConfigReconcileLoop interface. +type MockMulticlusterProxyConfigReconcileLoop struct { + ctrl *gomock.Controller + recorder *MockMulticlusterProxyConfigReconcileLoopMockRecorder +} + +// MockMulticlusterProxyConfigReconcileLoopMockRecorder is the mock recorder for MockMulticlusterProxyConfigReconcileLoop. +type MockMulticlusterProxyConfigReconcileLoopMockRecorder struct { + mock *MockMulticlusterProxyConfigReconcileLoop +} + +// NewMockMulticlusterProxyConfigReconcileLoop creates a new mock instance. +func NewMockMulticlusterProxyConfigReconcileLoop(ctrl *gomock.Controller) *MockMulticlusterProxyConfigReconcileLoop { + mock := &MockMulticlusterProxyConfigReconcileLoop{ctrl: ctrl} + mock.recorder = &MockMulticlusterProxyConfigReconcileLoopMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterProxyConfigReconcileLoop) EXPECT() *MockMulticlusterProxyConfigReconcileLoopMockRecorder { + return m.recorder +} + +// AddMulticlusterProxyConfigReconciler mocks base method. +func (m *MockMulticlusterProxyConfigReconcileLoop) AddMulticlusterProxyConfigReconciler(ctx context.Context, rec controller.MulticlusterProxyConfigReconciler, predicates ...predicate.Predicate) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, rec} + for _, a := range predicates { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "AddMulticlusterProxyConfigReconciler", varargs...) +} + +// AddMulticlusterProxyConfigReconciler indicates an expected call of AddMulticlusterProxyConfigReconciler. +func (mr *MockMulticlusterProxyConfigReconcileLoopMockRecorder) AddMulticlusterProxyConfigReconciler(ctx, rec interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, rec}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMulticlusterProxyConfigReconciler", reflect.TypeOf((*MockMulticlusterProxyConfigReconcileLoop)(nil).AddMulticlusterProxyConfigReconciler), varargs...) +} + // MockMulticlusterServiceEntryReconciler is a mock of MulticlusterServiceEntryReconciler interface. type MockMulticlusterServiceEntryReconciler struct { ctrl *gomock.Controller diff --git a/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/reconcilers.go b/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/reconcilers.go index 4b5499e..2579672 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/reconcilers.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/controller/mocks/reconcilers.go @@ -381,6 +381,189 @@ func (mr *MockGatewayReconcileLoopMockRecorder) RunGatewayReconciler(ctx, rec in return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunGatewayReconciler", reflect.TypeOf((*MockGatewayReconcileLoop)(nil).RunGatewayReconciler), varargs...) } +// MockProxyConfigReconciler is a mock of ProxyConfigReconciler interface. +type MockProxyConfigReconciler struct { + ctrl *gomock.Controller + recorder *MockProxyConfigReconcilerMockRecorder +} + +// MockProxyConfigReconcilerMockRecorder is the mock recorder for MockProxyConfigReconciler. +type MockProxyConfigReconcilerMockRecorder struct { + mock *MockProxyConfigReconciler +} + +// NewMockProxyConfigReconciler creates a new mock instance. +func NewMockProxyConfigReconciler(ctrl *gomock.Controller) *MockProxyConfigReconciler { + mock := &MockProxyConfigReconciler{ctrl: ctrl} + mock.recorder = &MockProxyConfigReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigReconciler) EXPECT() *MockProxyConfigReconcilerMockRecorder { + return m.recorder +} + +// ReconcileProxyConfig mocks base method. +func (m *MockProxyConfigReconciler) ReconcileProxyConfig(obj *v1beta1.ProxyConfig) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileProxyConfig", obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileProxyConfig indicates an expected call of ReconcileProxyConfig. +func (mr *MockProxyConfigReconcilerMockRecorder) ReconcileProxyConfig(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileProxyConfig", reflect.TypeOf((*MockProxyConfigReconciler)(nil).ReconcileProxyConfig), obj) +} + +// MockProxyConfigDeletionReconciler is a mock of ProxyConfigDeletionReconciler interface. +type MockProxyConfigDeletionReconciler struct { + ctrl *gomock.Controller + recorder *MockProxyConfigDeletionReconcilerMockRecorder +} + +// MockProxyConfigDeletionReconcilerMockRecorder is the mock recorder for MockProxyConfigDeletionReconciler. +type MockProxyConfigDeletionReconcilerMockRecorder struct { + mock *MockProxyConfigDeletionReconciler +} + +// NewMockProxyConfigDeletionReconciler creates a new mock instance. +func NewMockProxyConfigDeletionReconciler(ctrl *gomock.Controller) *MockProxyConfigDeletionReconciler { + mock := &MockProxyConfigDeletionReconciler{ctrl: ctrl} + mock.recorder = &MockProxyConfigDeletionReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigDeletionReconciler) EXPECT() *MockProxyConfigDeletionReconcilerMockRecorder { + return m.recorder +} + +// ReconcileProxyConfigDeletion mocks base method. +func (m *MockProxyConfigDeletionReconciler) ReconcileProxyConfigDeletion(req reconcile.Request) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileProxyConfigDeletion", req) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReconcileProxyConfigDeletion indicates an expected call of ReconcileProxyConfigDeletion. +func (mr *MockProxyConfigDeletionReconcilerMockRecorder) ReconcileProxyConfigDeletion(req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileProxyConfigDeletion", reflect.TypeOf((*MockProxyConfigDeletionReconciler)(nil).ReconcileProxyConfigDeletion), req) +} + +// MockProxyConfigFinalizer is a mock of ProxyConfigFinalizer interface. +type MockProxyConfigFinalizer struct { + ctrl *gomock.Controller + recorder *MockProxyConfigFinalizerMockRecorder +} + +// MockProxyConfigFinalizerMockRecorder is the mock recorder for MockProxyConfigFinalizer. +type MockProxyConfigFinalizerMockRecorder struct { + mock *MockProxyConfigFinalizer +} + +// NewMockProxyConfigFinalizer creates a new mock instance. +func NewMockProxyConfigFinalizer(ctrl *gomock.Controller) *MockProxyConfigFinalizer { + mock := &MockProxyConfigFinalizer{ctrl: ctrl} + mock.recorder = &MockProxyConfigFinalizerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigFinalizer) EXPECT() *MockProxyConfigFinalizerMockRecorder { + return m.recorder +} + +// FinalizeProxyConfig mocks base method. +func (m *MockProxyConfigFinalizer) FinalizeProxyConfig(obj *v1beta1.ProxyConfig) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FinalizeProxyConfig", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// FinalizeProxyConfig indicates an expected call of FinalizeProxyConfig. +func (mr *MockProxyConfigFinalizerMockRecorder) FinalizeProxyConfig(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FinalizeProxyConfig", reflect.TypeOf((*MockProxyConfigFinalizer)(nil).FinalizeProxyConfig), obj) +} + +// ProxyConfigFinalizerName mocks base method. +func (m *MockProxyConfigFinalizer) ProxyConfigFinalizerName() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ProxyConfigFinalizerName") + ret0, _ := ret[0].(string) + return ret0 +} + +// ProxyConfigFinalizerName indicates an expected call of ProxyConfigFinalizerName. +func (mr *MockProxyConfigFinalizerMockRecorder) ProxyConfigFinalizerName() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProxyConfigFinalizerName", reflect.TypeOf((*MockProxyConfigFinalizer)(nil).ProxyConfigFinalizerName)) +} + +// ReconcileProxyConfig mocks base method. +func (m *MockProxyConfigFinalizer) ReconcileProxyConfig(obj *v1beta1.ProxyConfig) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileProxyConfig", obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileProxyConfig indicates an expected call of ReconcileProxyConfig. +func (mr *MockProxyConfigFinalizerMockRecorder) ReconcileProxyConfig(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileProxyConfig", reflect.TypeOf((*MockProxyConfigFinalizer)(nil).ReconcileProxyConfig), obj) +} + +// MockProxyConfigReconcileLoop is a mock of ProxyConfigReconcileLoop interface. +type MockProxyConfigReconcileLoop struct { + ctrl *gomock.Controller + recorder *MockProxyConfigReconcileLoopMockRecorder +} + +// MockProxyConfigReconcileLoopMockRecorder is the mock recorder for MockProxyConfigReconcileLoop. +type MockProxyConfigReconcileLoopMockRecorder struct { + mock *MockProxyConfigReconcileLoop +} + +// NewMockProxyConfigReconcileLoop creates a new mock instance. +func NewMockProxyConfigReconcileLoop(ctrl *gomock.Controller) *MockProxyConfigReconcileLoop { + mock := &MockProxyConfigReconcileLoop{ctrl: ctrl} + mock.recorder = &MockProxyConfigReconcileLoopMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigReconcileLoop) EXPECT() *MockProxyConfigReconcileLoopMockRecorder { + return m.recorder +} + +// RunProxyConfigReconciler mocks base method. +func (m *MockProxyConfigReconcileLoop) RunProxyConfigReconciler(ctx context.Context, rec controller.ProxyConfigReconciler, predicates ...predicate.Predicate) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, rec} + for _, a := range predicates { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "RunProxyConfigReconciler", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// RunProxyConfigReconciler indicates an expected call of RunProxyConfigReconciler. +func (mr *MockProxyConfigReconcileLoopMockRecorder) RunProxyConfigReconciler(ctx, rec interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, rec}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunProxyConfigReconciler", reflect.TypeOf((*MockProxyConfigReconcileLoop)(nil).RunProxyConfigReconciler), varargs...) +} + // MockServiceEntryReconciler is a mock of ServiceEntryReconciler interface. type MockServiceEntryReconciler struct { ctrl *gomock.Controller diff --git a/pkg/api/istio/networking.istio.io/v1beta1/controller/multicluster_reconcilers.go b/pkg/api/istio/networking.istio.io/v1beta1/controller/multicluster_reconcilers.go index df62fea..f0925e8 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/controller/multicluster_reconcilers.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/controller/multicluster_reconcilers.go @@ -160,6 +160,77 @@ func (g genericGatewayMulticlusterReconciler) Reconcile(cluster string, object e return g.reconciler.ReconcileGateway(cluster, obj) } +// Reconcile Upsert events for the ProxyConfig Resource across clusters. +// implemented by the user +type MulticlusterProxyConfigReconciler interface { + ReconcileProxyConfig(clusterName string, obj *networking_istio_io_v1beta1.ProxyConfig) (reconcile.Result, error) +} + +// Reconcile deletion events for the ProxyConfig Resource across clusters. +// Deletion receives a reconcile.Request as we cannot guarantee the last state of the object +// before being deleted. +// implemented by the user +type MulticlusterProxyConfigDeletionReconciler interface { + ReconcileProxyConfigDeletion(clusterName string, req reconcile.Request) error +} + +type MulticlusterProxyConfigReconcilerFuncs struct { + OnReconcileProxyConfig func(clusterName string, obj *networking_istio_io_v1beta1.ProxyConfig) (reconcile.Result, error) + OnReconcileProxyConfigDeletion func(clusterName string, req reconcile.Request) error +} + +func (f *MulticlusterProxyConfigReconcilerFuncs) ReconcileProxyConfig(clusterName string, obj *networking_istio_io_v1beta1.ProxyConfig) (reconcile.Result, error) { + if f.OnReconcileProxyConfig == nil { + return reconcile.Result{}, nil + } + return f.OnReconcileProxyConfig(clusterName, obj) +} + +func (f *MulticlusterProxyConfigReconcilerFuncs) ReconcileProxyConfigDeletion(clusterName string, req reconcile.Request) error { + if f.OnReconcileProxyConfigDeletion == nil { + return nil + } + return f.OnReconcileProxyConfigDeletion(clusterName, req) +} + +type MulticlusterProxyConfigReconcileLoop interface { + // AddMulticlusterProxyConfigReconciler adds a MulticlusterProxyConfigReconciler to the MulticlusterProxyConfigReconcileLoop. + AddMulticlusterProxyConfigReconciler(ctx context.Context, rec MulticlusterProxyConfigReconciler, predicates ...predicate.Predicate) +} + +type multiclusterProxyConfigReconcileLoop struct { + loop multicluster.Loop +} + +func (m *multiclusterProxyConfigReconcileLoop) AddMulticlusterProxyConfigReconciler(ctx context.Context, rec MulticlusterProxyConfigReconciler, predicates ...predicate.Predicate) { + genericReconciler := genericProxyConfigMulticlusterReconciler{reconciler: rec} + + m.loop.AddReconciler(ctx, genericReconciler, predicates...) +} + +func NewMulticlusterProxyConfigReconcileLoop(name string, cw multicluster.ClusterWatcher, options reconcile.Options) MulticlusterProxyConfigReconcileLoop { + return &multiclusterProxyConfigReconcileLoop{loop: mc_reconcile.NewLoop(name, cw, &networking_istio_io_v1beta1.ProxyConfig{}, options)} +} + +type genericProxyConfigMulticlusterReconciler struct { + reconciler MulticlusterProxyConfigReconciler +} + +func (g genericProxyConfigMulticlusterReconciler) ReconcileDeletion(cluster string, req reconcile.Request) error { + if deletionReconciler, ok := g.reconciler.(MulticlusterProxyConfigDeletionReconciler); ok { + return deletionReconciler.ReconcileProxyConfigDeletion(cluster, req) + } + return nil +} + +func (g genericProxyConfigMulticlusterReconciler) Reconcile(cluster string, object ezkube.Object) (reconcile.Result, error) { + obj, ok := object.(*networking_istio_io_v1beta1.ProxyConfig) + if !ok { + return reconcile.Result{}, errors.Errorf("internal error: ProxyConfig handler received event for %T", object) + } + return g.reconciler.ReconcileProxyConfig(cluster, obj) +} + // Reconcile Upsert events for the ServiceEntry Resource across clusters. // implemented by the user type MulticlusterServiceEntryReconciler interface { diff --git a/pkg/api/istio/networking.istio.io/v1beta1/controller/reconcilers.go b/pkg/api/istio/networking.istio.io/v1beta1/controller/reconcilers.go index e722ec6..35aecfa 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/controller/reconcilers.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/controller/reconcilers.go @@ -251,6 +251,123 @@ func (r genericGatewayFinalizer) Finalize(object ezkube.Object) error { return r.finalizingReconciler.FinalizeGateway(obj) } +// Reconcile Upsert events for the ProxyConfig Resource. +// implemented by the user +type ProxyConfigReconciler interface { + ReconcileProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) (reconcile.Result, error) +} + +// Reconcile deletion events for the ProxyConfig Resource. +// Deletion receives a reconcile.Request as we cannot guarantee the last state of the object +// before being deleted. +// implemented by the user +type ProxyConfigDeletionReconciler interface { + ReconcileProxyConfigDeletion(req reconcile.Request) error +} + +type ProxyConfigReconcilerFuncs struct { + OnReconcileProxyConfig func(obj *networking_istio_io_v1beta1.ProxyConfig) (reconcile.Result, error) + OnReconcileProxyConfigDeletion func(req reconcile.Request) error +} + +func (f *ProxyConfigReconcilerFuncs) ReconcileProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) (reconcile.Result, error) { + if f.OnReconcileProxyConfig == nil { + return reconcile.Result{}, nil + } + return f.OnReconcileProxyConfig(obj) +} + +func (f *ProxyConfigReconcilerFuncs) ReconcileProxyConfigDeletion(req reconcile.Request) error { + if f.OnReconcileProxyConfigDeletion == nil { + return nil + } + return f.OnReconcileProxyConfigDeletion(req) +} + +// Reconcile and finalize the ProxyConfig Resource +// implemented by the user +type ProxyConfigFinalizer interface { + ProxyConfigReconciler + + // name of the finalizer used by this handler. + // finalizer names should be unique for a single task + ProxyConfigFinalizerName() string + + // finalize the object before it is deleted. + // Watchers created with a finalizing handler will a + FinalizeProxyConfig(obj *networking_istio_io_v1beta1.ProxyConfig) error +} + +type ProxyConfigReconcileLoop interface { + RunProxyConfigReconciler(ctx context.Context, rec ProxyConfigReconciler, predicates ...predicate.Predicate) error +} + +type proxyConfigReconcileLoop struct { + loop reconcile.Loop +} + +func NewProxyConfigReconcileLoop(name string, mgr manager.Manager, options reconcile.Options) ProxyConfigReconcileLoop { + return &proxyConfigReconcileLoop{ + // empty cluster indicates this reconciler is built for the local cluster + loop: reconcile.NewLoop(name, "", mgr, &networking_istio_io_v1beta1.ProxyConfig{}, options), + } +} + +func (c *proxyConfigReconcileLoop) RunProxyConfigReconciler(ctx context.Context, reconciler ProxyConfigReconciler, predicates ...predicate.Predicate) error { + genericReconciler := genericProxyConfigReconciler{ + reconciler: reconciler, + } + + var reconcilerWrapper reconcile.Reconciler + if finalizingReconciler, ok := reconciler.(ProxyConfigFinalizer); ok { + reconcilerWrapper = genericProxyConfigFinalizer{ + genericProxyConfigReconciler: genericReconciler, + finalizingReconciler: finalizingReconciler, + } + } else { + reconcilerWrapper = genericReconciler + } + return c.loop.RunReconciler(ctx, reconcilerWrapper, predicates...) +} + +// genericProxyConfigHandler implements a generic reconcile.Reconciler +type genericProxyConfigReconciler struct { + reconciler ProxyConfigReconciler +} + +func (r genericProxyConfigReconciler) Reconcile(object ezkube.Object) (reconcile.Result, error) { + obj, ok := object.(*networking_istio_io_v1beta1.ProxyConfig) + if !ok { + return reconcile.Result{}, errors.Errorf("internal error: ProxyConfig handler received event for %T", object) + } + return r.reconciler.ReconcileProxyConfig(obj) +} + +func (r genericProxyConfigReconciler) ReconcileDeletion(request reconcile.Request) error { + if deletionReconciler, ok := r.reconciler.(ProxyConfigDeletionReconciler); ok { + return deletionReconciler.ReconcileProxyConfigDeletion(request) + } + return nil +} + +// genericProxyConfigFinalizer implements a generic reconcile.FinalizingReconciler +type genericProxyConfigFinalizer struct { + genericProxyConfigReconciler + finalizingReconciler ProxyConfigFinalizer +} + +func (r genericProxyConfigFinalizer) FinalizerName() string { + return r.finalizingReconciler.ProxyConfigFinalizerName() +} + +func (r genericProxyConfigFinalizer) Finalize(object ezkube.Object) error { + obj, ok := object.(*networking_istio_io_v1beta1.ProxyConfig) + if !ok { + return errors.Errorf("internal error: ProxyConfig handler received event for %T", object) + } + return r.finalizingReconciler.FinalizeProxyConfig(obj) +} + // Reconcile Upsert events for the ServiceEntry Resource. // implemented by the user type ServiceEntryReconciler interface { diff --git a/pkg/api/istio/networking.istio.io/v1beta1/mocks/clients.go b/pkg/api/istio/networking.istio.io/v1beta1/mocks/clients.go index 14fbb95..1b34c8d 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/mocks/clients.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/mocks/clients.go @@ -103,6 +103,20 @@ func (mr *MockClientsetMockRecorder) Gateways() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Gateways", reflect.TypeOf((*MockClientset)(nil).Gateways)) } +// ProxyConfigs mocks base method. +func (m *MockClientset) ProxyConfigs() v1beta1.ProxyConfigClient { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ProxyConfigs") + ret0, _ := ret[0].(v1beta1.ProxyConfigClient) + return ret0 +} + +// ProxyConfigs indicates an expected call of ProxyConfigs. +func (mr *MockClientsetMockRecorder) ProxyConfigs() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProxyConfigs", reflect.TypeOf((*MockClientset)(nil).ProxyConfigs)) +} + // ServiceEntries mocks base method. func (m *MockClientset) ServiceEntries() v1beta1.ServiceEntryClient { m.ctrl.T.Helper() @@ -1181,6 +1195,510 @@ func (mr *MockMulticlusterGatewayClientMockRecorder) Cluster(cluster interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cluster", reflect.TypeOf((*MockMulticlusterGatewayClient)(nil).Cluster), cluster) } +// MockProxyConfigReader is a mock of ProxyConfigReader interface. +type MockProxyConfigReader struct { + ctrl *gomock.Controller + recorder *MockProxyConfigReaderMockRecorder +} + +// MockProxyConfigReaderMockRecorder is the mock recorder for MockProxyConfigReader. +type MockProxyConfigReaderMockRecorder struct { + mock *MockProxyConfigReader +} + +// NewMockProxyConfigReader creates a new mock instance. +func NewMockProxyConfigReader(ctrl *gomock.Controller) *MockProxyConfigReader { + mock := &MockProxyConfigReader{ctrl: ctrl} + mock.recorder = &MockProxyConfigReaderMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigReader) EXPECT() *MockProxyConfigReaderMockRecorder { + return m.recorder +} + +// GetProxyConfig mocks base method. +func (m *MockProxyConfigReader) GetProxyConfig(ctx context.Context, key client.ObjectKey) (*v1beta10.ProxyConfig, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetProxyConfig", ctx, key) + ret0, _ := ret[0].(*v1beta10.ProxyConfig) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetProxyConfig indicates an expected call of GetProxyConfig. +func (mr *MockProxyConfigReaderMockRecorder) GetProxyConfig(ctx, key interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProxyConfig", reflect.TypeOf((*MockProxyConfigReader)(nil).GetProxyConfig), ctx, key) +} + +// ListProxyConfig mocks base method. +func (m *MockProxyConfigReader) ListProxyConfig(ctx context.Context, opts ...client.ListOption) (*v1beta10.ProxyConfigList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListProxyConfig", varargs...) + ret0, _ := ret[0].(*v1beta10.ProxyConfigList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListProxyConfig indicates an expected call of ListProxyConfig. +func (mr *MockProxyConfigReaderMockRecorder) ListProxyConfig(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListProxyConfig", reflect.TypeOf((*MockProxyConfigReader)(nil).ListProxyConfig), varargs...) +} + +// MockProxyConfigWriter is a mock of ProxyConfigWriter interface. +type MockProxyConfigWriter struct { + ctrl *gomock.Controller + recorder *MockProxyConfigWriterMockRecorder +} + +// MockProxyConfigWriterMockRecorder is the mock recorder for MockProxyConfigWriter. +type MockProxyConfigWriterMockRecorder struct { + mock *MockProxyConfigWriter +} + +// NewMockProxyConfigWriter creates a new mock instance. +func NewMockProxyConfigWriter(ctrl *gomock.Controller) *MockProxyConfigWriter { + mock := &MockProxyConfigWriter{ctrl: ctrl} + mock.recorder = &MockProxyConfigWriterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigWriter) EXPECT() *MockProxyConfigWriterMockRecorder { + return m.recorder +} + +// CreateProxyConfig mocks base method. +func (m *MockProxyConfigWriter) CreateProxyConfig(ctx context.Context, obj *v1beta10.ProxyConfig, opts ...client.CreateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateProxyConfig indicates an expected call of CreateProxyConfig. +func (mr *MockProxyConfigWriterMockRecorder) CreateProxyConfig(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateProxyConfig", reflect.TypeOf((*MockProxyConfigWriter)(nil).CreateProxyConfig), varargs...) +} + +// DeleteAllOfProxyConfig mocks base method. +func (m *MockProxyConfigWriter) DeleteAllOfProxyConfig(ctx context.Context, opts ...client.DeleteAllOfOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteAllOfProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteAllOfProxyConfig indicates an expected call of DeleteAllOfProxyConfig. +func (mr *MockProxyConfigWriterMockRecorder) DeleteAllOfProxyConfig(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllOfProxyConfig", reflect.TypeOf((*MockProxyConfigWriter)(nil).DeleteAllOfProxyConfig), varargs...) +} + +// DeleteProxyConfig mocks base method. +func (m *MockProxyConfigWriter) DeleteProxyConfig(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, key} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteProxyConfig indicates an expected call of DeleteProxyConfig. +func (mr *MockProxyConfigWriterMockRecorder) DeleteProxyConfig(ctx, key interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, key}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteProxyConfig", reflect.TypeOf((*MockProxyConfigWriter)(nil).DeleteProxyConfig), varargs...) +} + +// PatchProxyConfig mocks base method. +func (m *MockProxyConfigWriter) PatchProxyConfig(ctx context.Context, obj *v1beta10.ProxyConfig, patch client.Patch, opts ...client.PatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchProxyConfig indicates an expected call of PatchProxyConfig. +func (mr *MockProxyConfigWriterMockRecorder) PatchProxyConfig(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchProxyConfig", reflect.TypeOf((*MockProxyConfigWriter)(nil).PatchProxyConfig), varargs...) +} + +// UpdateProxyConfig mocks base method. +func (m *MockProxyConfigWriter) UpdateProxyConfig(ctx context.Context, obj *v1beta10.ProxyConfig, opts ...client.UpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateProxyConfig indicates an expected call of UpdateProxyConfig. +func (mr *MockProxyConfigWriterMockRecorder) UpdateProxyConfig(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateProxyConfig", reflect.TypeOf((*MockProxyConfigWriter)(nil).UpdateProxyConfig), varargs...) +} + +// UpsertProxyConfig mocks base method. +func (m *MockProxyConfigWriter) UpsertProxyConfig(ctx context.Context, obj *v1beta10.ProxyConfig, transitionFuncs ...v1beta1.ProxyConfigTransitionFunction) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range transitionFuncs { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpsertProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpsertProxyConfig indicates an expected call of UpsertProxyConfig. +func (mr *MockProxyConfigWriterMockRecorder) UpsertProxyConfig(ctx, obj interface{}, transitionFuncs ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, transitionFuncs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertProxyConfig", reflect.TypeOf((*MockProxyConfigWriter)(nil).UpsertProxyConfig), varargs...) +} + +// MockProxyConfigStatusWriter is a mock of ProxyConfigStatusWriter interface. +type MockProxyConfigStatusWriter struct { + ctrl *gomock.Controller + recorder *MockProxyConfigStatusWriterMockRecorder +} + +// MockProxyConfigStatusWriterMockRecorder is the mock recorder for MockProxyConfigStatusWriter. +type MockProxyConfigStatusWriterMockRecorder struct { + mock *MockProxyConfigStatusWriter +} + +// NewMockProxyConfigStatusWriter creates a new mock instance. +func NewMockProxyConfigStatusWriter(ctrl *gomock.Controller) *MockProxyConfigStatusWriter { + mock := &MockProxyConfigStatusWriter{ctrl: ctrl} + mock.recorder = &MockProxyConfigStatusWriterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigStatusWriter) EXPECT() *MockProxyConfigStatusWriterMockRecorder { + return m.recorder +} + +// PatchProxyConfigStatus mocks base method. +func (m *MockProxyConfigStatusWriter) PatchProxyConfigStatus(ctx context.Context, obj *v1beta10.ProxyConfig, patch client.Patch, opts ...client.SubResourcePatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchProxyConfigStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchProxyConfigStatus indicates an expected call of PatchProxyConfigStatus. +func (mr *MockProxyConfigStatusWriterMockRecorder) PatchProxyConfigStatus(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchProxyConfigStatus", reflect.TypeOf((*MockProxyConfigStatusWriter)(nil).PatchProxyConfigStatus), varargs...) +} + +// UpdateProxyConfigStatus mocks base method. +func (m *MockProxyConfigStatusWriter) UpdateProxyConfigStatus(ctx context.Context, obj *v1beta10.ProxyConfig, opts ...client.SubResourceUpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateProxyConfigStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateProxyConfigStatus indicates an expected call of UpdateProxyConfigStatus. +func (mr *MockProxyConfigStatusWriterMockRecorder) UpdateProxyConfigStatus(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateProxyConfigStatus", reflect.TypeOf((*MockProxyConfigStatusWriter)(nil).UpdateProxyConfigStatus), varargs...) +} + +// MockProxyConfigClient is a mock of ProxyConfigClient interface. +type MockProxyConfigClient struct { + ctrl *gomock.Controller + recorder *MockProxyConfigClientMockRecorder +} + +// MockProxyConfigClientMockRecorder is the mock recorder for MockProxyConfigClient. +type MockProxyConfigClientMockRecorder struct { + mock *MockProxyConfigClient +} + +// NewMockProxyConfigClient creates a new mock instance. +func NewMockProxyConfigClient(ctrl *gomock.Controller) *MockProxyConfigClient { + mock := &MockProxyConfigClient{ctrl: ctrl} + mock.recorder = &MockProxyConfigClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigClient) EXPECT() *MockProxyConfigClientMockRecorder { + return m.recorder +} + +// CreateProxyConfig mocks base method. +func (m *MockProxyConfigClient) CreateProxyConfig(ctx context.Context, obj *v1beta10.ProxyConfig, opts ...client.CreateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateProxyConfig indicates an expected call of CreateProxyConfig. +func (mr *MockProxyConfigClientMockRecorder) CreateProxyConfig(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateProxyConfig", reflect.TypeOf((*MockProxyConfigClient)(nil).CreateProxyConfig), varargs...) +} + +// DeleteAllOfProxyConfig mocks base method. +func (m *MockProxyConfigClient) DeleteAllOfProxyConfig(ctx context.Context, opts ...client.DeleteAllOfOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteAllOfProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteAllOfProxyConfig indicates an expected call of DeleteAllOfProxyConfig. +func (mr *MockProxyConfigClientMockRecorder) DeleteAllOfProxyConfig(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllOfProxyConfig", reflect.TypeOf((*MockProxyConfigClient)(nil).DeleteAllOfProxyConfig), varargs...) +} + +// DeleteProxyConfig mocks base method. +func (m *MockProxyConfigClient) DeleteProxyConfig(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, key} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteProxyConfig indicates an expected call of DeleteProxyConfig. +func (mr *MockProxyConfigClientMockRecorder) DeleteProxyConfig(ctx, key interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, key}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteProxyConfig", reflect.TypeOf((*MockProxyConfigClient)(nil).DeleteProxyConfig), varargs...) +} + +// GetProxyConfig mocks base method. +func (m *MockProxyConfigClient) GetProxyConfig(ctx context.Context, key client.ObjectKey) (*v1beta10.ProxyConfig, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetProxyConfig", ctx, key) + ret0, _ := ret[0].(*v1beta10.ProxyConfig) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetProxyConfig indicates an expected call of GetProxyConfig. +func (mr *MockProxyConfigClientMockRecorder) GetProxyConfig(ctx, key interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProxyConfig", reflect.TypeOf((*MockProxyConfigClient)(nil).GetProxyConfig), ctx, key) +} + +// ListProxyConfig mocks base method. +func (m *MockProxyConfigClient) ListProxyConfig(ctx context.Context, opts ...client.ListOption) (*v1beta10.ProxyConfigList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListProxyConfig", varargs...) + ret0, _ := ret[0].(*v1beta10.ProxyConfigList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListProxyConfig indicates an expected call of ListProxyConfig. +func (mr *MockProxyConfigClientMockRecorder) ListProxyConfig(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListProxyConfig", reflect.TypeOf((*MockProxyConfigClient)(nil).ListProxyConfig), varargs...) +} + +// PatchProxyConfig mocks base method. +func (m *MockProxyConfigClient) PatchProxyConfig(ctx context.Context, obj *v1beta10.ProxyConfig, patch client.Patch, opts ...client.PatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchProxyConfig indicates an expected call of PatchProxyConfig. +func (mr *MockProxyConfigClientMockRecorder) PatchProxyConfig(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchProxyConfig", reflect.TypeOf((*MockProxyConfigClient)(nil).PatchProxyConfig), varargs...) +} + +// PatchProxyConfigStatus mocks base method. +func (m *MockProxyConfigClient) PatchProxyConfigStatus(ctx context.Context, obj *v1beta10.ProxyConfig, patch client.Patch, opts ...client.SubResourcePatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchProxyConfigStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchProxyConfigStatus indicates an expected call of PatchProxyConfigStatus. +func (mr *MockProxyConfigClientMockRecorder) PatchProxyConfigStatus(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchProxyConfigStatus", reflect.TypeOf((*MockProxyConfigClient)(nil).PatchProxyConfigStatus), varargs...) +} + +// UpdateProxyConfig mocks base method. +func (m *MockProxyConfigClient) UpdateProxyConfig(ctx context.Context, obj *v1beta10.ProxyConfig, opts ...client.UpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateProxyConfig indicates an expected call of UpdateProxyConfig. +func (mr *MockProxyConfigClientMockRecorder) UpdateProxyConfig(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateProxyConfig", reflect.TypeOf((*MockProxyConfigClient)(nil).UpdateProxyConfig), varargs...) +} + +// UpdateProxyConfigStatus mocks base method. +func (m *MockProxyConfigClient) UpdateProxyConfigStatus(ctx context.Context, obj *v1beta10.ProxyConfig, opts ...client.SubResourceUpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateProxyConfigStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateProxyConfigStatus indicates an expected call of UpdateProxyConfigStatus. +func (mr *MockProxyConfigClientMockRecorder) UpdateProxyConfigStatus(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateProxyConfigStatus", reflect.TypeOf((*MockProxyConfigClient)(nil).UpdateProxyConfigStatus), varargs...) +} + +// UpsertProxyConfig mocks base method. +func (m *MockProxyConfigClient) UpsertProxyConfig(ctx context.Context, obj *v1beta10.ProxyConfig, transitionFuncs ...v1beta1.ProxyConfigTransitionFunction) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range transitionFuncs { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpsertProxyConfig", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpsertProxyConfig indicates an expected call of UpsertProxyConfig. +func (mr *MockProxyConfigClientMockRecorder) UpsertProxyConfig(ctx, obj interface{}, transitionFuncs ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, transitionFuncs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertProxyConfig", reflect.TypeOf((*MockProxyConfigClient)(nil).UpsertProxyConfig), varargs...) +} + +// MockMulticlusterProxyConfigClient is a mock of MulticlusterProxyConfigClient interface. +type MockMulticlusterProxyConfigClient struct { + ctrl *gomock.Controller + recorder *MockMulticlusterProxyConfigClientMockRecorder +} + +// MockMulticlusterProxyConfigClientMockRecorder is the mock recorder for MockMulticlusterProxyConfigClient. +type MockMulticlusterProxyConfigClientMockRecorder struct { + mock *MockMulticlusterProxyConfigClient +} + +// NewMockMulticlusterProxyConfigClient creates a new mock instance. +func NewMockMulticlusterProxyConfigClient(ctrl *gomock.Controller) *MockMulticlusterProxyConfigClient { + mock := &MockMulticlusterProxyConfigClient{ctrl: ctrl} + mock.recorder = &MockMulticlusterProxyConfigClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterProxyConfigClient) EXPECT() *MockMulticlusterProxyConfigClientMockRecorder { + return m.recorder +} + +// Cluster mocks base method. +func (m *MockMulticlusterProxyConfigClient) Cluster(cluster string) (v1beta1.ProxyConfigClient, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Cluster", cluster) + ret0, _ := ret[0].(v1beta1.ProxyConfigClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Cluster indicates an expected call of Cluster. +func (mr *MockMulticlusterProxyConfigClientMockRecorder) Cluster(cluster interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cluster", reflect.TypeOf((*MockMulticlusterProxyConfigClient)(nil).Cluster), cluster) +} + // MockServiceEntryReader is a mock of ServiceEntryReader interface. type MockServiceEntryReader struct { ctrl *gomock.Controller diff --git a/pkg/api/istio/networking.istio.io/v1beta1/providers/client_providers.go b/pkg/api/istio/networking.istio.io/v1beta1/providers/client_providers.go index b1be572..6119a51 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/providers/client_providers.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/providers/client_providers.go @@ -73,6 +73,34 @@ func GatewayClientFromConfigFactoryProvider() GatewayClientFromConfigFactory { } } +// Provider for ProxyConfigClient from Clientset +func ProxyConfigClientFromClientsetProvider(clients networking_istio_io_v1beta1.Clientset) networking_istio_io_v1beta1.ProxyConfigClient { + return clients.ProxyConfigs() +} + +// Provider for ProxyConfig Client from Client +func ProxyConfigClientProvider(client client.Client) networking_istio_io_v1beta1.ProxyConfigClient { + return networking_istio_io_v1beta1.NewProxyConfigClient(client) +} + +type ProxyConfigClientFactory func(client client.Client) networking_istio_io_v1beta1.ProxyConfigClient + +func ProxyConfigClientFactoryProvider() ProxyConfigClientFactory { + return ProxyConfigClientProvider +} + +type ProxyConfigClientFromConfigFactory func(cfg *rest.Config) (networking_istio_io_v1beta1.ProxyConfigClient, error) + +func ProxyConfigClientFromConfigFactoryProvider() ProxyConfigClientFromConfigFactory { + return func(cfg *rest.Config) (networking_istio_io_v1beta1.ProxyConfigClient, error) { + clients, err := networking_istio_io_v1beta1.NewClientsetFromConfig(cfg) + if err != nil { + return nil, err + } + return clients.ProxyConfigs(), nil + } +} + // Provider for ServiceEntryClient from Clientset func ServiceEntryClientFromClientsetProvider(clients networking_istio_io_v1beta1.Clientset) networking_istio_io_v1beta1.ServiceEntryClient { return clients.ServiceEntries() diff --git a/pkg/api/istio/networking.istio.io/v1beta1/sets/mocks/sets.go b/pkg/api/istio/networking.istio.io/v1beta1/sets/mocks/sets.go index 91a79cc..dc15a4a 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/sets/mocks/sets.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/sets/mocks/sets.go @@ -527,6 +527,262 @@ func (mr *MockGatewaySetMockRecorder) UnsortedList(filterResource ...interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnsortedList", reflect.TypeOf((*MockGatewaySet)(nil).UnsortedList), filterResource...) } +// MockProxyConfigSet is a mock of ProxyConfigSet interface. +type MockProxyConfigSet struct { + ctrl *gomock.Controller + recorder *MockProxyConfigSetMockRecorder +} + +// MockProxyConfigSetMockRecorder is the mock recorder for MockProxyConfigSet. +type MockProxyConfigSetMockRecorder struct { + mock *MockProxyConfigSet +} + +// NewMockProxyConfigSet creates a new mock instance. +func NewMockProxyConfigSet(ctrl *gomock.Controller) *MockProxyConfigSet { + mock := &MockProxyConfigSet{ctrl: ctrl} + mock.recorder = &MockProxyConfigSetMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockProxyConfigSet) EXPECT() *MockProxyConfigSetMockRecorder { + return m.recorder +} + +// Clone mocks base method. +func (m *MockProxyConfigSet) Clone() v1beta1sets.ProxyConfigSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Clone") + ret0, _ := ret[0].(v1beta1sets.ProxyConfigSet) + return ret0 +} + +// Clone indicates an expected call of Clone. +func (mr *MockProxyConfigSetMockRecorder) Clone() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clone", reflect.TypeOf((*MockProxyConfigSet)(nil).Clone)) +} + +// Delete mocks base method. +func (m *MockProxyConfigSet) Delete(proxyConfig ezkube.ResourceId) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Delete", proxyConfig) +} + +// Delete indicates an expected call of Delete. +func (mr *MockProxyConfigSetMockRecorder) Delete(proxyConfig interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockProxyConfigSet)(nil).Delete), proxyConfig) +} + +// Delta mocks base method. +func (m *MockProxyConfigSet) Delta(newSet v1beta1sets.ProxyConfigSet) sets.ResourceDelta { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delta", newSet) + ret0, _ := ret[0].(sets.ResourceDelta) + return ret0 +} + +// Delta indicates an expected call of Delta. +func (mr *MockProxyConfigSetMockRecorder) Delta(newSet interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delta", reflect.TypeOf((*MockProxyConfigSet)(nil).Delta), newSet) +} + +// Difference mocks base method. +func (m *MockProxyConfigSet) Difference(set v1beta1sets.ProxyConfigSet) v1beta1sets.ProxyConfigSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Difference", set) + ret0, _ := ret[0].(v1beta1sets.ProxyConfigSet) + return ret0 +} + +// Difference indicates an expected call of Difference. +func (mr *MockProxyConfigSetMockRecorder) Difference(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Difference", reflect.TypeOf((*MockProxyConfigSet)(nil).Difference), set) +} + +// Equal mocks base method. +func (m *MockProxyConfigSet) Equal(proxyConfigSet v1beta1sets.ProxyConfigSet) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Equal", proxyConfigSet) + ret0, _ := ret[0].(bool) + return ret0 +} + +// Equal indicates an expected call of Equal. +func (mr *MockProxyConfigSetMockRecorder) Equal(proxyConfigSet interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Equal", reflect.TypeOf((*MockProxyConfigSet)(nil).Equal), proxyConfigSet) +} + +// Find mocks base method. +func (m *MockProxyConfigSet) Find(id ezkube.ResourceId) (*v1beta1.ProxyConfig, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Find", id) + ret0, _ := ret[0].(*v1beta1.ProxyConfig) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Find indicates an expected call of Find. +func (mr *MockProxyConfigSetMockRecorder) Find(id interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockProxyConfigSet)(nil).Find), id) +} + +// Generic mocks base method. +func (m *MockProxyConfigSet) Generic() sets.ResourceSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Generic") + ret0, _ := ret[0].(sets.ResourceSet) + return ret0 +} + +// Generic indicates an expected call of Generic. +func (mr *MockProxyConfigSetMockRecorder) Generic() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Generic", reflect.TypeOf((*MockProxyConfigSet)(nil).Generic)) +} + +// Has mocks base method. +func (m *MockProxyConfigSet) Has(proxyConfig ezkube.ResourceId) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Has", proxyConfig) + ret0, _ := ret[0].(bool) + return ret0 +} + +// Has indicates an expected call of Has. +func (mr *MockProxyConfigSetMockRecorder) Has(proxyConfig interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Has", reflect.TypeOf((*MockProxyConfigSet)(nil).Has), proxyConfig) +} + +// Insert mocks base method. +func (m *MockProxyConfigSet) Insert(proxyConfig ...*v1beta1.ProxyConfig) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range proxyConfig { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Insert", varargs...) +} + +// Insert indicates an expected call of Insert. +func (mr *MockProxyConfigSetMockRecorder) Insert(proxyConfig ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockProxyConfigSet)(nil).Insert), proxyConfig...) +} + +// Intersection mocks base method. +func (m *MockProxyConfigSet) Intersection(set v1beta1sets.ProxyConfigSet) v1beta1sets.ProxyConfigSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Intersection", set) + ret0, _ := ret[0].(v1beta1sets.ProxyConfigSet) + return ret0 +} + +// Intersection indicates an expected call of Intersection. +func (mr *MockProxyConfigSetMockRecorder) Intersection(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Intersection", reflect.TypeOf((*MockProxyConfigSet)(nil).Intersection), set) +} + +// Keys mocks base method. +func (m *MockProxyConfigSet) Keys() sets0.String { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Keys") + ret0, _ := ret[0].(sets0.String) + return ret0 +} + +// Keys indicates an expected call of Keys. +func (mr *MockProxyConfigSetMockRecorder) Keys() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Keys", reflect.TypeOf((*MockProxyConfigSet)(nil).Keys)) +} + +// Length mocks base method. +func (m *MockProxyConfigSet) Length() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Length") + ret0, _ := ret[0].(int) + return ret0 +} + +// Length indicates an expected call of Length. +func (mr *MockProxyConfigSetMockRecorder) Length() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Length", reflect.TypeOf((*MockProxyConfigSet)(nil).Length)) +} + +// List mocks base method. +func (m *MockProxyConfigSet) List(filterResource ...func(*v1beta1.ProxyConfig) bool) []*v1beta1.ProxyConfig { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range filterResource { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].([]*v1beta1.ProxyConfig) + return ret0 +} + +// List indicates an expected call of List. +func (mr *MockProxyConfigSetMockRecorder) List(filterResource ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockProxyConfigSet)(nil).List), filterResource...) +} + +// Map mocks base method. +func (m *MockProxyConfigSet) Map() map[string]*v1beta1.ProxyConfig { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Map") + ret0, _ := ret[0].(map[string]*v1beta1.ProxyConfig) + return ret0 +} + +// Map indicates an expected call of Map. +func (mr *MockProxyConfigSetMockRecorder) Map() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Map", reflect.TypeOf((*MockProxyConfigSet)(nil).Map)) +} + +// Union mocks base method. +func (m *MockProxyConfigSet) Union(set v1beta1sets.ProxyConfigSet) v1beta1sets.ProxyConfigSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Union", set) + ret0, _ := ret[0].(v1beta1sets.ProxyConfigSet) + return ret0 +} + +// Union indicates an expected call of Union. +func (mr *MockProxyConfigSetMockRecorder) Union(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Union", reflect.TypeOf((*MockProxyConfigSet)(nil).Union), set) +} + +// UnsortedList mocks base method. +func (m *MockProxyConfigSet) UnsortedList(filterResource ...func(*v1beta1.ProxyConfig) bool) []*v1beta1.ProxyConfig { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range filterResource { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UnsortedList", varargs...) + ret0, _ := ret[0].([]*v1beta1.ProxyConfig) + return ret0 +} + +// UnsortedList indicates an expected call of UnsortedList. +func (mr *MockProxyConfigSetMockRecorder) UnsortedList(filterResource ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnsortedList", reflect.TypeOf((*MockProxyConfigSet)(nil).UnsortedList), filterResource...) +} + // MockServiceEntrySet is a mock of ServiceEntrySet interface. type MockServiceEntrySet struct { ctrl *gomock.Controller diff --git a/pkg/api/istio/networking.istio.io/v1beta1/sets/sets.go b/pkg/api/istio/networking.istio.io/v1beta1/sets/sets.go index 09df0f0..1920e5a 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/sets/sets.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/sets/sets.go @@ -459,6 +459,229 @@ func (s *gatewaySet) Clone() GatewaySet { return &gatewaySet{set: sksets.NewResourceSet(s.Generic().Clone().List()...)} } +type ProxyConfigSet interface { + // Get the set stored keys + Keys() sets.String + // List of resources stored in the set. Pass an optional filter function to filter on the list. + // The filter function should return false to keep the resource, true to drop it. + List(filterResource ...func(*networking_istio_io_v1beta1.ProxyConfig) bool) []*networking_istio_io_v1beta1.ProxyConfig + // Unsorted list of resources stored in the set. Pass an optional filter function to filter on the list. + // The filter function should return false to keep the resource, true to drop it. + UnsortedList(filterResource ...func(*networking_istio_io_v1beta1.ProxyConfig) bool) []*networking_istio_io_v1beta1.ProxyConfig + // Return the Set as a map of key to resource. + Map() map[string]*networking_istio_io_v1beta1.ProxyConfig + // Insert a resource into the set. + Insert(proxyConfig ...*networking_istio_io_v1beta1.ProxyConfig) + // Compare the equality of the keys in two sets (not the resources themselves) + Equal(proxyConfigSet ProxyConfigSet) bool + // Check if the set contains a key matching the resource (not the resource itself) + Has(proxyConfig ezkube.ResourceId) bool + // Delete the key matching the resource + Delete(proxyConfig ezkube.ResourceId) + // Return the union with the provided set + Union(set ProxyConfigSet) ProxyConfigSet + // Return the difference with the provided set + Difference(set ProxyConfigSet) ProxyConfigSet + // Return the intersection with the provided set + Intersection(set ProxyConfigSet) ProxyConfigSet + // Find the resource with the given ID + Find(id ezkube.ResourceId) (*networking_istio_io_v1beta1.ProxyConfig, error) + // Get the length of the set + Length() int + // returns the generic implementation of the set + Generic() sksets.ResourceSet + // returns the delta between this and and another ProxyConfigSet + Delta(newSet ProxyConfigSet) sksets.ResourceDelta + // Create a deep copy of the current ProxyConfigSet + Clone() ProxyConfigSet +} + +func makeGenericProxyConfigSet(proxyConfigList []*networking_istio_io_v1beta1.ProxyConfig) sksets.ResourceSet { + var genericResources []ezkube.ResourceId + for _, obj := range proxyConfigList { + genericResources = append(genericResources, obj) + } + return sksets.NewResourceSet(genericResources...) +} + +type proxyConfigSet struct { + set sksets.ResourceSet +} + +func NewProxyConfigSet(proxyConfigList ...*networking_istio_io_v1beta1.ProxyConfig) ProxyConfigSet { + return &proxyConfigSet{set: makeGenericProxyConfigSet(proxyConfigList)} +} + +func NewProxyConfigSetFromList(proxyConfigList *networking_istio_io_v1beta1.ProxyConfigList) ProxyConfigSet { + list := make([]*networking_istio_io_v1beta1.ProxyConfig, 0, len(proxyConfigList.Items)) + for idx := range proxyConfigList.Items { + list = append(list, proxyConfigList.Items[idx]) + } + return &proxyConfigSet{set: makeGenericProxyConfigSet(list)} +} + +func (s *proxyConfigSet) Keys() sets.String { + if s == nil { + return sets.String{} + } + return s.Generic().Keys() +} + +func (s *proxyConfigSet) List(filterResource ...func(*networking_istio_io_v1beta1.ProxyConfig) bool) []*networking_istio_io_v1beta1.ProxyConfig { + if s == nil { + return nil + } + var genericFilters []func(ezkube.ResourceId) bool + for _, filter := range filterResource { + filter := filter + genericFilters = append(genericFilters, func(obj ezkube.ResourceId) bool { + return filter(obj.(*networking_istio_io_v1beta1.ProxyConfig)) + }) + } + + objs := s.Generic().List(genericFilters...) + proxyConfigList := make([]*networking_istio_io_v1beta1.ProxyConfig, 0, len(objs)) + for _, obj := range objs { + proxyConfigList = append(proxyConfigList, obj.(*networking_istio_io_v1beta1.ProxyConfig)) + } + return proxyConfigList +} + +func (s *proxyConfigSet) UnsortedList(filterResource ...func(*networking_istio_io_v1beta1.ProxyConfig) bool) []*networking_istio_io_v1beta1.ProxyConfig { + if s == nil { + return nil + } + var genericFilters []func(ezkube.ResourceId) bool + for _, filter := range filterResource { + filter := filter + genericFilters = append(genericFilters, func(obj ezkube.ResourceId) bool { + return filter(obj.(*networking_istio_io_v1beta1.ProxyConfig)) + }) + } + + var proxyConfigList []*networking_istio_io_v1beta1.ProxyConfig + for _, obj := range s.Generic().UnsortedList(genericFilters...) { + proxyConfigList = append(proxyConfigList, obj.(*networking_istio_io_v1beta1.ProxyConfig)) + } + return proxyConfigList +} + +func (s *proxyConfigSet) Map() map[string]*networking_istio_io_v1beta1.ProxyConfig { + if s == nil { + return nil + } + + newMap := map[string]*networking_istio_io_v1beta1.ProxyConfig{} + for k, v := range s.Generic().Map() { + newMap[k] = v.(*networking_istio_io_v1beta1.ProxyConfig) + } + return newMap +} + +func (s *proxyConfigSet) Insert( + proxyConfigList ...*networking_istio_io_v1beta1.ProxyConfig, +) { + if s == nil { + panic("cannot insert into nil set") + } + + for _, obj := range proxyConfigList { + s.Generic().Insert(obj) + } +} + +func (s *proxyConfigSet) Has(proxyConfig ezkube.ResourceId) bool { + if s == nil { + return false + } + return s.Generic().Has(proxyConfig) +} + +func (s *proxyConfigSet) Equal( + proxyConfigSet ProxyConfigSet, +) bool { + if s == nil { + return proxyConfigSet == nil + } + return s.Generic().Equal(proxyConfigSet.Generic()) +} + +func (s *proxyConfigSet) Delete(ProxyConfig ezkube.ResourceId) { + if s == nil { + return + } + s.Generic().Delete(ProxyConfig) +} + +func (s *proxyConfigSet) Union(set ProxyConfigSet) ProxyConfigSet { + if s == nil { + return set + } + return NewProxyConfigSet(append(s.List(), set.List()...)...) +} + +func (s *proxyConfigSet) Difference(set ProxyConfigSet) ProxyConfigSet { + if s == nil { + return set + } + newSet := s.Generic().Difference(set.Generic()) + return &proxyConfigSet{set: newSet} +} + +func (s *proxyConfigSet) Intersection(set ProxyConfigSet) ProxyConfigSet { + if s == nil { + return nil + } + newSet := s.Generic().Intersection(set.Generic()) + var proxyConfigList []*networking_istio_io_v1beta1.ProxyConfig + for _, obj := range newSet.List() { + proxyConfigList = append(proxyConfigList, obj.(*networking_istio_io_v1beta1.ProxyConfig)) + } + return NewProxyConfigSet(proxyConfigList...) +} + +func (s *proxyConfigSet) Find(id ezkube.ResourceId) (*networking_istio_io_v1beta1.ProxyConfig, error) { + if s == nil { + return nil, eris.Errorf("empty set, cannot find ProxyConfig %v", sksets.Key(id)) + } + obj, err := s.Generic().Find(&networking_istio_io_v1beta1.ProxyConfig{}, id) + if err != nil { + return nil, err + } + + return obj.(*networking_istio_io_v1beta1.ProxyConfig), nil +} + +func (s *proxyConfigSet) Length() int { + if s == nil { + return 0 + } + return s.Generic().Length() +} + +func (s *proxyConfigSet) Generic() sksets.ResourceSet { + if s == nil { + return nil + } + return s.set +} + +func (s *proxyConfigSet) Delta(newSet ProxyConfigSet) sksets.ResourceDelta { + if s == nil { + return sksets.ResourceDelta{ + Inserted: newSet.Generic(), + } + } + return s.Generic().Delta(newSet.Generic()) +} + +func (s *proxyConfigSet) Clone() ProxyConfigSet { + if s == nil { + return nil + } + return &proxyConfigSet{set: sksets.NewResourceSet(s.Generic().Clone().List()...)} +} + type ServiceEntrySet interface { // Get the set stored keys Keys() sets.String diff --git a/pkg/api/istio/networking.istio.io/v1beta1/type_helpers.go b/pkg/api/istio/networking.istio.io/v1beta1/type_helpers.go index 2f97f23..3cba43f 100644 --- a/pkg/api/istio/networking.istio.io/v1beta1/type_helpers.go +++ b/pkg/api/istio/networking.istio.io/v1beta1/type_helpers.go @@ -13,6 +13,9 @@ type DestinationRuleSlice []*DestinationRule // GatewaySlice represents a slice of *Gateway type GatewaySlice []*Gateway +// ProxyConfigSlice represents a slice of *ProxyConfig +type ProxyConfigSlice []*ProxyConfig + // ServiceEntrySlice represents a slice of *ServiceEntry type ServiceEntrySlice []*ServiceEntry diff --git a/pkg/api/istio/security.istio.io/v1beta1/clients.go b/pkg/api/istio/security.istio.io/v1beta1/clients.go index f6260c1..d445281 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/clients.go +++ b/pkg/api/istio/security.istio.io/v1beta1/clients.go @@ -44,6 +44,8 @@ type Clientset interface { AuthorizationPolicies() AuthorizationPolicyClient // clienset for the security.istio.io/v1beta1/v1beta1 APIs PeerAuthentications() PeerAuthenticationClient + // clienset for the security.istio.io/v1beta1/v1beta1 APIs + RequestAuthentications() RequestAuthenticationClient } type clientSet struct { @@ -78,6 +80,11 @@ func (c *clientSet) PeerAuthentications() PeerAuthenticationClient { return NewPeerAuthenticationClient(c.client) } +// clienset for the security.istio.io/v1beta1/v1beta1 APIs +func (c *clientSet) RequestAuthentications() RequestAuthenticationClient { + return NewRequestAuthenticationClient(c.client) +} + // Reader knows how to read and list AuthorizationPolicys. type AuthorizationPolicyReader interface { // Get retrieves a AuthorizationPolicy for the given object key @@ -361,3 +368,145 @@ func (m *multiclusterPeerAuthenticationClient) Cluster(cluster string) (PeerAuth } return NewPeerAuthenticationClient(client), nil } + +// Reader knows how to read and list RequestAuthentications. +type RequestAuthenticationReader interface { + // Get retrieves a RequestAuthentication for the given object key + GetRequestAuthentication(ctx context.Context, key client.ObjectKey) (*security_istio_io_v1beta1.RequestAuthentication, error) + + // List retrieves list of RequestAuthentications for a given namespace and list options. + ListRequestAuthentication(ctx context.Context, opts ...client.ListOption) (*security_istio_io_v1beta1.RequestAuthenticationList, error) +} + +// RequestAuthenticationTransitionFunction instructs the RequestAuthenticationWriter how to transition between an existing +// RequestAuthentication object and a desired on an Upsert +type RequestAuthenticationTransitionFunction func(existing, desired *security_istio_io_v1beta1.RequestAuthentication) error + +// Writer knows how to create, delete, and update RequestAuthentications. +type RequestAuthenticationWriter interface { + // Create saves the RequestAuthentication object. + CreateRequestAuthentication(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, opts ...client.CreateOption) error + + // Delete deletes the RequestAuthentication object. + DeleteRequestAuthentication(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error + + // Update updates the given RequestAuthentication object. + UpdateRequestAuthentication(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, opts ...client.UpdateOption) error + + // Patch patches the given RequestAuthentication object. + PatchRequestAuthentication(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, patch client.Patch, opts ...client.PatchOption) error + + // DeleteAllOf deletes all RequestAuthentication objects matching the given options. + DeleteAllOfRequestAuthentication(ctx context.Context, opts ...client.DeleteAllOfOption) error + + // Create or Update the RequestAuthentication object. + UpsertRequestAuthentication(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, transitionFuncs ...RequestAuthenticationTransitionFunction) error +} + +// StatusWriter knows how to update status subresource of a RequestAuthentication object. +type RequestAuthenticationStatusWriter interface { + // Update updates the fields corresponding to the status subresource for the + // given RequestAuthentication object. + UpdateRequestAuthenticationStatus(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, opts ...client.SubResourceUpdateOption) error + + // Patch patches the given RequestAuthentication object's subresource. + PatchRequestAuthenticationStatus(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, patch client.Patch, opts ...client.SubResourcePatchOption) error +} + +// Client knows how to perform CRUD operations on RequestAuthentications. +type RequestAuthenticationClient interface { + RequestAuthenticationReader + RequestAuthenticationWriter + RequestAuthenticationStatusWriter +} + +type requestAuthenticationClient struct { + client client.Client +} + +func NewRequestAuthenticationClient(client client.Client) *requestAuthenticationClient { + return &requestAuthenticationClient{client: client} +} + +func (c *requestAuthenticationClient) GetRequestAuthentication(ctx context.Context, key client.ObjectKey) (*security_istio_io_v1beta1.RequestAuthentication, error) { + obj := &security_istio_io_v1beta1.RequestAuthentication{} + if err := c.client.Get(ctx, key, obj); err != nil { + return nil, err + } + return obj, nil +} + +func (c *requestAuthenticationClient) ListRequestAuthentication(ctx context.Context, opts ...client.ListOption) (*security_istio_io_v1beta1.RequestAuthenticationList, error) { + list := &security_istio_io_v1beta1.RequestAuthenticationList{} + if err := c.client.List(ctx, list, opts...); err != nil { + return nil, err + } + return list, nil +} + +func (c *requestAuthenticationClient) CreateRequestAuthentication(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, opts ...client.CreateOption) error { + return c.client.Create(ctx, obj, opts...) +} + +func (c *requestAuthenticationClient) DeleteRequestAuthentication(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + obj := &security_istio_io_v1beta1.RequestAuthentication{} + obj.SetName(key.Name) + obj.SetNamespace(key.Namespace) + return c.client.Delete(ctx, obj, opts...) +} + +func (c *requestAuthenticationClient) UpdateRequestAuthentication(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, opts ...client.UpdateOption) error { + return c.client.Update(ctx, obj, opts...) +} + +func (c *requestAuthenticationClient) PatchRequestAuthentication(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, patch client.Patch, opts ...client.PatchOption) error { + return c.client.Patch(ctx, obj, patch, opts...) +} + +func (c *requestAuthenticationClient) DeleteAllOfRequestAuthentication(ctx context.Context, opts ...client.DeleteAllOfOption) error { + obj := &security_istio_io_v1beta1.RequestAuthentication{} + return c.client.DeleteAllOf(ctx, obj, opts...) +} + +func (c *requestAuthenticationClient) UpsertRequestAuthentication(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, transitionFuncs ...RequestAuthenticationTransitionFunction) error { + genericTxFunc := func(existing, desired runtime.Object) error { + for _, txFunc := range transitionFuncs { + if err := txFunc(existing.(*security_istio_io_v1beta1.RequestAuthentication), desired.(*security_istio_io_v1beta1.RequestAuthentication)); err != nil { + return err + } + } + return nil + } + _, err := controllerutils.Upsert(ctx, c.client, obj, genericTxFunc) + return err +} + +func (c *requestAuthenticationClient) UpdateRequestAuthenticationStatus(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, opts ...client.SubResourceUpdateOption) error { + return c.client.Status().Update(ctx, obj, opts...) +} + +func (c *requestAuthenticationClient) PatchRequestAuthenticationStatus(ctx context.Context, obj *security_istio_io_v1beta1.RequestAuthentication, patch client.Patch, opts ...client.SubResourcePatchOption) error { + return c.client.Status().Patch(ctx, obj, patch, opts...) +} + +// Provides RequestAuthenticationClients for multiple clusters. +type MulticlusterRequestAuthenticationClient interface { + // Cluster returns a RequestAuthenticationClient for the given cluster + Cluster(cluster string) (RequestAuthenticationClient, error) +} + +type multiclusterRequestAuthenticationClient struct { + client multicluster.Client +} + +func NewMulticlusterRequestAuthenticationClient(client multicluster.Client) MulticlusterRequestAuthenticationClient { + return &multiclusterRequestAuthenticationClient{client: client} +} + +func (m *multiclusterRequestAuthenticationClient) Cluster(cluster string) (RequestAuthenticationClient, error) { + client, err := m.client.Cluster(cluster) + if err != nil { + return nil, err + } + return NewRequestAuthenticationClient(client), nil +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/controller/event_handlers.go b/pkg/api/istio/security.istio.io/v1beta1/controller/event_handlers.go index d64c80e..4ef22aa 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/controller/event_handlers.go +++ b/pkg/api/istio/security.istio.io/v1beta1/controller/event_handlers.go @@ -230,3 +230,110 @@ func (h genericPeerAuthenticationHandler) Generic(object client.Object) error { } return h.handler.GenericPeerAuthentication(obj) } + +// Handle events for the RequestAuthentication Resource +// DEPRECATED: Prefer reconciler pattern. +type RequestAuthenticationEventHandler interface { + CreateRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) error + UpdateRequestAuthentication(old, new *security_istio_io_v1beta1.RequestAuthentication) error + DeleteRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) error + GenericRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) error +} + +type RequestAuthenticationEventHandlerFuncs struct { + OnCreate func(obj *security_istio_io_v1beta1.RequestAuthentication) error + OnUpdate func(old, new *security_istio_io_v1beta1.RequestAuthentication) error + OnDelete func(obj *security_istio_io_v1beta1.RequestAuthentication) error + OnGeneric func(obj *security_istio_io_v1beta1.RequestAuthentication) error +} + +func (f *RequestAuthenticationEventHandlerFuncs) CreateRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) error { + if f.OnCreate == nil { + return nil + } + return f.OnCreate(obj) +} + +func (f *RequestAuthenticationEventHandlerFuncs) DeleteRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) error { + if f.OnDelete == nil { + return nil + } + return f.OnDelete(obj) +} + +func (f *RequestAuthenticationEventHandlerFuncs) UpdateRequestAuthentication(objOld, objNew *security_istio_io_v1beta1.RequestAuthentication) error { + if f.OnUpdate == nil { + return nil + } + return f.OnUpdate(objOld, objNew) +} + +func (f *RequestAuthenticationEventHandlerFuncs) GenericRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) error { + if f.OnGeneric == nil { + return nil + } + return f.OnGeneric(obj) +} + +type RequestAuthenticationEventWatcher interface { + AddEventHandler(ctx context.Context, h RequestAuthenticationEventHandler, predicates ...predicate.Predicate) error +} + +type requestAuthenticationEventWatcher struct { + watcher events.EventWatcher +} + +func NewRequestAuthenticationEventWatcher(name string, mgr manager.Manager) RequestAuthenticationEventWatcher { + return &requestAuthenticationEventWatcher{ + watcher: events.NewWatcher(name, mgr, &security_istio_io_v1beta1.RequestAuthentication{}), + } +} + +func (c *requestAuthenticationEventWatcher) AddEventHandler(ctx context.Context, h RequestAuthenticationEventHandler, predicates ...predicate.Predicate) error { + handler := genericRequestAuthenticationHandler{handler: h} + if err := c.watcher.Watch(ctx, handler, predicates...); err != nil { + return err + } + return nil +} + +// genericRequestAuthenticationHandler implements a generic events.EventHandler +type genericRequestAuthenticationHandler struct { + handler RequestAuthenticationEventHandler +} + +func (h genericRequestAuthenticationHandler) Create(object client.Object) error { + obj, ok := object.(*security_istio_io_v1beta1.RequestAuthentication) + if !ok { + return errors.Errorf("internal error: RequestAuthentication handler received event for %T", object) + } + return h.handler.CreateRequestAuthentication(obj) +} + +func (h genericRequestAuthenticationHandler) Delete(object client.Object) error { + obj, ok := object.(*security_istio_io_v1beta1.RequestAuthentication) + if !ok { + return errors.Errorf("internal error: RequestAuthentication handler received event for %T", object) + } + return h.handler.DeleteRequestAuthentication(obj) +} + +func (h genericRequestAuthenticationHandler) Update(old, new client.Object) error { + objOld, ok := old.(*security_istio_io_v1beta1.RequestAuthentication) + if !ok { + return errors.Errorf("internal error: RequestAuthentication handler received event for %T", old) + } + objNew, ok := new.(*security_istio_io_v1beta1.RequestAuthentication) + if !ok { + return errors.Errorf("internal error: RequestAuthentication handler received event for %T", new) + } + return h.handler.UpdateRequestAuthentication(objOld, objNew) +} + +func (h genericRequestAuthenticationHandler) Generic(object client.Object) error { + obj, ok := object.(*security_istio_io_v1beta1.RequestAuthentication) + if !ok { + return errors.Errorf("internal error: RequestAuthentication handler received event for %T", object) + } + return h.handler.GenericRequestAuthentication(obj) +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/event_handlers.go b/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/event_handlers.go index 98a91ca..e89df03 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/event_handlers.go +++ b/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/event_handlers.go @@ -255,3 +255,124 @@ func (mr *MockPeerAuthenticationEventWatcherMockRecorder) AddEventHandler(ctx, h varargs := append([]interface{}{ctx, h}, predicates...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddEventHandler", reflect.TypeOf((*MockPeerAuthenticationEventWatcher)(nil).AddEventHandler), varargs...) } + +// MockRequestAuthenticationEventHandler is a mock of RequestAuthenticationEventHandler interface. +type MockRequestAuthenticationEventHandler struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationEventHandlerMockRecorder +} + +// MockRequestAuthenticationEventHandlerMockRecorder is the mock recorder for MockRequestAuthenticationEventHandler. +type MockRequestAuthenticationEventHandlerMockRecorder struct { + mock *MockRequestAuthenticationEventHandler +} + +// NewMockRequestAuthenticationEventHandler creates a new mock instance. +func NewMockRequestAuthenticationEventHandler(ctrl *gomock.Controller) *MockRequestAuthenticationEventHandler { + mock := &MockRequestAuthenticationEventHandler{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationEventHandlerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationEventHandler) EXPECT() *MockRequestAuthenticationEventHandlerMockRecorder { + return m.recorder +} + +// CreateRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationEventHandler) CreateRequestAuthentication(obj *v1beta1.RequestAuthentication) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateRequestAuthentication", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateRequestAuthentication indicates an expected call of CreateRequestAuthentication. +func (mr *MockRequestAuthenticationEventHandlerMockRecorder) CreateRequestAuthentication(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationEventHandler)(nil).CreateRequestAuthentication), obj) +} + +// DeleteRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationEventHandler) DeleteRequestAuthentication(obj *v1beta1.RequestAuthentication) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteRequestAuthentication", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteRequestAuthentication indicates an expected call of DeleteRequestAuthentication. +func (mr *MockRequestAuthenticationEventHandlerMockRecorder) DeleteRequestAuthentication(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationEventHandler)(nil).DeleteRequestAuthentication), obj) +} + +// GenericRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationEventHandler) GenericRequestAuthentication(obj *v1beta1.RequestAuthentication) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GenericRequestAuthentication", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// GenericRequestAuthentication indicates an expected call of GenericRequestAuthentication. +func (mr *MockRequestAuthenticationEventHandlerMockRecorder) GenericRequestAuthentication(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenericRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationEventHandler)(nil).GenericRequestAuthentication), obj) +} + +// UpdateRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationEventHandler) UpdateRequestAuthentication(old, new *v1beta1.RequestAuthentication) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateRequestAuthentication", old, new) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRequestAuthentication indicates an expected call of UpdateRequestAuthentication. +func (mr *MockRequestAuthenticationEventHandlerMockRecorder) UpdateRequestAuthentication(old, new interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationEventHandler)(nil).UpdateRequestAuthentication), old, new) +} + +// MockRequestAuthenticationEventWatcher is a mock of RequestAuthenticationEventWatcher interface. +type MockRequestAuthenticationEventWatcher struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationEventWatcherMockRecorder +} + +// MockRequestAuthenticationEventWatcherMockRecorder is the mock recorder for MockRequestAuthenticationEventWatcher. +type MockRequestAuthenticationEventWatcherMockRecorder struct { + mock *MockRequestAuthenticationEventWatcher +} + +// NewMockRequestAuthenticationEventWatcher creates a new mock instance. +func NewMockRequestAuthenticationEventWatcher(ctrl *gomock.Controller) *MockRequestAuthenticationEventWatcher { + mock := &MockRequestAuthenticationEventWatcher{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationEventWatcherMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationEventWatcher) EXPECT() *MockRequestAuthenticationEventWatcherMockRecorder { + return m.recorder +} + +// AddEventHandler mocks base method. +func (m *MockRequestAuthenticationEventWatcher) AddEventHandler(ctx context.Context, h controller.RequestAuthenticationEventHandler, predicates ...predicate.Predicate) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, h} + for _, a := range predicates { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AddEventHandler", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddEventHandler indicates an expected call of AddEventHandler. +func (mr *MockRequestAuthenticationEventWatcherMockRecorder) AddEventHandler(ctx, h interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, h}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddEventHandler", reflect.TypeOf((*MockRequestAuthenticationEventWatcher)(nil).AddEventHandler), varargs...) +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/multicluster_reconcilers.go b/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/multicluster_reconcilers.go index ad0d32a..346acf2 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/multicluster_reconcilers.go +++ b/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/multicluster_reconcilers.go @@ -244,3 +244,118 @@ func (mr *MockMulticlusterPeerAuthenticationReconcileLoopMockRecorder) AddMultic varargs := append([]interface{}{ctx, rec}, predicates...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMulticlusterPeerAuthenticationReconciler", reflect.TypeOf((*MockMulticlusterPeerAuthenticationReconcileLoop)(nil).AddMulticlusterPeerAuthenticationReconciler), varargs...) } + +// MockMulticlusterRequestAuthenticationReconciler is a mock of MulticlusterRequestAuthenticationReconciler interface. +type MockMulticlusterRequestAuthenticationReconciler struct { + ctrl *gomock.Controller + recorder *MockMulticlusterRequestAuthenticationReconcilerMockRecorder +} + +// MockMulticlusterRequestAuthenticationReconcilerMockRecorder is the mock recorder for MockMulticlusterRequestAuthenticationReconciler. +type MockMulticlusterRequestAuthenticationReconcilerMockRecorder struct { + mock *MockMulticlusterRequestAuthenticationReconciler +} + +// NewMockMulticlusterRequestAuthenticationReconciler creates a new mock instance. +func NewMockMulticlusterRequestAuthenticationReconciler(ctrl *gomock.Controller) *MockMulticlusterRequestAuthenticationReconciler { + mock := &MockMulticlusterRequestAuthenticationReconciler{ctrl: ctrl} + mock.recorder = &MockMulticlusterRequestAuthenticationReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterRequestAuthenticationReconciler) EXPECT() *MockMulticlusterRequestAuthenticationReconcilerMockRecorder { + return m.recorder +} + +// ReconcileRequestAuthentication mocks base method. +func (m *MockMulticlusterRequestAuthenticationReconciler) ReconcileRequestAuthentication(clusterName string, obj *v1beta1.RequestAuthentication) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileRequestAuthentication", clusterName, obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileRequestAuthentication indicates an expected call of ReconcileRequestAuthentication. +func (mr *MockMulticlusterRequestAuthenticationReconcilerMockRecorder) ReconcileRequestAuthentication(clusterName, obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileRequestAuthentication", reflect.TypeOf((*MockMulticlusterRequestAuthenticationReconciler)(nil).ReconcileRequestAuthentication), clusterName, obj) +} + +// MockMulticlusterRequestAuthenticationDeletionReconciler is a mock of MulticlusterRequestAuthenticationDeletionReconciler interface. +type MockMulticlusterRequestAuthenticationDeletionReconciler struct { + ctrl *gomock.Controller + recorder *MockMulticlusterRequestAuthenticationDeletionReconcilerMockRecorder +} + +// MockMulticlusterRequestAuthenticationDeletionReconcilerMockRecorder is the mock recorder for MockMulticlusterRequestAuthenticationDeletionReconciler. +type MockMulticlusterRequestAuthenticationDeletionReconcilerMockRecorder struct { + mock *MockMulticlusterRequestAuthenticationDeletionReconciler +} + +// NewMockMulticlusterRequestAuthenticationDeletionReconciler creates a new mock instance. +func NewMockMulticlusterRequestAuthenticationDeletionReconciler(ctrl *gomock.Controller) *MockMulticlusterRequestAuthenticationDeletionReconciler { + mock := &MockMulticlusterRequestAuthenticationDeletionReconciler{ctrl: ctrl} + mock.recorder = &MockMulticlusterRequestAuthenticationDeletionReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterRequestAuthenticationDeletionReconciler) EXPECT() *MockMulticlusterRequestAuthenticationDeletionReconcilerMockRecorder { + return m.recorder +} + +// ReconcileRequestAuthenticationDeletion mocks base method. +func (m *MockMulticlusterRequestAuthenticationDeletionReconciler) ReconcileRequestAuthenticationDeletion(clusterName string, req reconcile.Request) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileRequestAuthenticationDeletion", clusterName, req) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReconcileRequestAuthenticationDeletion indicates an expected call of ReconcileRequestAuthenticationDeletion. +func (mr *MockMulticlusterRequestAuthenticationDeletionReconcilerMockRecorder) ReconcileRequestAuthenticationDeletion(clusterName, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileRequestAuthenticationDeletion", reflect.TypeOf((*MockMulticlusterRequestAuthenticationDeletionReconciler)(nil).ReconcileRequestAuthenticationDeletion), clusterName, req) +} + +// MockMulticlusterRequestAuthenticationReconcileLoop is a mock of MulticlusterRequestAuthenticationReconcileLoop interface. +type MockMulticlusterRequestAuthenticationReconcileLoop struct { + ctrl *gomock.Controller + recorder *MockMulticlusterRequestAuthenticationReconcileLoopMockRecorder +} + +// MockMulticlusterRequestAuthenticationReconcileLoopMockRecorder is the mock recorder for MockMulticlusterRequestAuthenticationReconcileLoop. +type MockMulticlusterRequestAuthenticationReconcileLoopMockRecorder struct { + mock *MockMulticlusterRequestAuthenticationReconcileLoop +} + +// NewMockMulticlusterRequestAuthenticationReconcileLoop creates a new mock instance. +func NewMockMulticlusterRequestAuthenticationReconcileLoop(ctrl *gomock.Controller) *MockMulticlusterRequestAuthenticationReconcileLoop { + mock := &MockMulticlusterRequestAuthenticationReconcileLoop{ctrl: ctrl} + mock.recorder = &MockMulticlusterRequestAuthenticationReconcileLoopMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterRequestAuthenticationReconcileLoop) EXPECT() *MockMulticlusterRequestAuthenticationReconcileLoopMockRecorder { + return m.recorder +} + +// AddMulticlusterRequestAuthenticationReconciler mocks base method. +func (m *MockMulticlusterRequestAuthenticationReconcileLoop) AddMulticlusterRequestAuthenticationReconciler(ctx context.Context, rec controller.MulticlusterRequestAuthenticationReconciler, predicates ...predicate.Predicate) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, rec} + for _, a := range predicates { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "AddMulticlusterRequestAuthenticationReconciler", varargs...) +} + +// AddMulticlusterRequestAuthenticationReconciler indicates an expected call of AddMulticlusterRequestAuthenticationReconciler. +func (mr *MockMulticlusterRequestAuthenticationReconcileLoopMockRecorder) AddMulticlusterRequestAuthenticationReconciler(ctx, rec interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, rec}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMulticlusterRequestAuthenticationReconciler", reflect.TypeOf((*MockMulticlusterRequestAuthenticationReconcileLoop)(nil).AddMulticlusterRequestAuthenticationReconciler), varargs...) +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/reconcilers.go b/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/reconcilers.go index f4e6d8b..ff86977 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/reconcilers.go +++ b/pkg/api/istio/security.istio.io/v1beta1/controller/mocks/reconcilers.go @@ -380,3 +380,186 @@ func (mr *MockPeerAuthenticationReconcileLoopMockRecorder) RunPeerAuthentication varargs := append([]interface{}{ctx, rec}, predicates...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunPeerAuthenticationReconciler", reflect.TypeOf((*MockPeerAuthenticationReconcileLoop)(nil).RunPeerAuthenticationReconciler), varargs...) } + +// MockRequestAuthenticationReconciler is a mock of RequestAuthenticationReconciler interface. +type MockRequestAuthenticationReconciler struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationReconcilerMockRecorder +} + +// MockRequestAuthenticationReconcilerMockRecorder is the mock recorder for MockRequestAuthenticationReconciler. +type MockRequestAuthenticationReconcilerMockRecorder struct { + mock *MockRequestAuthenticationReconciler +} + +// NewMockRequestAuthenticationReconciler creates a new mock instance. +func NewMockRequestAuthenticationReconciler(ctrl *gomock.Controller) *MockRequestAuthenticationReconciler { + mock := &MockRequestAuthenticationReconciler{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationReconciler) EXPECT() *MockRequestAuthenticationReconcilerMockRecorder { + return m.recorder +} + +// ReconcileRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationReconciler) ReconcileRequestAuthentication(obj *v1beta1.RequestAuthentication) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileRequestAuthentication", obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileRequestAuthentication indicates an expected call of ReconcileRequestAuthentication. +func (mr *MockRequestAuthenticationReconcilerMockRecorder) ReconcileRequestAuthentication(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationReconciler)(nil).ReconcileRequestAuthentication), obj) +} + +// MockRequestAuthenticationDeletionReconciler is a mock of RequestAuthenticationDeletionReconciler interface. +type MockRequestAuthenticationDeletionReconciler struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationDeletionReconcilerMockRecorder +} + +// MockRequestAuthenticationDeletionReconcilerMockRecorder is the mock recorder for MockRequestAuthenticationDeletionReconciler. +type MockRequestAuthenticationDeletionReconcilerMockRecorder struct { + mock *MockRequestAuthenticationDeletionReconciler +} + +// NewMockRequestAuthenticationDeletionReconciler creates a new mock instance. +func NewMockRequestAuthenticationDeletionReconciler(ctrl *gomock.Controller) *MockRequestAuthenticationDeletionReconciler { + mock := &MockRequestAuthenticationDeletionReconciler{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationDeletionReconcilerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationDeletionReconciler) EXPECT() *MockRequestAuthenticationDeletionReconcilerMockRecorder { + return m.recorder +} + +// ReconcileRequestAuthenticationDeletion mocks base method. +func (m *MockRequestAuthenticationDeletionReconciler) ReconcileRequestAuthenticationDeletion(req reconcile.Request) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileRequestAuthenticationDeletion", req) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReconcileRequestAuthenticationDeletion indicates an expected call of ReconcileRequestAuthenticationDeletion. +func (mr *MockRequestAuthenticationDeletionReconcilerMockRecorder) ReconcileRequestAuthenticationDeletion(req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileRequestAuthenticationDeletion", reflect.TypeOf((*MockRequestAuthenticationDeletionReconciler)(nil).ReconcileRequestAuthenticationDeletion), req) +} + +// MockRequestAuthenticationFinalizer is a mock of RequestAuthenticationFinalizer interface. +type MockRequestAuthenticationFinalizer struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationFinalizerMockRecorder +} + +// MockRequestAuthenticationFinalizerMockRecorder is the mock recorder for MockRequestAuthenticationFinalizer. +type MockRequestAuthenticationFinalizerMockRecorder struct { + mock *MockRequestAuthenticationFinalizer +} + +// NewMockRequestAuthenticationFinalizer creates a new mock instance. +func NewMockRequestAuthenticationFinalizer(ctrl *gomock.Controller) *MockRequestAuthenticationFinalizer { + mock := &MockRequestAuthenticationFinalizer{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationFinalizerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationFinalizer) EXPECT() *MockRequestAuthenticationFinalizerMockRecorder { + return m.recorder +} + +// FinalizeRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationFinalizer) FinalizeRequestAuthentication(obj *v1beta1.RequestAuthentication) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FinalizeRequestAuthentication", obj) + ret0, _ := ret[0].(error) + return ret0 +} + +// FinalizeRequestAuthentication indicates an expected call of FinalizeRequestAuthentication. +func (mr *MockRequestAuthenticationFinalizerMockRecorder) FinalizeRequestAuthentication(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FinalizeRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationFinalizer)(nil).FinalizeRequestAuthentication), obj) +} + +// ReconcileRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationFinalizer) ReconcileRequestAuthentication(obj *v1beta1.RequestAuthentication) (reconcile.Result, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReconcileRequestAuthentication", obj) + ret0, _ := ret[0].(reconcile.Result) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReconcileRequestAuthentication indicates an expected call of ReconcileRequestAuthentication. +func (mr *MockRequestAuthenticationFinalizerMockRecorder) ReconcileRequestAuthentication(obj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReconcileRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationFinalizer)(nil).ReconcileRequestAuthentication), obj) +} + +// RequestAuthenticationFinalizerName mocks base method. +func (m *MockRequestAuthenticationFinalizer) RequestAuthenticationFinalizerName() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RequestAuthenticationFinalizerName") + ret0, _ := ret[0].(string) + return ret0 +} + +// RequestAuthenticationFinalizerName indicates an expected call of RequestAuthenticationFinalizerName. +func (mr *MockRequestAuthenticationFinalizerMockRecorder) RequestAuthenticationFinalizerName() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RequestAuthenticationFinalizerName", reflect.TypeOf((*MockRequestAuthenticationFinalizer)(nil).RequestAuthenticationFinalizerName)) +} + +// MockRequestAuthenticationReconcileLoop is a mock of RequestAuthenticationReconcileLoop interface. +type MockRequestAuthenticationReconcileLoop struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationReconcileLoopMockRecorder +} + +// MockRequestAuthenticationReconcileLoopMockRecorder is the mock recorder for MockRequestAuthenticationReconcileLoop. +type MockRequestAuthenticationReconcileLoopMockRecorder struct { + mock *MockRequestAuthenticationReconcileLoop +} + +// NewMockRequestAuthenticationReconcileLoop creates a new mock instance. +func NewMockRequestAuthenticationReconcileLoop(ctrl *gomock.Controller) *MockRequestAuthenticationReconcileLoop { + mock := &MockRequestAuthenticationReconcileLoop{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationReconcileLoopMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationReconcileLoop) EXPECT() *MockRequestAuthenticationReconcileLoopMockRecorder { + return m.recorder +} + +// RunRequestAuthenticationReconciler mocks base method. +func (m *MockRequestAuthenticationReconcileLoop) RunRequestAuthenticationReconciler(ctx context.Context, rec controller.RequestAuthenticationReconciler, predicates ...predicate.Predicate) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, rec} + for _, a := range predicates { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "RunRequestAuthenticationReconciler", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// RunRequestAuthenticationReconciler indicates an expected call of RunRequestAuthenticationReconciler. +func (mr *MockRequestAuthenticationReconcileLoopMockRecorder) RunRequestAuthenticationReconciler(ctx, rec interface{}, predicates ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, rec}, predicates...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunRequestAuthenticationReconciler", reflect.TypeOf((*MockRequestAuthenticationReconcileLoop)(nil).RunRequestAuthenticationReconciler), varargs...) +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/controller/multicluster_reconcilers.go b/pkg/api/istio/security.istio.io/v1beta1/controller/multicluster_reconcilers.go index d9fd1f9..bb48599 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/controller/multicluster_reconcilers.go +++ b/pkg/api/istio/security.istio.io/v1beta1/controller/multicluster_reconcilers.go @@ -159,3 +159,74 @@ func (g genericPeerAuthenticationMulticlusterReconciler) Reconcile(cluster strin } return g.reconciler.ReconcilePeerAuthentication(cluster, obj) } + +// Reconcile Upsert events for the RequestAuthentication Resource across clusters. +// implemented by the user +type MulticlusterRequestAuthenticationReconciler interface { + ReconcileRequestAuthentication(clusterName string, obj *security_istio_io_v1beta1.RequestAuthentication) (reconcile.Result, error) +} + +// Reconcile deletion events for the RequestAuthentication Resource across clusters. +// Deletion receives a reconcile.Request as we cannot guarantee the last state of the object +// before being deleted. +// implemented by the user +type MulticlusterRequestAuthenticationDeletionReconciler interface { + ReconcileRequestAuthenticationDeletion(clusterName string, req reconcile.Request) error +} + +type MulticlusterRequestAuthenticationReconcilerFuncs struct { + OnReconcileRequestAuthentication func(clusterName string, obj *security_istio_io_v1beta1.RequestAuthentication) (reconcile.Result, error) + OnReconcileRequestAuthenticationDeletion func(clusterName string, req reconcile.Request) error +} + +func (f *MulticlusterRequestAuthenticationReconcilerFuncs) ReconcileRequestAuthentication(clusterName string, obj *security_istio_io_v1beta1.RequestAuthentication) (reconcile.Result, error) { + if f.OnReconcileRequestAuthentication == nil { + return reconcile.Result{}, nil + } + return f.OnReconcileRequestAuthentication(clusterName, obj) +} + +func (f *MulticlusterRequestAuthenticationReconcilerFuncs) ReconcileRequestAuthenticationDeletion(clusterName string, req reconcile.Request) error { + if f.OnReconcileRequestAuthenticationDeletion == nil { + return nil + } + return f.OnReconcileRequestAuthenticationDeletion(clusterName, req) +} + +type MulticlusterRequestAuthenticationReconcileLoop interface { + // AddMulticlusterRequestAuthenticationReconciler adds a MulticlusterRequestAuthenticationReconciler to the MulticlusterRequestAuthenticationReconcileLoop. + AddMulticlusterRequestAuthenticationReconciler(ctx context.Context, rec MulticlusterRequestAuthenticationReconciler, predicates ...predicate.Predicate) +} + +type multiclusterRequestAuthenticationReconcileLoop struct { + loop multicluster.Loop +} + +func (m *multiclusterRequestAuthenticationReconcileLoop) AddMulticlusterRequestAuthenticationReconciler(ctx context.Context, rec MulticlusterRequestAuthenticationReconciler, predicates ...predicate.Predicate) { + genericReconciler := genericRequestAuthenticationMulticlusterReconciler{reconciler: rec} + + m.loop.AddReconciler(ctx, genericReconciler, predicates...) +} + +func NewMulticlusterRequestAuthenticationReconcileLoop(name string, cw multicluster.ClusterWatcher, options reconcile.Options) MulticlusterRequestAuthenticationReconcileLoop { + return &multiclusterRequestAuthenticationReconcileLoop{loop: mc_reconcile.NewLoop(name, cw, &security_istio_io_v1beta1.RequestAuthentication{}, options)} +} + +type genericRequestAuthenticationMulticlusterReconciler struct { + reconciler MulticlusterRequestAuthenticationReconciler +} + +func (g genericRequestAuthenticationMulticlusterReconciler) ReconcileDeletion(cluster string, req reconcile.Request) error { + if deletionReconciler, ok := g.reconciler.(MulticlusterRequestAuthenticationDeletionReconciler); ok { + return deletionReconciler.ReconcileRequestAuthenticationDeletion(cluster, req) + } + return nil +} + +func (g genericRequestAuthenticationMulticlusterReconciler) Reconcile(cluster string, object ezkube.Object) (reconcile.Result, error) { + obj, ok := object.(*security_istio_io_v1beta1.RequestAuthentication) + if !ok { + return reconcile.Result{}, errors.Errorf("internal error: RequestAuthentication handler received event for %T", object) + } + return g.reconciler.ReconcileRequestAuthentication(cluster, obj) +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/controller/reconcilers.go b/pkg/api/istio/security.istio.io/v1beta1/controller/reconcilers.go index a9b9e07..69b7680 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/controller/reconcilers.go +++ b/pkg/api/istio/security.istio.io/v1beta1/controller/reconcilers.go @@ -250,3 +250,120 @@ func (r genericPeerAuthenticationFinalizer) Finalize(object ezkube.Object) error } return r.finalizingReconciler.FinalizePeerAuthentication(obj) } + +// Reconcile Upsert events for the RequestAuthentication Resource. +// implemented by the user +type RequestAuthenticationReconciler interface { + ReconcileRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) (reconcile.Result, error) +} + +// Reconcile deletion events for the RequestAuthentication Resource. +// Deletion receives a reconcile.Request as we cannot guarantee the last state of the object +// before being deleted. +// implemented by the user +type RequestAuthenticationDeletionReconciler interface { + ReconcileRequestAuthenticationDeletion(req reconcile.Request) error +} + +type RequestAuthenticationReconcilerFuncs struct { + OnReconcileRequestAuthentication func(obj *security_istio_io_v1beta1.RequestAuthentication) (reconcile.Result, error) + OnReconcileRequestAuthenticationDeletion func(req reconcile.Request) error +} + +func (f *RequestAuthenticationReconcilerFuncs) ReconcileRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) (reconcile.Result, error) { + if f.OnReconcileRequestAuthentication == nil { + return reconcile.Result{}, nil + } + return f.OnReconcileRequestAuthentication(obj) +} + +func (f *RequestAuthenticationReconcilerFuncs) ReconcileRequestAuthenticationDeletion(req reconcile.Request) error { + if f.OnReconcileRequestAuthenticationDeletion == nil { + return nil + } + return f.OnReconcileRequestAuthenticationDeletion(req) +} + +// Reconcile and finalize the RequestAuthentication Resource +// implemented by the user +type RequestAuthenticationFinalizer interface { + RequestAuthenticationReconciler + + // name of the finalizer used by this handler. + // finalizer names should be unique for a single task + RequestAuthenticationFinalizerName() string + + // finalize the object before it is deleted. + // Watchers created with a finalizing handler will a + FinalizeRequestAuthentication(obj *security_istio_io_v1beta1.RequestAuthentication) error +} + +type RequestAuthenticationReconcileLoop interface { + RunRequestAuthenticationReconciler(ctx context.Context, rec RequestAuthenticationReconciler, predicates ...predicate.Predicate) error +} + +type requestAuthenticationReconcileLoop struct { + loop reconcile.Loop +} + +func NewRequestAuthenticationReconcileLoop(name string, mgr manager.Manager, options reconcile.Options) RequestAuthenticationReconcileLoop { + return &requestAuthenticationReconcileLoop{ + // empty cluster indicates this reconciler is built for the local cluster + loop: reconcile.NewLoop(name, "", mgr, &security_istio_io_v1beta1.RequestAuthentication{}, options), + } +} + +func (c *requestAuthenticationReconcileLoop) RunRequestAuthenticationReconciler(ctx context.Context, reconciler RequestAuthenticationReconciler, predicates ...predicate.Predicate) error { + genericReconciler := genericRequestAuthenticationReconciler{ + reconciler: reconciler, + } + + var reconcilerWrapper reconcile.Reconciler + if finalizingReconciler, ok := reconciler.(RequestAuthenticationFinalizer); ok { + reconcilerWrapper = genericRequestAuthenticationFinalizer{ + genericRequestAuthenticationReconciler: genericReconciler, + finalizingReconciler: finalizingReconciler, + } + } else { + reconcilerWrapper = genericReconciler + } + return c.loop.RunReconciler(ctx, reconcilerWrapper, predicates...) +} + +// genericRequestAuthenticationHandler implements a generic reconcile.Reconciler +type genericRequestAuthenticationReconciler struct { + reconciler RequestAuthenticationReconciler +} + +func (r genericRequestAuthenticationReconciler) Reconcile(object ezkube.Object) (reconcile.Result, error) { + obj, ok := object.(*security_istio_io_v1beta1.RequestAuthentication) + if !ok { + return reconcile.Result{}, errors.Errorf("internal error: RequestAuthentication handler received event for %T", object) + } + return r.reconciler.ReconcileRequestAuthentication(obj) +} + +func (r genericRequestAuthenticationReconciler) ReconcileDeletion(request reconcile.Request) error { + if deletionReconciler, ok := r.reconciler.(RequestAuthenticationDeletionReconciler); ok { + return deletionReconciler.ReconcileRequestAuthenticationDeletion(request) + } + return nil +} + +// genericRequestAuthenticationFinalizer implements a generic reconcile.FinalizingReconciler +type genericRequestAuthenticationFinalizer struct { + genericRequestAuthenticationReconciler + finalizingReconciler RequestAuthenticationFinalizer +} + +func (r genericRequestAuthenticationFinalizer) FinalizerName() string { + return r.finalizingReconciler.RequestAuthenticationFinalizerName() +} + +func (r genericRequestAuthenticationFinalizer) Finalize(object ezkube.Object) error { + obj, ok := object.(*security_istio_io_v1beta1.RequestAuthentication) + if !ok { + return errors.Errorf("internal error: RequestAuthentication handler received event for %T", object) + } + return r.finalizingReconciler.FinalizeRequestAuthentication(obj) +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/mocks/clients.go b/pkg/api/istio/security.istio.io/v1beta1/mocks/clients.go index ec9dabe..a5281d5 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/mocks/clients.go +++ b/pkg/api/istio/security.istio.io/v1beta1/mocks/clients.go @@ -103,6 +103,20 @@ func (mr *MockClientsetMockRecorder) PeerAuthentications() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PeerAuthentications", reflect.TypeOf((*MockClientset)(nil).PeerAuthentications)) } +// RequestAuthentications mocks base method. +func (m *MockClientset) RequestAuthentications() v1beta1.RequestAuthenticationClient { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RequestAuthentications") + ret0, _ := ret[0].(v1beta1.RequestAuthenticationClient) + return ret0 +} + +// RequestAuthentications indicates an expected call of RequestAuthentications. +func (mr *MockClientsetMockRecorder) RequestAuthentications() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RequestAuthentications", reflect.TypeOf((*MockClientset)(nil).RequestAuthentications)) +} + // MockAuthorizationPolicyReader is a mock of AuthorizationPolicyReader interface. type MockAuthorizationPolicyReader struct { ctrl *gomock.Controller @@ -1110,3 +1124,507 @@ func (mr *MockMulticlusterPeerAuthenticationClientMockRecorder) Cluster(cluster mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cluster", reflect.TypeOf((*MockMulticlusterPeerAuthenticationClient)(nil).Cluster), cluster) } + +// MockRequestAuthenticationReader is a mock of RequestAuthenticationReader interface. +type MockRequestAuthenticationReader struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationReaderMockRecorder +} + +// MockRequestAuthenticationReaderMockRecorder is the mock recorder for MockRequestAuthenticationReader. +type MockRequestAuthenticationReaderMockRecorder struct { + mock *MockRequestAuthenticationReader +} + +// NewMockRequestAuthenticationReader creates a new mock instance. +func NewMockRequestAuthenticationReader(ctrl *gomock.Controller) *MockRequestAuthenticationReader { + mock := &MockRequestAuthenticationReader{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationReaderMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationReader) EXPECT() *MockRequestAuthenticationReaderMockRecorder { + return m.recorder +} + +// GetRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationReader) GetRequestAuthentication(ctx context.Context, key client.ObjectKey) (*v1beta10.RequestAuthentication, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetRequestAuthentication", ctx, key) + ret0, _ := ret[0].(*v1beta10.RequestAuthentication) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRequestAuthentication indicates an expected call of GetRequestAuthentication. +func (mr *MockRequestAuthenticationReaderMockRecorder) GetRequestAuthentication(ctx, key interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationReader)(nil).GetRequestAuthentication), ctx, key) +} + +// ListRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationReader) ListRequestAuthentication(ctx context.Context, opts ...client.ListOption) (*v1beta10.RequestAuthenticationList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListRequestAuthentication", varargs...) + ret0, _ := ret[0].(*v1beta10.RequestAuthenticationList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListRequestAuthentication indicates an expected call of ListRequestAuthentication. +func (mr *MockRequestAuthenticationReaderMockRecorder) ListRequestAuthentication(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationReader)(nil).ListRequestAuthentication), varargs...) +} + +// MockRequestAuthenticationWriter is a mock of RequestAuthenticationWriter interface. +type MockRequestAuthenticationWriter struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationWriterMockRecorder +} + +// MockRequestAuthenticationWriterMockRecorder is the mock recorder for MockRequestAuthenticationWriter. +type MockRequestAuthenticationWriterMockRecorder struct { + mock *MockRequestAuthenticationWriter +} + +// NewMockRequestAuthenticationWriter creates a new mock instance. +func NewMockRequestAuthenticationWriter(ctrl *gomock.Controller) *MockRequestAuthenticationWriter { + mock := &MockRequestAuthenticationWriter{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationWriterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationWriter) EXPECT() *MockRequestAuthenticationWriterMockRecorder { + return m.recorder +} + +// CreateRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationWriter) CreateRequestAuthentication(ctx context.Context, obj *v1beta10.RequestAuthentication, opts ...client.CreateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateRequestAuthentication indicates an expected call of CreateRequestAuthentication. +func (mr *MockRequestAuthenticationWriterMockRecorder) CreateRequestAuthentication(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationWriter)(nil).CreateRequestAuthentication), varargs...) +} + +// DeleteAllOfRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationWriter) DeleteAllOfRequestAuthentication(ctx context.Context, opts ...client.DeleteAllOfOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteAllOfRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteAllOfRequestAuthentication indicates an expected call of DeleteAllOfRequestAuthentication. +func (mr *MockRequestAuthenticationWriterMockRecorder) DeleteAllOfRequestAuthentication(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllOfRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationWriter)(nil).DeleteAllOfRequestAuthentication), varargs...) +} + +// DeleteRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationWriter) DeleteRequestAuthentication(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, key} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteRequestAuthentication indicates an expected call of DeleteRequestAuthentication. +func (mr *MockRequestAuthenticationWriterMockRecorder) DeleteRequestAuthentication(ctx, key interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, key}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationWriter)(nil).DeleteRequestAuthentication), varargs...) +} + +// PatchRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationWriter) PatchRequestAuthentication(ctx context.Context, obj *v1beta10.RequestAuthentication, patch client.Patch, opts ...client.PatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchRequestAuthentication indicates an expected call of PatchRequestAuthentication. +func (mr *MockRequestAuthenticationWriterMockRecorder) PatchRequestAuthentication(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationWriter)(nil).PatchRequestAuthentication), varargs...) +} + +// UpdateRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationWriter) UpdateRequestAuthentication(ctx context.Context, obj *v1beta10.RequestAuthentication, opts ...client.UpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRequestAuthentication indicates an expected call of UpdateRequestAuthentication. +func (mr *MockRequestAuthenticationWriterMockRecorder) UpdateRequestAuthentication(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationWriter)(nil).UpdateRequestAuthentication), varargs...) +} + +// UpsertRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationWriter) UpsertRequestAuthentication(ctx context.Context, obj *v1beta10.RequestAuthentication, transitionFuncs ...v1beta1.RequestAuthenticationTransitionFunction) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range transitionFuncs { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpsertRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpsertRequestAuthentication indicates an expected call of UpsertRequestAuthentication. +func (mr *MockRequestAuthenticationWriterMockRecorder) UpsertRequestAuthentication(ctx, obj interface{}, transitionFuncs ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, transitionFuncs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationWriter)(nil).UpsertRequestAuthentication), varargs...) +} + +// MockRequestAuthenticationStatusWriter is a mock of RequestAuthenticationStatusWriter interface. +type MockRequestAuthenticationStatusWriter struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationStatusWriterMockRecorder +} + +// MockRequestAuthenticationStatusWriterMockRecorder is the mock recorder for MockRequestAuthenticationStatusWriter. +type MockRequestAuthenticationStatusWriterMockRecorder struct { + mock *MockRequestAuthenticationStatusWriter +} + +// NewMockRequestAuthenticationStatusWriter creates a new mock instance. +func NewMockRequestAuthenticationStatusWriter(ctrl *gomock.Controller) *MockRequestAuthenticationStatusWriter { + mock := &MockRequestAuthenticationStatusWriter{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationStatusWriterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationStatusWriter) EXPECT() *MockRequestAuthenticationStatusWriterMockRecorder { + return m.recorder +} + +// PatchRequestAuthenticationStatus mocks base method. +func (m *MockRequestAuthenticationStatusWriter) PatchRequestAuthenticationStatus(ctx context.Context, obj *v1beta10.RequestAuthentication, patch client.Patch, opts ...client.SubResourcePatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchRequestAuthenticationStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchRequestAuthenticationStatus indicates an expected call of PatchRequestAuthenticationStatus. +func (mr *MockRequestAuthenticationStatusWriterMockRecorder) PatchRequestAuthenticationStatus(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchRequestAuthenticationStatus", reflect.TypeOf((*MockRequestAuthenticationStatusWriter)(nil).PatchRequestAuthenticationStatus), varargs...) +} + +// UpdateRequestAuthenticationStatus mocks base method. +func (m *MockRequestAuthenticationStatusWriter) UpdateRequestAuthenticationStatus(ctx context.Context, obj *v1beta10.RequestAuthentication, opts ...client.SubResourceUpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateRequestAuthenticationStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRequestAuthenticationStatus indicates an expected call of UpdateRequestAuthenticationStatus. +func (mr *MockRequestAuthenticationStatusWriterMockRecorder) UpdateRequestAuthenticationStatus(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRequestAuthenticationStatus", reflect.TypeOf((*MockRequestAuthenticationStatusWriter)(nil).UpdateRequestAuthenticationStatus), varargs...) +} + +// MockRequestAuthenticationClient is a mock of RequestAuthenticationClient interface. +type MockRequestAuthenticationClient struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationClientMockRecorder +} + +// MockRequestAuthenticationClientMockRecorder is the mock recorder for MockRequestAuthenticationClient. +type MockRequestAuthenticationClientMockRecorder struct { + mock *MockRequestAuthenticationClient +} + +// NewMockRequestAuthenticationClient creates a new mock instance. +func NewMockRequestAuthenticationClient(ctrl *gomock.Controller) *MockRequestAuthenticationClient { + mock := &MockRequestAuthenticationClient{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationClient) EXPECT() *MockRequestAuthenticationClientMockRecorder { + return m.recorder +} + +// CreateRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationClient) CreateRequestAuthentication(ctx context.Context, obj *v1beta10.RequestAuthentication, opts ...client.CreateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateRequestAuthentication indicates an expected call of CreateRequestAuthentication. +func (mr *MockRequestAuthenticationClientMockRecorder) CreateRequestAuthentication(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).CreateRequestAuthentication), varargs...) +} + +// DeleteAllOfRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationClient) DeleteAllOfRequestAuthentication(ctx context.Context, opts ...client.DeleteAllOfOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteAllOfRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteAllOfRequestAuthentication indicates an expected call of DeleteAllOfRequestAuthentication. +func (mr *MockRequestAuthenticationClientMockRecorder) DeleteAllOfRequestAuthentication(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllOfRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).DeleteAllOfRequestAuthentication), varargs...) +} + +// DeleteRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationClient) DeleteRequestAuthentication(ctx context.Context, key client.ObjectKey, opts ...client.DeleteOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, key} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteRequestAuthentication indicates an expected call of DeleteRequestAuthentication. +func (mr *MockRequestAuthenticationClientMockRecorder) DeleteRequestAuthentication(ctx, key interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, key}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).DeleteRequestAuthentication), varargs...) +} + +// GetRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationClient) GetRequestAuthentication(ctx context.Context, key client.ObjectKey) (*v1beta10.RequestAuthentication, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetRequestAuthentication", ctx, key) + ret0, _ := ret[0].(*v1beta10.RequestAuthentication) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRequestAuthentication indicates an expected call of GetRequestAuthentication. +func (mr *MockRequestAuthenticationClientMockRecorder) GetRequestAuthentication(ctx, key interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).GetRequestAuthentication), ctx, key) +} + +// ListRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationClient) ListRequestAuthentication(ctx context.Context, opts ...client.ListOption) (*v1beta10.RequestAuthenticationList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListRequestAuthentication", varargs...) + ret0, _ := ret[0].(*v1beta10.RequestAuthenticationList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListRequestAuthentication indicates an expected call of ListRequestAuthentication. +func (mr *MockRequestAuthenticationClientMockRecorder) ListRequestAuthentication(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).ListRequestAuthentication), varargs...) +} + +// PatchRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationClient) PatchRequestAuthentication(ctx context.Context, obj *v1beta10.RequestAuthentication, patch client.Patch, opts ...client.PatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchRequestAuthentication indicates an expected call of PatchRequestAuthentication. +func (mr *MockRequestAuthenticationClientMockRecorder) PatchRequestAuthentication(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).PatchRequestAuthentication), varargs...) +} + +// PatchRequestAuthenticationStatus mocks base method. +func (m *MockRequestAuthenticationClient) PatchRequestAuthenticationStatus(ctx context.Context, obj *v1beta10.RequestAuthentication, patch client.Patch, opts ...client.SubResourcePatchOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj, patch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PatchRequestAuthenticationStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PatchRequestAuthenticationStatus indicates an expected call of PatchRequestAuthenticationStatus. +func (mr *MockRequestAuthenticationClientMockRecorder) PatchRequestAuthenticationStatus(ctx, obj, patch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj, patch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchRequestAuthenticationStatus", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).PatchRequestAuthenticationStatus), varargs...) +} + +// UpdateRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationClient) UpdateRequestAuthentication(ctx context.Context, obj *v1beta10.RequestAuthentication, opts ...client.UpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRequestAuthentication indicates an expected call of UpdateRequestAuthentication. +func (mr *MockRequestAuthenticationClientMockRecorder) UpdateRequestAuthentication(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).UpdateRequestAuthentication), varargs...) +} + +// UpdateRequestAuthenticationStatus mocks base method. +func (m *MockRequestAuthenticationClient) UpdateRequestAuthenticationStatus(ctx context.Context, obj *v1beta10.RequestAuthentication, opts ...client.SubResourceUpdateOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateRequestAuthenticationStatus", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRequestAuthenticationStatus indicates an expected call of UpdateRequestAuthenticationStatus. +func (mr *MockRequestAuthenticationClientMockRecorder) UpdateRequestAuthenticationStatus(ctx, obj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRequestAuthenticationStatus", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).UpdateRequestAuthenticationStatus), varargs...) +} + +// UpsertRequestAuthentication mocks base method. +func (m *MockRequestAuthenticationClient) UpsertRequestAuthentication(ctx context.Context, obj *v1beta10.RequestAuthentication, transitionFuncs ...v1beta1.RequestAuthenticationTransitionFunction) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, obj} + for _, a := range transitionFuncs { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpsertRequestAuthentication", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpsertRequestAuthentication indicates an expected call of UpsertRequestAuthentication. +func (mr *MockRequestAuthenticationClientMockRecorder) UpsertRequestAuthentication(ctx, obj interface{}, transitionFuncs ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, obj}, transitionFuncs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertRequestAuthentication", reflect.TypeOf((*MockRequestAuthenticationClient)(nil).UpsertRequestAuthentication), varargs...) +} + +// MockMulticlusterRequestAuthenticationClient is a mock of MulticlusterRequestAuthenticationClient interface. +type MockMulticlusterRequestAuthenticationClient struct { + ctrl *gomock.Controller + recorder *MockMulticlusterRequestAuthenticationClientMockRecorder +} + +// MockMulticlusterRequestAuthenticationClientMockRecorder is the mock recorder for MockMulticlusterRequestAuthenticationClient. +type MockMulticlusterRequestAuthenticationClientMockRecorder struct { + mock *MockMulticlusterRequestAuthenticationClient +} + +// NewMockMulticlusterRequestAuthenticationClient creates a new mock instance. +func NewMockMulticlusterRequestAuthenticationClient(ctrl *gomock.Controller) *MockMulticlusterRequestAuthenticationClient { + mock := &MockMulticlusterRequestAuthenticationClient{ctrl: ctrl} + mock.recorder = &MockMulticlusterRequestAuthenticationClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMulticlusterRequestAuthenticationClient) EXPECT() *MockMulticlusterRequestAuthenticationClientMockRecorder { + return m.recorder +} + +// Cluster mocks base method. +func (m *MockMulticlusterRequestAuthenticationClient) Cluster(cluster string) (v1beta1.RequestAuthenticationClient, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Cluster", cluster) + ret0, _ := ret[0].(v1beta1.RequestAuthenticationClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Cluster indicates an expected call of Cluster. +func (mr *MockMulticlusterRequestAuthenticationClientMockRecorder) Cluster(cluster interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cluster", reflect.TypeOf((*MockMulticlusterRequestAuthenticationClient)(nil).Cluster), cluster) +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/providers/client_providers.go b/pkg/api/istio/security.istio.io/v1beta1/providers/client_providers.go index e12c2e8..f7195fe 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/providers/client_providers.go +++ b/pkg/api/istio/security.istio.io/v1beta1/providers/client_providers.go @@ -72,3 +72,31 @@ func PeerAuthenticationClientFromConfigFactoryProvider() PeerAuthenticationClien return clients.PeerAuthentications(), nil } } + +// Provider for RequestAuthenticationClient from Clientset +func RequestAuthenticationClientFromClientsetProvider(clients security_istio_io_v1beta1.Clientset) security_istio_io_v1beta1.RequestAuthenticationClient { + return clients.RequestAuthentications() +} + +// Provider for RequestAuthentication Client from Client +func RequestAuthenticationClientProvider(client client.Client) security_istio_io_v1beta1.RequestAuthenticationClient { + return security_istio_io_v1beta1.NewRequestAuthenticationClient(client) +} + +type RequestAuthenticationClientFactory func(client client.Client) security_istio_io_v1beta1.RequestAuthenticationClient + +func RequestAuthenticationClientFactoryProvider() RequestAuthenticationClientFactory { + return RequestAuthenticationClientProvider +} + +type RequestAuthenticationClientFromConfigFactory func(cfg *rest.Config) (security_istio_io_v1beta1.RequestAuthenticationClient, error) + +func RequestAuthenticationClientFromConfigFactoryProvider() RequestAuthenticationClientFromConfigFactory { + return func(cfg *rest.Config) (security_istio_io_v1beta1.RequestAuthenticationClient, error) { + clients, err := security_istio_io_v1beta1.NewClientsetFromConfig(cfg) + if err != nil { + return nil, err + } + return clients.RequestAuthentications(), nil + } +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/sets/mocks/sets.go b/pkg/api/istio/security.istio.io/v1beta1/sets/mocks/sets.go index bb5b2b8..8e4b465 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/sets/mocks/sets.go +++ b/pkg/api/istio/security.istio.io/v1beta1/sets/mocks/sets.go @@ -526,3 +526,259 @@ func (mr *MockPeerAuthenticationSetMockRecorder) UnsortedList(filterResource ... mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnsortedList", reflect.TypeOf((*MockPeerAuthenticationSet)(nil).UnsortedList), filterResource...) } + +// MockRequestAuthenticationSet is a mock of RequestAuthenticationSet interface. +type MockRequestAuthenticationSet struct { + ctrl *gomock.Controller + recorder *MockRequestAuthenticationSetMockRecorder +} + +// MockRequestAuthenticationSetMockRecorder is the mock recorder for MockRequestAuthenticationSet. +type MockRequestAuthenticationSetMockRecorder struct { + mock *MockRequestAuthenticationSet +} + +// NewMockRequestAuthenticationSet creates a new mock instance. +func NewMockRequestAuthenticationSet(ctrl *gomock.Controller) *MockRequestAuthenticationSet { + mock := &MockRequestAuthenticationSet{ctrl: ctrl} + mock.recorder = &MockRequestAuthenticationSetMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRequestAuthenticationSet) EXPECT() *MockRequestAuthenticationSetMockRecorder { + return m.recorder +} + +// Clone mocks base method. +func (m *MockRequestAuthenticationSet) Clone() v1beta1sets.RequestAuthenticationSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Clone") + ret0, _ := ret[0].(v1beta1sets.RequestAuthenticationSet) + return ret0 +} + +// Clone indicates an expected call of Clone. +func (mr *MockRequestAuthenticationSetMockRecorder) Clone() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clone", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Clone)) +} + +// Delete mocks base method. +func (m *MockRequestAuthenticationSet) Delete(requestAuthentication ezkube.ResourceId) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Delete", requestAuthentication) +} + +// Delete indicates an expected call of Delete. +func (mr *MockRequestAuthenticationSetMockRecorder) Delete(requestAuthentication interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Delete), requestAuthentication) +} + +// Delta mocks base method. +func (m *MockRequestAuthenticationSet) Delta(newSet v1beta1sets.RequestAuthenticationSet) sets.ResourceDelta { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delta", newSet) + ret0, _ := ret[0].(sets.ResourceDelta) + return ret0 +} + +// Delta indicates an expected call of Delta. +func (mr *MockRequestAuthenticationSetMockRecorder) Delta(newSet interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delta", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Delta), newSet) +} + +// Difference mocks base method. +func (m *MockRequestAuthenticationSet) Difference(set v1beta1sets.RequestAuthenticationSet) v1beta1sets.RequestAuthenticationSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Difference", set) + ret0, _ := ret[0].(v1beta1sets.RequestAuthenticationSet) + return ret0 +} + +// Difference indicates an expected call of Difference. +func (mr *MockRequestAuthenticationSetMockRecorder) Difference(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Difference", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Difference), set) +} + +// Equal mocks base method. +func (m *MockRequestAuthenticationSet) Equal(requestAuthenticationSet v1beta1sets.RequestAuthenticationSet) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Equal", requestAuthenticationSet) + ret0, _ := ret[0].(bool) + return ret0 +} + +// Equal indicates an expected call of Equal. +func (mr *MockRequestAuthenticationSetMockRecorder) Equal(requestAuthenticationSet interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Equal", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Equal), requestAuthenticationSet) +} + +// Find mocks base method. +func (m *MockRequestAuthenticationSet) Find(id ezkube.ResourceId) (*v1beta1.RequestAuthentication, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Find", id) + ret0, _ := ret[0].(*v1beta1.RequestAuthentication) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Find indicates an expected call of Find. +func (mr *MockRequestAuthenticationSetMockRecorder) Find(id interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Find), id) +} + +// Generic mocks base method. +func (m *MockRequestAuthenticationSet) Generic() sets.ResourceSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Generic") + ret0, _ := ret[0].(sets.ResourceSet) + return ret0 +} + +// Generic indicates an expected call of Generic. +func (mr *MockRequestAuthenticationSetMockRecorder) Generic() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Generic", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Generic)) +} + +// Has mocks base method. +func (m *MockRequestAuthenticationSet) Has(requestAuthentication ezkube.ResourceId) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Has", requestAuthentication) + ret0, _ := ret[0].(bool) + return ret0 +} + +// Has indicates an expected call of Has. +func (mr *MockRequestAuthenticationSetMockRecorder) Has(requestAuthentication interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Has", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Has), requestAuthentication) +} + +// Insert mocks base method. +func (m *MockRequestAuthenticationSet) Insert(requestAuthentication ...*v1beta1.RequestAuthentication) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range requestAuthentication { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Insert", varargs...) +} + +// Insert indicates an expected call of Insert. +func (mr *MockRequestAuthenticationSetMockRecorder) Insert(requestAuthentication ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Insert), requestAuthentication...) +} + +// Intersection mocks base method. +func (m *MockRequestAuthenticationSet) Intersection(set v1beta1sets.RequestAuthenticationSet) v1beta1sets.RequestAuthenticationSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Intersection", set) + ret0, _ := ret[0].(v1beta1sets.RequestAuthenticationSet) + return ret0 +} + +// Intersection indicates an expected call of Intersection. +func (mr *MockRequestAuthenticationSetMockRecorder) Intersection(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Intersection", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Intersection), set) +} + +// Keys mocks base method. +func (m *MockRequestAuthenticationSet) Keys() sets0.String { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Keys") + ret0, _ := ret[0].(sets0.String) + return ret0 +} + +// Keys indicates an expected call of Keys. +func (mr *MockRequestAuthenticationSetMockRecorder) Keys() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Keys", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Keys)) +} + +// Length mocks base method. +func (m *MockRequestAuthenticationSet) Length() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Length") + ret0, _ := ret[0].(int) + return ret0 +} + +// Length indicates an expected call of Length. +func (mr *MockRequestAuthenticationSetMockRecorder) Length() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Length", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Length)) +} + +// List mocks base method. +func (m *MockRequestAuthenticationSet) List(filterResource ...func(*v1beta1.RequestAuthentication) bool) []*v1beta1.RequestAuthentication { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range filterResource { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].([]*v1beta1.RequestAuthentication) + return ret0 +} + +// List indicates an expected call of List. +func (mr *MockRequestAuthenticationSetMockRecorder) List(filterResource ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).List), filterResource...) +} + +// Map mocks base method. +func (m *MockRequestAuthenticationSet) Map() map[string]*v1beta1.RequestAuthentication { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Map") + ret0, _ := ret[0].(map[string]*v1beta1.RequestAuthentication) + return ret0 +} + +// Map indicates an expected call of Map. +func (mr *MockRequestAuthenticationSetMockRecorder) Map() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Map", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Map)) +} + +// Union mocks base method. +func (m *MockRequestAuthenticationSet) Union(set v1beta1sets.RequestAuthenticationSet) v1beta1sets.RequestAuthenticationSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Union", set) + ret0, _ := ret[0].(v1beta1sets.RequestAuthenticationSet) + return ret0 +} + +// Union indicates an expected call of Union. +func (mr *MockRequestAuthenticationSetMockRecorder) Union(set interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Union", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).Union), set) +} + +// UnsortedList mocks base method. +func (m *MockRequestAuthenticationSet) UnsortedList(filterResource ...func(*v1beta1.RequestAuthentication) bool) []*v1beta1.RequestAuthentication { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range filterResource { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UnsortedList", varargs...) + ret0, _ := ret[0].([]*v1beta1.RequestAuthentication) + return ret0 +} + +// UnsortedList indicates an expected call of UnsortedList. +func (mr *MockRequestAuthenticationSetMockRecorder) UnsortedList(filterResource ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnsortedList", reflect.TypeOf((*MockRequestAuthenticationSet)(nil).UnsortedList), filterResource...) +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/sets/sets.go b/pkg/api/istio/security.istio.io/v1beta1/sets/sets.go index 098aa33..0e67b25 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/sets/sets.go +++ b/pkg/api/istio/security.istio.io/v1beta1/sets/sets.go @@ -458,3 +458,226 @@ func (s *peerAuthenticationSet) Clone() PeerAuthenticationSet { } return &peerAuthenticationSet{set: sksets.NewResourceSet(s.Generic().Clone().List()...)} } + +type RequestAuthenticationSet interface { + // Get the set stored keys + Keys() sets.String + // List of resources stored in the set. Pass an optional filter function to filter on the list. + // The filter function should return false to keep the resource, true to drop it. + List(filterResource ...func(*security_istio_io_v1beta1.RequestAuthentication) bool) []*security_istio_io_v1beta1.RequestAuthentication + // Unsorted list of resources stored in the set. Pass an optional filter function to filter on the list. + // The filter function should return false to keep the resource, true to drop it. + UnsortedList(filterResource ...func(*security_istio_io_v1beta1.RequestAuthentication) bool) []*security_istio_io_v1beta1.RequestAuthentication + // Return the Set as a map of key to resource. + Map() map[string]*security_istio_io_v1beta1.RequestAuthentication + // Insert a resource into the set. + Insert(requestAuthentication ...*security_istio_io_v1beta1.RequestAuthentication) + // Compare the equality of the keys in two sets (not the resources themselves) + Equal(requestAuthenticationSet RequestAuthenticationSet) bool + // Check if the set contains a key matching the resource (not the resource itself) + Has(requestAuthentication ezkube.ResourceId) bool + // Delete the key matching the resource + Delete(requestAuthentication ezkube.ResourceId) + // Return the union with the provided set + Union(set RequestAuthenticationSet) RequestAuthenticationSet + // Return the difference with the provided set + Difference(set RequestAuthenticationSet) RequestAuthenticationSet + // Return the intersection with the provided set + Intersection(set RequestAuthenticationSet) RequestAuthenticationSet + // Find the resource with the given ID + Find(id ezkube.ResourceId) (*security_istio_io_v1beta1.RequestAuthentication, error) + // Get the length of the set + Length() int + // returns the generic implementation of the set + Generic() sksets.ResourceSet + // returns the delta between this and and another RequestAuthenticationSet + Delta(newSet RequestAuthenticationSet) sksets.ResourceDelta + // Create a deep copy of the current RequestAuthenticationSet + Clone() RequestAuthenticationSet +} + +func makeGenericRequestAuthenticationSet(requestAuthenticationList []*security_istio_io_v1beta1.RequestAuthentication) sksets.ResourceSet { + var genericResources []ezkube.ResourceId + for _, obj := range requestAuthenticationList { + genericResources = append(genericResources, obj) + } + return sksets.NewResourceSet(genericResources...) +} + +type requestAuthenticationSet struct { + set sksets.ResourceSet +} + +func NewRequestAuthenticationSet(requestAuthenticationList ...*security_istio_io_v1beta1.RequestAuthentication) RequestAuthenticationSet { + return &requestAuthenticationSet{set: makeGenericRequestAuthenticationSet(requestAuthenticationList)} +} + +func NewRequestAuthenticationSetFromList(requestAuthenticationList *security_istio_io_v1beta1.RequestAuthenticationList) RequestAuthenticationSet { + list := make([]*security_istio_io_v1beta1.RequestAuthentication, 0, len(requestAuthenticationList.Items)) + for idx := range requestAuthenticationList.Items { + list = append(list, requestAuthenticationList.Items[idx]) + } + return &requestAuthenticationSet{set: makeGenericRequestAuthenticationSet(list)} +} + +func (s *requestAuthenticationSet) Keys() sets.String { + if s == nil { + return sets.String{} + } + return s.Generic().Keys() +} + +func (s *requestAuthenticationSet) List(filterResource ...func(*security_istio_io_v1beta1.RequestAuthentication) bool) []*security_istio_io_v1beta1.RequestAuthentication { + if s == nil { + return nil + } + var genericFilters []func(ezkube.ResourceId) bool + for _, filter := range filterResource { + filter := filter + genericFilters = append(genericFilters, func(obj ezkube.ResourceId) bool { + return filter(obj.(*security_istio_io_v1beta1.RequestAuthentication)) + }) + } + + objs := s.Generic().List(genericFilters...) + requestAuthenticationList := make([]*security_istio_io_v1beta1.RequestAuthentication, 0, len(objs)) + for _, obj := range objs { + requestAuthenticationList = append(requestAuthenticationList, obj.(*security_istio_io_v1beta1.RequestAuthentication)) + } + return requestAuthenticationList +} + +func (s *requestAuthenticationSet) UnsortedList(filterResource ...func(*security_istio_io_v1beta1.RequestAuthentication) bool) []*security_istio_io_v1beta1.RequestAuthentication { + if s == nil { + return nil + } + var genericFilters []func(ezkube.ResourceId) bool + for _, filter := range filterResource { + filter := filter + genericFilters = append(genericFilters, func(obj ezkube.ResourceId) bool { + return filter(obj.(*security_istio_io_v1beta1.RequestAuthentication)) + }) + } + + var requestAuthenticationList []*security_istio_io_v1beta1.RequestAuthentication + for _, obj := range s.Generic().UnsortedList(genericFilters...) { + requestAuthenticationList = append(requestAuthenticationList, obj.(*security_istio_io_v1beta1.RequestAuthentication)) + } + return requestAuthenticationList +} + +func (s *requestAuthenticationSet) Map() map[string]*security_istio_io_v1beta1.RequestAuthentication { + if s == nil { + return nil + } + + newMap := map[string]*security_istio_io_v1beta1.RequestAuthentication{} + for k, v := range s.Generic().Map() { + newMap[k] = v.(*security_istio_io_v1beta1.RequestAuthentication) + } + return newMap +} + +func (s *requestAuthenticationSet) Insert( + requestAuthenticationList ...*security_istio_io_v1beta1.RequestAuthentication, +) { + if s == nil { + panic("cannot insert into nil set") + } + + for _, obj := range requestAuthenticationList { + s.Generic().Insert(obj) + } +} + +func (s *requestAuthenticationSet) Has(requestAuthentication ezkube.ResourceId) bool { + if s == nil { + return false + } + return s.Generic().Has(requestAuthentication) +} + +func (s *requestAuthenticationSet) Equal( + requestAuthenticationSet RequestAuthenticationSet, +) bool { + if s == nil { + return requestAuthenticationSet == nil + } + return s.Generic().Equal(requestAuthenticationSet.Generic()) +} + +func (s *requestAuthenticationSet) Delete(RequestAuthentication ezkube.ResourceId) { + if s == nil { + return + } + s.Generic().Delete(RequestAuthentication) +} + +func (s *requestAuthenticationSet) Union(set RequestAuthenticationSet) RequestAuthenticationSet { + if s == nil { + return set + } + return NewRequestAuthenticationSet(append(s.List(), set.List()...)...) +} + +func (s *requestAuthenticationSet) Difference(set RequestAuthenticationSet) RequestAuthenticationSet { + if s == nil { + return set + } + newSet := s.Generic().Difference(set.Generic()) + return &requestAuthenticationSet{set: newSet} +} + +func (s *requestAuthenticationSet) Intersection(set RequestAuthenticationSet) RequestAuthenticationSet { + if s == nil { + return nil + } + newSet := s.Generic().Intersection(set.Generic()) + var requestAuthenticationList []*security_istio_io_v1beta1.RequestAuthentication + for _, obj := range newSet.List() { + requestAuthenticationList = append(requestAuthenticationList, obj.(*security_istio_io_v1beta1.RequestAuthentication)) + } + return NewRequestAuthenticationSet(requestAuthenticationList...) +} + +func (s *requestAuthenticationSet) Find(id ezkube.ResourceId) (*security_istio_io_v1beta1.RequestAuthentication, error) { + if s == nil { + return nil, eris.Errorf("empty set, cannot find RequestAuthentication %v", sksets.Key(id)) + } + obj, err := s.Generic().Find(&security_istio_io_v1beta1.RequestAuthentication{}, id) + if err != nil { + return nil, err + } + + return obj.(*security_istio_io_v1beta1.RequestAuthentication), nil +} + +func (s *requestAuthenticationSet) Length() int { + if s == nil { + return 0 + } + return s.Generic().Length() +} + +func (s *requestAuthenticationSet) Generic() sksets.ResourceSet { + if s == nil { + return nil + } + return s.set +} + +func (s *requestAuthenticationSet) Delta(newSet RequestAuthenticationSet) sksets.ResourceDelta { + if s == nil { + return sksets.ResourceDelta{ + Inserted: newSet.Generic(), + } + } + return s.Generic().Delta(newSet.Generic()) +} + +func (s *requestAuthenticationSet) Clone() RequestAuthenticationSet { + if s == nil { + return nil + } + return &requestAuthenticationSet{set: sksets.NewResourceSet(s.Generic().Clone().List()...)} +} diff --git a/pkg/api/istio/security.istio.io/v1beta1/type_helpers.go b/pkg/api/istio/security.istio.io/v1beta1/type_helpers.go index fc96c98..cf8ebb0 100644 --- a/pkg/api/istio/security.istio.io/v1beta1/type_helpers.go +++ b/pkg/api/istio/security.istio.io/v1beta1/type_helpers.go @@ -12,3 +12,6 @@ type AuthorizationPolicySlice []*AuthorizationPolicy // PeerAuthenticationSlice represents a slice of *PeerAuthentication type PeerAuthenticationSlice []*PeerAuthentication + +// RequestAuthenticationSlice represents a slice of *RequestAuthentication +type RequestAuthenticationSlice []*RequestAuthentication