forked from joeholley/supergloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_interface.go
52 lines (42 loc) · 1.08 KB
/
plugin_interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package plugins
import (
"context"
"github.com/linkerd/linkerd2/controller/gen/apis/serviceprofile/v1alpha1"
gloov1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
v1 "github.com/solo-io/supergloo/pkg/api/v1"
"k8s.io/client-go/kubernetes"
)
type InitParams struct {
Ctx context.Context
}
type Plugin interface {
// init on first loop, flush cache
Init(params InitParams) error
}
type Params struct {
Ctx context.Context
Upstreams gloov1.UpstreamList
}
type RoutingPlugin interface {
Plugin
ProcessRoutes(params Params, in v1.RoutingRuleSpec, out []*v1alpha1.RouteSpec) error
}
type ServiceProfilePlugin interface {
Plugin
ProcessServiceProfile(params Params, in v1.RoutingRuleSpec, out *v1alpha1.ServiceProfileSpec) error
}
type registry struct {
plugins []Plugin
}
var globalRegistry = func(kc kubernetes.Interface) *registry {
reg := ®istry{}
// plugins should be added here
reg.plugins = append(reg.plugins,
NewRetriesPlugin(),
//NewLinkerdTimeoutsPlugin(),
)
return reg
}
func Plugins(kc kubernetes.Interface) []Plugin {
return globalRegistry(kc).plugins
}