Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.
Open
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
5 changes: 5 additions & 0 deletions pkg/p2exec/p2_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var DefaultP2Exec = "/usr/local/bin/p2-exec"
type P2ExecArgs struct {
User string
EnvDirs []string
Envs []string
ExtraEnv map[string]string
NoLimits bool
PodID *types.PodID
Expand All @@ -40,6 +41,10 @@ func (args P2ExecArgs) CommandLine() []string {
cmd = append(cmd, "-e", envDir)
}

for _, env := range args.Envs {
cmd = append(cmd, "env", env)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should "env" be "--env"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we are using this way to modify the environment before executing a p2 hook launchable, and it works.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these traditional environment variables that are being added or are these truly just additional arguments that happen to be similar in name? Examples of traditional environment variable usage from my perspective:

~ export ABC=123
~ command_that_uses_abc

# or
~ API_KEY=xxx my_awesome_command

Copy link
Copy Markdown
Author

@yzaccc yzaccc Mar 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the env here is for adding the traditional environment variables for the commands. like
~ my_awesome_command env API_KEY=xxx
which equals to:
~ API_KEY=xxx my_awesome_command

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it is a custom argument that we turn into environment variables?

}

for envVarKey, envVarValue := range args.ExtraEnv {
cmd = append(cmd, "--extra-env", fmt.Sprintf("%s=%s", envVarKey, envVarValue))
}
Expand Down