Allow plugins to load environment variable (#1727)

* Allow plugins to load environment variable
This commit is contained in:
AlteredCoder 2022-09-08 11:41:28 +02:00 committed by GitHub
parent f3317f78d5
commit b06167a3fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 1 deletions

View file

@ -254,7 +254,7 @@ func (pb *PluginBroker) loadPlugins(path string) error {
if err != nil {
return err
}
data = []byte(os.ExpandEnv(string(data)))
_, err = pluginClient.Configure(context.Background(), &protobufs.Config{Config: data})
if err != nil {
return errors.Wrapf(err, "while configuring %s", pc.Name)

View file

@ -79,6 +79,7 @@ func (n *EmailPlugin) Configure(ctx context.Context, config *protobufs.Config) (
}
n.ConfigByName[d.Name] = d
baseLogger.Debug(fmt.Sprintf("Email plugin '%s' use SMTP host '%s:%d'", d.Name, d.SMTPHost, d.SMTPPort))
return &protobufs.Empty{}, nil
}

View file

@ -90,6 +90,7 @@ func (s *HTTPPlugin) Configure(ctx context.Context, config *protobufs.Config) (*
d := PluginConfig{}
err := yaml.Unmarshal(config.Config, &d)
s.PluginConfigByName[d.Name] = d
logger.Debug(fmt.Sprintf("HTTP plugin '%s' use URL '%s'", d.Name, d.URL))
return &protobufs.Empty{}, err
}

View file

@ -57,6 +57,7 @@ func (n *Notify) Configure(ctx context.Context, config *protobufs.Config) (*prot
return nil, err
}
n.ConfigByName[d.Name] = d
logger.Debug(fmt.Sprintf("Slack plugin '%s' use URL '%s'", d.Name, d.Webhook))
return &protobufs.Empty{}, nil
}

View file

@ -89,6 +89,7 @@ func (s *Splunk) Configure(ctx context.Context, config *protobufs.Config) (*prot
d := PluginConfig{}
err := yaml.Unmarshal(config.Config, &d)
s.PluginConfigByName[d.Name] = d
logger.Debug(fmt.Sprintf("Splunk plugin '%s' use URL '%s'", d.Name, d.URL))
return &protobufs.Empty{}, err
}