forked from cyberark/secretless-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugins.go
40 lines (35 loc) · 1.58 KB
/
plugins.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
package plugin
import (
"github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector/http"
"github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector/tcp"
)
// builtinConnectorIDs is a list of connector IDs for "connectors" that don't
// even exist as separate objects, but are hardcoded into the ssh proxy
// services.
var builtinConnectorIDs = []string{"ssh", "ssh-agent"}
// AvailablePlugins is an interface that provides a list of all the available
// plugins for each type that the broker supports.
type AvailablePlugins interface {
HTTPPlugins() map[string]http.Plugin
TCPPlugins() map[string]tcp.Plugin
}
// AvailableConnectorIDs returns a list of all available connector IDs: for both
// builtin connectors and those provided by AvailablePlugins. In the case of
// AvailablePlugins, the connector ID and plugin ID are identical. For the
// builtin "connectors", the concept of plugin ID doesn't make sense.
// AvailableConnectorIDs is a pure function that depends only on the
// AvailablePlugins interface, which is why we define it here rather than in the
// implementation package "sharedobj".
func AvailableConnectorIDs(availPlugins AvailablePlugins) []string {
// Start with the IDs of the static, built-in ssh plugins.
var connectorIDs []string
connectorIDs = append(connectorIDs, builtinConnectorIDs...)
// Now add the connector IDs from the available plugins.
for name := range availPlugins.TCPPlugins() {
connectorIDs = append(connectorIDs, name)
}
for name := range availPlugins.HTTPPlugins() {
connectorIDs = append(connectorIDs, name)
}
return connectorIDs
}