Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion gatewayd_plugins.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion plugin/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
},
Expand Down