Skip to content

Commit

Permalink
corrected breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
facchettos committed Apr 9, 2024
1 parent c0244ed commit cfd5933
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
5 changes: 2 additions & 3 deletions e2e/test_plugin/syncers/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ func (d DummyInterceptor) Name() string {
return "testinterceptor"
}

func (d DummyInterceptor) InterceptedRequests() []v2.Interceptor {
return []v2.Interceptor{
func (d DummyInterceptor) InterceptionRules() []v2.InterceptorRule {
return []v2.InterceptorRule{
{
HandlerName: "testhandler",
APIGroups: []string{"*"},
Resources: []string{"pods"},
ResourceNames: []string{"*"},
Expand Down
4 changes: 2 additions & 2 deletions plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type manager struct {
syncers []syncertypes.Base

interceptorsHandlers map[string]http.Handler
interceptors map[string][]Interceptor
interceptors []Interceptor
interceptorsPort int

proConfig v2.InitConfigPro
Expand Down Expand Up @@ -202,7 +202,7 @@ func (m *manager) Register(syncer syncertypes.Base) error {
return fmt.Errorf("could not add the interceptor %s because its name is already in use", int.Name())
}
m.interceptorsHandlers[int.Name()] = int
m.interceptors[int.Name()] = append(m.interceptors[int.Name()], int)
m.interceptors = append(m.interceptors, int)
} else {
m.syncers = append(m.syncers, syncer)
}
Expand Down
13 changes: 7 additions & 6 deletions plugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type server interface {
Serve()

// SetReady signals the plugin server the plugin is ready to start
SetReady(hooks map[types.VersionKindType][]ClientHook, interceptors map[string][]Interceptor, port int)
SetReady(hooks map[types.VersionKindType][]ClientHook, interceptors []Interceptor, port int)

// Initialized retrieves the initialize request
Initialized() <-chan *pluginv2.Initialize_Request
Expand All @@ -44,7 +44,7 @@ type pluginServer struct {
pluginv2.UnimplementedPluginServer

hooks map[types.VersionKindType][]ClientHook
interceptors map[string][]Interceptor
interceptors []Interceptor
interceptorsPort int

initialized chan *pluginv2.Initialize_Request
Expand Down Expand Up @@ -90,7 +90,7 @@ func (p *pluginServer) IsLeader() <-chan struct{} {
return p.isLeader
}

func (p *pluginServer) SetReady(hooks map[types.VersionKindType][]ClientHook, interceptors map[string][]Interceptor, port int) {
func (p *pluginServer) SetReady(hooks map[types.VersionKindType][]ClientHook, interceptors []Interceptor, port int) {
p.hooks = hooks
p.interceptors = interceptors
p.interceptorsPort = port
Expand Down Expand Up @@ -271,12 +271,13 @@ func (p *pluginServer) getClientHooks() ([]*v2.ClientHook, error) {
return registeredHooks, nil
}

func (p *pluginServer) getInterceptorConfig() map[string]v2.Interceptor {
func (p *pluginServer) getInterceptorConfig() map[string][]v2.InterceptorRule {
res := make(map[string][]v2.InterceptorRule)
for _, interceptor := range p.interceptors {
interceptorConfig.Interceptors = append(interceptorConfig.Interceptors, interceptor.InterceptedRequests()...)
res[interceptor.Name()] = interceptor.InterceptionRules()
}

return interceptorConfig
return res
}

var _ plugin.Plugin = &pluginServer{}
Expand Down
4 changes: 2 additions & 2 deletions plugin/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ type Interceptor interface {
// Handler is the handler that will handle the requests delegated by the syncer
http.Handler

// InterceptedRequests returns an rbac style struct which defines what to intercept
InterceptedRequests() []v2.Interceptor
// InterceptionRules returns an rbac style struct which defines what to intercept
InterceptionRules() []v2.InterceptorRule
}

type MutateCreateVirtual interface {
Expand Down

0 comments on commit cfd5933

Please sign in to comment.