Documentation ¶
Index ¶
- Constants
- Variables
- func Dispense(rpcClient plugin.ClientProtocol, pluginClient pluginutil.PluginClient) (logical.Backend, error)
- func NewBackend(ctx context.Context, pluginName string, pluginType consts.PluginType, ...) (logical.Backend, error)
- func NewBackendV5(ctx context.Context, pluginName string, pluginType consts.PluginType, ...) (logical.Backend, error)
- func NewBackendWithVersion(ctx context.Context, pluginName string, pluginType consts.PluginType, ...) (logical.Backend, error)
- func NewPluginClient(ctx context.Context, sys pluginutil.RunnerUtil, ...) (logical.Backend, error)
- func NewPluginClientV5(ctx context.Context, sys pluginutil.RunnerUtil, ...) (logical.Backend, error)
- func Serve(opts *ServeOpts) error
- func ServeMultiplex(opts *ServeOpts) error
- type BackendPluginClient
- type BackendPluginClientV5
- type BackendTracingMiddleware
- func (b *BackendTracingMiddleware) Cleanup(ctx context.Context)
- func (b *BackendTracingMiddleware) HandleExistenceCheck(ctx context.Context, req *logical.Request) (found bool, exists bool, err error)
- func (b *BackendTracingMiddleware) HandleRequest(ctx context.Context, req *logical.Request) (resp *logical.Response, err error)
- func (b *BackendTracingMiddleware) Initialize(ctx context.Context, req *logical.InitializationRequest) (err error)
- func (b *BackendTracingMiddleware) InvalidateKey(ctx context.Context, key string)
- func (b *BackendTracingMiddleware) Logger() log.Logger
- func (b *BackendTracingMiddleware) PluginVersion() logical.PluginVersion
- func (b *BackendTracingMiddleware) Setup(ctx context.Context, config *logical.BackendConfig) (err error)
- func (b *BackendTracingMiddleware) SpecialPaths() *logical.Paths
- func (b *BackendTracingMiddleware) System() logical.SystemView
- func (b *BackendTracingMiddleware) Type() logical.BackendType
- type ContextKey
- type GRPCBackendPlugin
- type GRPCStorageClient
- func (s *GRPCStorageClient) Delete(ctx context.Context, key string) error
- func (s *GRPCStorageClient) Get(ctx context.Context, key string) (*logical.StorageEntry, error)
- func (s *GRPCStorageClient) List(ctx context.Context, prefix string) ([]string, error)
- func (s *GRPCStorageClient) ListPage(ctx context.Context, prefix string, after string, limit int) ([]string, error)
- func (s *GRPCStorageClient) Put(ctx context.Context, entry *logical.StorageEntry) error
- type GRPCStorageClientTransaction
- type GRPCStorageServer
- func (s *GRPCStorageServer) BeginReadOnlyTx(ctx context.Context, args *pb.Empty) (*pb.StorageBeginTxReply, error)
- func (s *GRPCStorageServer) BeginTx(ctx context.Context, args *pb.Empty) (*pb.StorageBeginTxReply, error)
- func (s *GRPCStorageServer) Commit(ctx context.Context, args *pb.StorageCommitTxArgs) (*pb.StorageCommitTxReply, error)
- func (s *GRPCStorageServer) Delete(ctx context.Context, args *pb.StorageDeleteArgs) (*pb.StorageDeleteReply, error)
- func (s *GRPCStorageServer) Get(ctx context.Context, args *pb.StorageGetArgs) (*pb.StorageGetReply, error)
- func (s *GRPCStorageServer) IsTransactional(ctx context.Context, args *pb.Empty) (*pb.StorageIsTransactionalReply, error)
- func (s *GRPCStorageServer) List(ctx context.Context, args *pb.StorageListArgs) (*pb.StorageListReply, error)
- func (s *GRPCStorageServer) ListPage(ctx context.Context, args *pb.StorageListPageArgs) (*pb.StorageListReply, error)
- func (s *GRPCStorageServer) Put(ctx context.Context, args *pb.StoragePutArgs) (*pb.StoragePutReply, error)
- func (s *GRPCStorageServer) Rollback(ctx context.Context, args *pb.StorageRollbackTxArgs) (*pb.StorageRollbackTxReply, error)
- type GRPCTransactionalStorageClient
- type LoggerArgs
- type LoggerReply
- type LoggerServer
- func (l *LoggerServer) Debug(args *LoggerArgs, _ *struct{}) error
- func (l *LoggerServer) Error(args *LoggerArgs, reply *LoggerReply) error
- func (l *LoggerServer) Info(args *LoggerArgs, _ *struct{}) error
- func (l *LoggerServer) IsDebug(args interface{}, reply *LoggerReply) error
- func (l *LoggerServer) IsInfo(args interface{}, reply *LoggerReply) error
- func (l *LoggerServer) IsTrace(args interface{}, reply *LoggerReply) error
- func (l *LoggerServer) IsWarn(args interface{}, reply *LoggerReply) error
- func (l *LoggerServer) Log(args *LoggerArgs, _ *struct{}) error
- func (l *LoggerServer) SetLevel(args int, _ *struct{}) error
- func (l *LoggerServer) Trace(args *LoggerArgs, _ *struct{}) error
- func (l *LoggerServer) Warn(args *LoggerArgs, reply *LoggerReply) error
- type NOOPStorage
- func (s *NOOPStorage) Delete(_ context.Context, key string) error
- func (s *NOOPStorage) Get(_ context.Context, key string) (*logical.StorageEntry, error)
- func (s *NOOPStorage) List(_ context.Context, prefix string) ([]string, error)
- func (s *NOOPStorage) ListPage(_ context.Context, prefix string, after string, limit int) ([]string, error)
- func (s *NOOPStorage) Put(_ context.Context, entry *logical.StorageEntry) error
- type ServeOpts
- type TLSProviderFunc
Constants ¶
const BackendPluginName = "backend"
BackendPluginName is the name of the plugin that can be dispensed from the plugin server.
const ContextKeyPluginReload = ContextKey("plugin-reload")
Variables ¶
var ( ErrPluginShutdown = errors.New("plugin is shut down") ErrClientInMetadataMode = errors.New("plugin client can not perform action while in metadata mode") )
var ErrServerInMetadataMode = errors.New("plugin server can not perform action while in metadata mode")
var HandshakeConfig = plugin.HandshakeConfig{
MagicCookieKey: "VAULT_BACKEND_PLUGIN",
MagicCookieValue: "6669da05-b1c8-4f49-97d9-c8e5bed98e20",
}
handshakeConfigs are used to just do a basic handshake between a plugin and host. If the handshake fails, a user friendly error is shown. This prevents users from executing bad plugins or executing a plugin directory. It is a UX feature, not a security feature.
var PluginSet = map[int]plugin.PluginSet{ 5: { "backend": &GRPCBackendPlugin{}, }, }
PluginSet is the map of plugins we can dispense.
Functions ¶
func Dispense ¶
func Dispense(rpcClient plugin.ClientProtocol, pluginClient pluginutil.PluginClient) (logical.Backend, error)
func NewBackend ¶
func NewBackend(ctx context.Context, pluginName string, pluginType consts.PluginType, sys pluginutil.LookRunnerUtil, conf *logical.BackendConfig, isMetadataMode bool) (logical.Backend, error)
NewBackend will return an instance of an RPC-based client implementation of the backend for external plugins, or a concrete implementation of the backend if it is a builtin backend. The backend is returned as a logical.Backend interface. The isMetadataMode param determines whether the plugin should run in metadata mode.
func NewBackendV5 ¶
func NewBackendV5(ctx context.Context, pluginName string, pluginType consts.PluginType, pluginVersion string, sys pluginutil.LookRunnerUtil, conf *logical.BackendConfig) (logical.Backend, error)
NewBackendV5 will return an instance of an RPC-based client implementation of the backend for external plugins, or a concrete implementation of the backend if it is a builtin backend. The backend is returned as a logical.Backend interface.
func NewBackendWithVersion ¶
func NewBackendWithVersion(ctx context.Context, pluginName string, pluginType consts.PluginType, sys pluginutil.LookRunnerUtil, conf *logical.BackendConfig, isMetadataMode bool, version string) (logical.Backend, error)
NewBackendWithVersion will return an instance of an RPC-based client implementation of the backend for external plugins, or a concrete implementation of the backend if it is a builtin backend. The backend is returned as a logical.Backend interface. The isMetadataMode param determines whether the plugin should run in metadata mode.
func NewPluginClient ¶
func NewPluginClient(ctx context.Context, sys pluginutil.RunnerUtil, pluginRunner *pluginutil.PluginRunner, logger log.Logger, isMetadataMode bool) (logical.Backend, error)
func NewPluginClientV5 ¶
func NewPluginClientV5(ctx context.Context, sys pluginutil.RunnerUtil, config pluginutil.PluginClientConfig) (logical.Backend, error)
func Serve ¶
Serve is a helper function used to serve a backend plugin. This should be ran on the plugin's main process.
func ServeMultiplex ¶
ServeMultiplex is a helper function used to serve a backend plugin. This should be ran on the plugin's main process.
Types ¶
type BackendPluginClient ¶
BackendPluginClient is a wrapper around backendPluginClient that also contains its plugin.Client instance. It's primarily used to cleanly kill the client on Cleanup()
func (*BackendPluginClient) Cleanup ¶
func (b *BackendPluginClient) Cleanup(ctx context.Context)
Cleanup calls the RPC client's Cleanup() func and also calls the go-plugin's client Kill() func
func (*BackendPluginClient) PluginVersion ¶
func (b *BackendPluginClient) PluginVersion() logical.PluginVersion
type BackendPluginClientV5 ¶
BackendPluginClientV5 is a wrapper around backendPluginClient that also contains its plugin.Client instance. It's primarily used to cleanly kill the client on Cleanup()
func (*BackendPluginClientV5) Cleanup ¶
func (b *BackendPluginClientV5) Cleanup(ctx context.Context)
Cleanup cleans up the go-plugin client and the plugin catalog
func (*BackendPluginClientV5) IsExternal ¶
func (b *BackendPluginClientV5) IsExternal() bool
func (*BackendPluginClientV5) PluginVersion ¶
func (b *BackendPluginClientV5) PluginVersion() logical.PluginVersion
type BackendTracingMiddleware ¶
type BackendTracingMiddleware struct {
// contains filtered or unexported fields
}
backendPluginClient implements logical.Backend and is the go-plugin client.
func (*BackendTracingMiddleware) Cleanup ¶
func (b *BackendTracingMiddleware) Cleanup(ctx context.Context)
func (*BackendTracingMiddleware) HandleExistenceCheck ¶
func (*BackendTracingMiddleware) HandleRequest ¶
func (*BackendTracingMiddleware) Initialize ¶
func (b *BackendTracingMiddleware) Initialize(ctx context.Context, req *logical.InitializationRequest) (err error)
func (*BackendTracingMiddleware) InvalidateKey ¶
func (b *BackendTracingMiddleware) InvalidateKey(ctx context.Context, key string)
func (*BackendTracingMiddleware) Logger ¶
func (b *BackendTracingMiddleware) Logger() log.Logger
func (*BackendTracingMiddleware) PluginVersion ¶
func (b *BackendTracingMiddleware) PluginVersion() logical.PluginVersion
func (*BackendTracingMiddleware) Setup ¶
func (b *BackendTracingMiddleware) Setup(ctx context.Context, config *logical.BackendConfig) (err error)
func (*BackendTracingMiddleware) SpecialPaths ¶
func (b *BackendTracingMiddleware) SpecialPaths() *logical.Paths
func (*BackendTracingMiddleware) System ¶
func (b *BackendTracingMiddleware) System() logical.SystemView
func (*BackendTracingMiddleware) Type ¶
func (b *BackendTracingMiddleware) Type() logical.BackendType
type ContextKey ¶
type ContextKey string
func (ContextKey) String ¶
func (c ContextKey) String() string
type GRPCBackendPlugin ¶
type GRPCBackendPlugin struct { Factory logical.Factory MetadataMode bool Logger log.Logger MultiplexingSupport bool // Embeding this will disable the netRPC protocol plugin.NetRPCUnsupportedPlugin }
GRPCBackendPlugin is the plugin.Plugin implementation that only supports GRPC transport
func (*GRPCBackendPlugin) GRPCClient ¶
func (b *GRPCBackendPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
func (GRPCBackendPlugin) GRPCServer ¶
func (b GRPCBackendPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type GRPCStorageClient ¶
type GRPCStorageClient struct {
// contains filtered or unexported fields
}
GRPCStorageClient is an implementation of logical.Storage that communicates over RPC.
func (*GRPCStorageClient) Delete ¶
func (s *GRPCStorageClient) Delete(ctx context.Context, key string) error
func (*GRPCStorageClient) Get ¶
func (s *GRPCStorageClient) Get(ctx context.Context, key string) (*logical.StorageEntry, error)
func (*GRPCStorageClient) Put ¶
func (s *GRPCStorageClient) Put(ctx context.Context, entry *logical.StorageEntry) error
type GRPCStorageClientTransaction ¶ added in v2.1.0
type GRPCStorageClientTransaction struct {
GRPCStorageClient
}
type GRPCStorageServer ¶
type GRPCStorageServer struct { pb.UnimplementedStorageServer // contains filtered or unexported fields }
GRPCStorageServer is a net/rpc compatible structure for serving
func (*GRPCStorageServer) BeginReadOnlyTx ¶ added in v2.1.0
func (s *GRPCStorageServer) BeginReadOnlyTx(ctx context.Context, args *pb.Empty) (*pb.StorageBeginTxReply, error)
func (*GRPCStorageServer) BeginTx ¶ added in v2.1.0
func (s *GRPCStorageServer) BeginTx(ctx context.Context, args *pb.Empty) (*pb.StorageBeginTxReply, error)
func (*GRPCStorageServer) Commit ¶ added in v2.1.0
func (s *GRPCStorageServer) Commit(ctx context.Context, args *pb.StorageCommitTxArgs) (*pb.StorageCommitTxReply, error)
func (*GRPCStorageServer) Delete ¶
func (s *GRPCStorageServer) Delete(ctx context.Context, args *pb.StorageDeleteArgs) (*pb.StorageDeleteReply, error)
func (*GRPCStorageServer) Get ¶
func (s *GRPCStorageServer) Get(ctx context.Context, args *pb.StorageGetArgs) (*pb.StorageGetReply, error)
func (*GRPCStorageServer) IsTransactional ¶ added in v2.1.0
func (s *GRPCStorageServer) IsTransactional(ctx context.Context, args *pb.Empty) (*pb.StorageIsTransactionalReply, error)
func (*GRPCStorageServer) List ¶
func (s *GRPCStorageServer) List(ctx context.Context, args *pb.StorageListArgs) (*pb.StorageListReply, error)
func (*GRPCStorageServer) ListPage ¶
func (s *GRPCStorageServer) ListPage(ctx context.Context, args *pb.StorageListPageArgs) (*pb.StorageListReply, error)
func (*GRPCStorageServer) Put ¶
func (s *GRPCStorageServer) Put(ctx context.Context, args *pb.StoragePutArgs) (*pb.StoragePutReply, error)
func (*GRPCStorageServer) Rollback ¶ added in v2.1.0
func (s *GRPCStorageServer) Rollback(ctx context.Context, args *pb.StorageRollbackTxArgs) (*pb.StorageRollbackTxReply, error)
type GRPCTransactionalStorageClient ¶ added in v2.1.0
type GRPCTransactionalStorageClient struct {
GRPCStorageClient
}
func (*GRPCTransactionalStorageClient) BeginReadOnlyTx ¶ added in v2.1.0
func (s *GRPCTransactionalStorageClient) BeginReadOnlyTx(ctx context.Context) (logical.Transaction, error)
func (*GRPCTransactionalStorageClient) BeginTx ¶ added in v2.1.0
func (s *GRPCTransactionalStorageClient) BeginTx(ctx context.Context) (logical.Transaction, error)
type LoggerArgs ¶
type LoggerReply ¶
LoggerReply contains the RPC reply. Not all fields may be used for a particular RPC call.
type LoggerServer ¶
type LoggerServer struct {
// contains filtered or unexported fields
}
func (*LoggerServer) Debug ¶
func (l *LoggerServer) Debug(args *LoggerArgs, _ *struct{}) error
func (*LoggerServer) Error ¶
func (l *LoggerServer) Error(args *LoggerArgs, reply *LoggerReply) error
func (*LoggerServer) Info ¶
func (l *LoggerServer) Info(args *LoggerArgs, _ *struct{}) error
func (*LoggerServer) IsDebug ¶
func (l *LoggerServer) IsDebug(args interface{}, reply *LoggerReply) error
func (*LoggerServer) IsInfo ¶
func (l *LoggerServer) IsInfo(args interface{}, reply *LoggerReply) error
func (*LoggerServer) IsTrace ¶
func (l *LoggerServer) IsTrace(args interface{}, reply *LoggerReply) error
func (*LoggerServer) IsWarn ¶
func (l *LoggerServer) IsWarn(args interface{}, reply *LoggerReply) error
func (*LoggerServer) Log ¶
func (l *LoggerServer) Log(args *LoggerArgs, _ *struct{}) error
func (*LoggerServer) SetLevel ¶
func (l *LoggerServer) SetLevel(args int, _ *struct{}) error
func (*LoggerServer) Trace ¶
func (l *LoggerServer) Trace(args *LoggerArgs, _ *struct{}) error
func (*LoggerServer) Warn ¶
func (l *LoggerServer) Warn(args *LoggerArgs, reply *LoggerReply) error
type NOOPStorage ¶
type NOOPStorage struct{}
NOOPStorage is used to deny access to the storage interface while running a backend plugin in metadata mode.
func (*NOOPStorage) Get ¶
func (s *NOOPStorage) Get(_ context.Context, key string) (*logical.StorageEntry, error)
func (*NOOPStorage) Put ¶
func (s *NOOPStorage) Put(_ context.Context, entry *logical.StorageEntry) error
type ServeOpts ¶
type ServeOpts struct { BackendFactoryFunc logical.Factory TLSProviderFunc TLSProviderFunc Logger log.Logger }