Skip to content

Allow controlling environment variables when invoking a plugin #16

@ndrpnt

Description

@ndrpnt

I'd like to specify environment variables when invoking PluginRPC plugins. Currently the environment is always empty:

pluginrpc-go/runner.go

Lines 94 to 95 in ad1c581

// We want to make sure the command has access to no env vars, as the default is the current env.
cmd.Env = emptyEnv

I propose to add a ClientOption (or ExecRunnerOption or CallOption, not sure) that accepts a []string of the form "key=value", to match exec.Cmd.Env and os.Environ() format.

So something like:

func ClientWithEnviron(envs []string) ClientOption {
	return func(clientOptions *clientOptions) {
		clientOptions.envs = envs
	}
}

My use case: I write plugins that depend on (cloud providers') Go SDKs. These SDKs usually configure themselves through environment variables, among other ways. I want my plugins to feel intuitive by behaving like other tools and respecting these environment variables.

I guess it is possible to work around that limitation by passing environment variables as part of the plugin request, and then call os.Setenv() from the plugin. But that doesn't feel right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions