diff --git a/gatewayd_plugins.yaml b/gatewayd_plugins.yaml index de449aec..23453432 100644 --- a/gatewayd_plugins.yaml +++ b/gatewayd_plugins.yaml @@ -1,4 +1,12 @@ +# Plugin configuration file for GatewayD + +# Plugin name gatewayd-plugin-test: + # whether to enable or disable the plugin on the next run enabled: True + # path to the plugin's binary file localPath: ../gatewayd-plugin-test/gatewayd-plugin-test - checksum: ca3f75467f022bf0049fb26c604348bb96f97863a5c526ca2808e21daa8c2694 + # Pass cmdline args to the plugin + args: ["--log-level", "info"] + # Checksum hash to verify the binary before loading + checksum: a20e3a1529f4460ad24416a055d599f6f55f42ead836345a4bf0a17d056abb45 diff --git a/plugin/plugin.go b/plugin/plugin.go index 7628d432..cb81d68f 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -33,6 +33,7 @@ type Impl struct { License string ProjectURL string LocalPath string + Args []string Enabled bool // internal and external config options Config map[string]string diff --git a/plugin/registry.go b/plugin/registry.go index 9b4f8d6e..c0adf32f 100644 --- a/plugin/registry.go +++ b/plugin/registry.go @@ -129,6 +129,10 @@ func (reg *RegistryImpl) LoadPlugins(pluginConfig *koanf.Koanf) { plugin.LocalPath = localPath } + if args := pluginConfig.Strings(name + ".args"); len(args) > 0 { + plugin.Args = args + } + if checksum, ok := pluginConfig.Get(name + ".checksum").(string); !ok || checksum == "" { reg.hooksConfig.Logger.Debug().Str("name", name).Msg( "Checksum of plugin doesn't exist or is not set") @@ -163,7 +167,7 @@ func (reg *RegistryImpl) LoadPlugins(pluginConfig *koanf.Koanf) { &goplugin.ClientConfig{ HandshakeConfig: pluginV1.Handshake, Plugins: pluginV1.GetPluginMap(plugin.ID.Name), - Cmd: exec.Command(plugin.LocalPath), //nolint:gosec + Cmd: exec.Command(plugin.LocalPath, plugin.Args...), //nolint:gosec AllowedProtocols: []goplugin.Protocol{ goplugin.ProtocolGRPC, },