diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2023-04-04 08:42:23 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2023-04-04 09:08:57 -0400 |
| commit | 72194feae77870190471d220898e2ccf1c7443a5 (patch) | |
| tree | cd386500fd5c08318e80fad78b87dbdc6126e04a /plugins.go | |
| parent | cd3be0bb789acd4b48f6572cfd230e9100ac2d6c (diff) | |
New plugin args option
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'plugins.go')
| -rw-r--r-- | plugins.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -37,6 +37,7 @@ func bindPlugins(ctx context.Context, cfg *config.Config, funcMap template.FuncM Timeout: timeout, Pipe: v.Pipe, Stderr: cfg.Stderr, + Args: v.Args, }) } @@ -49,6 +50,10 @@ type PluginOpts struct { // Defaults to os.Stderr. Stderr io.Writer + // Args are additional arguments to pass to the plugin. These precede any + // arguments passed to the plugin function at runtime. + Args []string + // Timeout is the maximum amount of time to wait for the plugin to complete. // Defaults to 5 seconds. Timeout time.Duration @@ -74,6 +79,7 @@ func PluginFunc(ctx context.Context, cmd string, opts PluginOpts) func(...interf plugin := &plugin{ ctx: ctx, path: cmd, + args: opts.Args, timeout: timeout, pipe: opts.Pipe, stderr: stderr, @@ -87,6 +93,7 @@ type plugin struct { ctx context.Context stderr io.Writer path string + args []string timeout time.Duration pipe bool } @@ -122,6 +129,7 @@ func findPowershell() string { func (p *plugin) run(args ...interface{}) (interface{}, error) { a := conv.ToStrings(args...) + a = append(p.args, a...) name, a := p.buildCommand(a) |
