Documentation ¶
Index ¶
- func NewHostServer(pluginName string, opts []grpc.ServerOption, hostServices []HostServiceServer) *grpc.Server
- func PluginMain(plugin Plugin)
- func PluginNameFromHostServiceContext(ctx context.Context) (string, bool)
- func WithPluginName(ctx context.Context, name string) context.Context
- type BuiltInPlugin
- type Catalog
- type Closer
- type Config
- type ExternalPlugin
- type GlobalConfig
- type HCLPluginConfig
- type HCLPluginConfigMap
- type HostServiceBroker
- type HostServiceClient
- type HostServiceServer
- type LoadedPlugin
- type NeedsHostServices
- type NeedsLogger
- type PipeAddr
- type PipeNet
- type Plugin
- type PluginClient
- type PluginConfig
- type PluginInfo
- type PluginServer
- type ServiceClient
- type ServiceServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHostServer ¶
func NewHostServer(pluginName string, opts []grpc.ServerOption, hostServices []HostServiceServer) *grpc.Server
func PluginMain ¶
func PluginMain(plugin Plugin)
Types ¶
type BuiltInPlugin ¶
type BuiltInPlugin struct { Log logrus.FieldLogger Plugin Plugin HostServices []HostServiceServer }
type Catalog ¶
type Catalog interface { // Fill fills up a "catalog" with client interfaces to interface with // the plugins and services offered by loaded plugins. The shape of the // "catalog" determines the constraints and requirements of the plugins. // // The "catalog" can be a pointer to an interface: // // // Fill() will fail if there are no plugins that implement NodeAttestor // var na nodeattestor.NodeAttestor // cat, _ := catalog.Load(...) // cat.Fill(&c) // catalog.Fill(&na) // // The "catalog" can also be a pointer to a struct: // // type TheCatalog struct { // // A required interface. Fill() fails if there is not exactly // // one plugin matching this interface. // RequiredPlugin nodeattestor.NodeAttestor // // // An optional interface. Fill() fails if there are more than // // one plugin that match this interface. // OptionalPlugin *nodeattestor.NodeAttestor // // // A slice of interfaces. // Plugins []nodeattestor.NodeAttestor // // // A map from string to interface. The key of the map is the name // // of the plugin that matched. // PluginsByName map[string]nodeattestor.NodeAttestor // // // A struct of interfaces. A plugin must satisfy all interfaces // // // within the struct to match. Fill() fails if there is not // // exactly one plugin that matches. // RequiredPluginStruct StructOfInterface // // // A pointer to a struct of interfaces. A plugin must satisfy all // // interfaces within the struct to meet the criteria. Fill() fails // // if there are more than one plugin that matches. // OptionalPluginStruct *StructOfInterface // // // A slice of a struct of interfaces. // PluginStructs []StructOfInterface // // // A map from string to struct of interfaces. The key of the map // // is the name of the plugin that matched. // PluginStructsByName map[string]StructOfInterface // } // // type StructOfInterface struct { // // The PluginInfo interface is special and is implemented on all // // plugins. // catalog.PluginInfo // // nodeattestor.NodeAttestor // } // // var c TheCatalog // cat, _ := catalog.Load(...) // cat.Fill(&c) // // In addition, the slice and map struct fields support imposing minimum // and maximum constraints on the number of plugins to populate that // field. For example: // // struct { // AtLeastTwo []nodeattestor.NodeAttestor `catalog:"min=2"` // AtMostTwo []nodeattestor.NodeAttestor `catalog:"max=2"` // BetweenThreeAndFive []nodeattestor.NodeAttestor `catalog:"min=3,max=5"` // } // // You can also add a `catalog:"-"` tag to a field to have it be ignored // by the catalog: // // struct { // IgnoreMe int `catalog:"-"` // } // Fill(x interface{}) error // Close() closes the catalog, shutting down servers and killing external // plugin processes. Close() }
Catalog provides a method to obtain clients to loaded plugins and services.
type Config ¶
type Config struct { Log logrus.FieldLogger // GlobalConfig is passed to plugins during configuration. GlobalConfig *GlobalConfig // PluginConfig is the configuration of plugins to load. PluginConfig []PluginConfig // KnownPlugins is the set of known external plugins. KnownPlugins []PluginClient // KnownServices is the set of known external services. KnownServices []ServiceClient // HostServices is a set of services offered by the host. HostServices []HostServiceServer // BuiltIns is the set of builtin plugins available to the host. BuiltIns []Plugin }
type ExternalPlugin ¶
type ExternalPlugin struct { Log logrus.FieldLogger Name string Path string Checksum string Data string Plugin PluginClient KnownServices []ServiceClient HostServices []HostServiceServer }
type GlobalConfig ¶
type GlobalConfig = spi.ConfigureRequest_GlobalConfig
type HCLPluginConfig ¶
type HCLPluginConfig struct { PluginCmd string `hcl:"plugin_cmd"` PluginChecksum string `hcl:"plugin_checksum"` PluginData ast.Node `hcl:"plugin_data"` Enabled *bool `hcl:"enabled"` }
HCLPluginConfig serves as an intermediary struct. We pass this to the HCL library for parsing, except the parser won't parse pluginData as a string.
func (HCLPluginConfig) IsEnabled ¶
func (c HCLPluginConfig) IsEnabled() bool
type HCLPluginConfigMap ¶
type HCLPluginConfigMap map[string]map[string]HCLPluginConfig
type HostServiceBroker ¶
type HostServiceBroker interface {
GetHostService(HostServiceClient) (has bool, err error)
}
HostServiceBroker is used by plugins that implement the NeedsHostBroker service to obtain host service clients.
type HostServiceClient ¶
type HostServiceClient interface { HostServiceType() string // InitHostServiceClient initializes the host service client. InitHostServiceClient(conn grpc.ClientConnInterface) }
HostServiceClient is used to initialize a host service client.
type HostServiceServer ¶
type HostServiceServer interface { // HostServiceType returns the host service type HostServiceType() string // RegisterHostServiceServer registers the host service server. RegisterHostServiceServer(*grpc.Server) }
HostServiceServer is used to register a host service server.
type LoadedPlugin ¶
type LoadedPlugin struct {
// contains filtered or unexported fields
}
func LoadBuiltInPlugin ¶
func LoadBuiltInPlugin(ctx context.Context, builtin BuiltInPlugin) (plugin *LoadedPlugin, err error)
LoadBuiltIn loads a builtin plugin.
func LoadExternalPlugin ¶
func LoadExternalPlugin(ctx context.Context, ext ExternalPlugin) (plugin *LoadedPlugin, err error)
func (*LoadedPlugin) BuiltIn ¶ added in v0.11.0
func (p *LoadedPlugin) BuiltIn() bool
func (*LoadedPlugin) Close ¶
func (p *LoadedPlugin) Close()
func (*LoadedPlugin) Configure ¶
func (p *LoadedPlugin) Configure(ctx context.Context, req *spi.ConfigureRequest) error
func (*LoadedPlugin) Fill ¶
func (p *LoadedPlugin) Fill(x interface{}) (err error)
func (*LoadedPlugin) Name ¶
func (p *LoadedPlugin) Name() string
type NeedsHostServices ¶
type NeedsHostServices interface {
BrokerHostServices(HostServiceBroker) error
}
NeedsHostServices is implemented by plugin/service implementations that need to obtain clients to host services.
type NeedsLogger ¶
type NeedsLogger interface {
SetLogger(hclog.Logger)
}
NeedsLogger is implemented by plugin/service implementations that need a logger that is connected to the SPIRE core logger.
type PipeNet ¶
type PipeNet struct {
// contains filtered or unexported fields
}
func NewPipeNet ¶
func NewPipeNet() *PipeNet
type Plugin ¶
type Plugin struct { Name string Plugin PluginServer Services []ServiceServer }
func MakePlugin ¶
func MakePlugin(name string, plugin PluginServer, services ...ServiceServer) Plugin
type PluginClient ¶
type PluginClient interface { PluginType() string // NewPluginClient initializes and returns a service client. NewPluginClient(grpc.ClientConnInterface) interface{} }
PluginClient is used to initialize and return a plugin client.
type PluginConfig ¶
type PluginConfig struct { Name string Type string Path string Checksum string Data string Disabled bool }
func ParsePluginConfigsFromHCL ¶ added in v0.12.0
func ParsePluginConfigsFromHCL(config string) ([]PluginConfig, error)
func PluginConfigFromHCL ¶
func PluginConfigFromHCL(pluginType, pluginName string, hclPluginConfig HCLPluginConfig) (PluginConfig, error)
func PluginConfigsFromHCL ¶ added in v0.12.0
func PluginConfigsFromHCL(hclPlugins HCLPluginConfigMap) ([]PluginConfig, error)
type PluginInfo ¶
type PluginServer ¶
type PluginServer interface { // PluginType returns the plugin type PluginType() string // PluginClient returns the PluginClient interface for this server. PluginClient() PluginClient // Registers the implementation against the provided gRPC server and // returns the implementation. The implementation is used to wire up // logging and host services. RegisterPluginServer(server *grpc.Server) interface{} }
PluginServer is the interface for both the primary interface and auxiliary services served by the plugin.
type ServiceClient ¶
type ServiceClient interface { // ServiceType returns the service type ServiceType() string // NewServiceClient initializes and returns a service client. NewServiceClient(grpc.ClientConnInterface) interface{} }
ServiceClient is used to initialize and return a service client.
type ServiceServer ¶
type ServiceServer interface { // ServiceType returns the service type ServiceType() string // ServiceClient returns the PluginClient interface for this server. ServiceClient() ServiceClient // Registers the implementation against the provided gRPC server and // returns the implementation. The implementation is used to wire up // logging and host services. RegisterServiceServer(server *grpc.Server) interface{} }
ServiceServer is the interface for both the primary interface and auxiliary services served by the plugin.