Plugins: Add plugin version field to proto interface (#78213)

add plugin version
This commit is contained in:
Will Browne 2023-11-15 16:53:30 +01:00 committed by GitHub
parent 0122f7ccad
commit b3ad61e180
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,19 +26,22 @@ type ProtoClient interface {
PID() (string, error)
PluginID() string
PluginVersion() string
Logger() log.Logger
Start(context.Context) error
Stop(context.Context) error
}
type protoClient struct {
plugin *grpcPlugin
plugin *grpcPlugin
pluginVersion string
mu sync.RWMutex
}
type ProtoClientOpts struct {
PluginID string
PluginVersion string
ExecutablePath string
ExecutableArgs []string
Env []string
@ -58,7 +61,7 @@ func NewProtoClient(opts ProtoClientOpts) (ProtoClient, error) {
func() []string { return opts.Env },
)
return &protoClient{plugin: p}, nil
return &protoClient{plugin: p, pluginVersion: opts.PluginVersion}, nil
}
func (r *protoClient) PID() (string, error) {
@ -72,6 +75,10 @@ func (r *protoClient) PluginID() string {
return r.plugin.descriptor.pluginID
}
func (r *protoClient) PluginVersion() string {
return r.pluginVersion
}
func (r *protoClient) Logger() log.Logger {
return r.plugin.logger
}