/
provider.go
39 lines (32 loc) 路 921 Bytes
/
provider.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
package provider
import (
"context"
"github.com/open-policy-agent/gatekeeper/v3/pkg/pubsub/connection"
"github.com/open-policy-agent/gatekeeper/v3/pkg/pubsub/dapr"
)
var pubSubs = newPubSubSet(map[string]InitiateConnection{
dapr.Name: dapr.NewConnection,
},
)
type pubSubSet struct {
supportedPubSub map[string]InitiateConnection
}
// returns new client for pub sub tool.
type InitiateConnection func(ctx context.Context, config interface{}) (connection.Connection, error)
func newPubSubSet(pubSubs map[string]InitiateConnection) *pubSubSet {
supported := make(map[string]InitiateConnection)
set := &pubSubSet{
supportedPubSub: supported,
}
for name := range pubSubs {
set.supportedPubSub[name] = pubSubs[name]
}
return set
}
func List() map[string]InitiateConnection {
ret := make(map[string]InitiateConnection)
for name, new := range pubSubs.supportedPubSub {
ret[name] = new
}
return ret
}