Skip to content

Commit

Permalink
Add exports to proxy plugin config
Browse files Browse the repository at this point in the history
Allows external plugins to define exports.

Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit e4639ad)
Signed-off-by: Kern Walster <walster@amazon.com>
  • Loading branch information
dmcgowan authored and Kern-- committed Apr 17, 2024
1 parent 8916e2c commit 8fb6bfa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions services/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ type CgroupConfig struct {

// ProxyPlugin provides a proxy plugin configuration
type ProxyPlugin struct {
Type string `toml:"type"`
Address string `toml:"address"`
Platform string `toml:"platform"`
Type string `toml:"type"`
Address string `toml:"address"`
Platform string `toml:"platform"`
Exports map[string]string `toml:"exports"`
}

// Decode unmarshals a plugin specific configuration by plugin id
Expand Down
8 changes: 7 additions & 1 deletion services/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,17 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
p = platforms.DefaultSpec()
}

exports := pp.Exports
if exports == nil {
exports = map[string]string{}
}
exports["address"] = address

plugin.Register(&plugin.Registration{
Type: t,
ID: name,
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
ic.Meta.Exports["address"] = address
ic.Meta.Exports = exports
ic.Meta.Platforms = append(ic.Meta.Platforms, p)
conn, err := clients.getClient(address)
if err != nil {
Expand Down

0 comments on commit 8fb6bfa

Please sign in to comment.