-
Couldn't load subscription status.
- Fork 5
test: Allow Storm to accept any env vars, not just proxy vars #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
e049086
df6b131
75411ad
d10c8f8
7e2c325
0a11b46
c55cc0a
41fa134
cf07c74
73143fe
12c5193
1de9f14
f1ce724
6fe7aa9
e410774
5c92b73
910492f
faf8e97
c644cdb
e66110d
e3b8a44
6b28ac2
1338975
34282b8
b5db98f
36eb1d3
f0e8bbe
0fb3f2d
449617b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,10 +19,12 @@ const ( | |||||||||||||
| DOCKER_IMAGE_PATH = "/var/lib/trident/trident-container.tar.gz" | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| func BuildTridentContainerCommand(env string) string { | ||||||||||||||
| func BuildTridentContainerCommand(envVars []string) string { | ||||||||||||||
| cmd := DOCKER_COMMAND_BASE | ||||||||||||||
| if env != "" { | ||||||||||||||
| cmd += fmt.Sprintf("--env %s ", env) | ||||||||||||||
| if len(envVars) != 0 { | ||||||||||||||
| for _, envVar := range envVars { | ||||||||||||||
| cmd += fmt.Sprintf("--env %s ", envVar) | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| cmd += TRIDENT_CONTAINER | ||||||||||||||
| return cmd | ||||||||||||||
|
|
@@ -38,27 +40,35 @@ func BuildTridentContainerCommand(env string) string { | |||||||||||||
| // - The SSH session cannot be created | ||||||||||||||
| // - There was an error starting the command. | ||||||||||||||
| // - Some IO error occurred while reading stdout or stderr. | ||||||||||||||
| func InvokeTrident(env TridentEnvironment, client *ssh.Client, proxy string, arguments string) (*SshCmdOutput, error) { | ||||||||||||||
| func InvokeTrident(env TridentEnvironment, client *ssh.Client, envVars []string, arguments string) (*SshCmdOutput, error) { | ||||||||||||||
| var cmd string | ||||||||||||||
| switch env { | ||||||||||||||
| case TridentEnvironmentHost: | ||||||||||||||
| cmd = TRIDENT_BINARY | ||||||||||||||
| case TridentEnvironmentContainer: | ||||||||||||||
| cmd = BuildTridentContainerCommand(proxy) | ||||||||||||||
| cmd = BuildTridentContainerCommand(envVars) | ||||||||||||||
| case TridentEnvironmentNone: | ||||||||||||||
| return nil, fmt.Errorf("trident service is not running") | ||||||||||||||
| default: | ||||||||||||||
| return nil, fmt.Errorf("invalid environment: %s", env) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| var cmdPrefix string | ||||||||||||||
| if proxy != "" { | ||||||||||||||
| envVar := strings.Split(proxy, "=")[0] | ||||||||||||||
| cmdPrefix = fmt.Sprintf("%s sudo --preserve-env=%s", proxy, envVar) | ||||||||||||||
| if len(envVars) != 0 { | ||||||||||||||
| var envKeys []string | ||||||||||||||
| for _, v := range envVars { | ||||||||||||||
| if key := strings.Split(v, "=")[0]; key != "" { | ||||||||||||||
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| envKeys = append(envKeys, key) | ||||||||||||||
|
||||||||||||||
| if key := strings.Split(v, "=")[0]; key != "" { | |
| envKeys = append(envKeys, key) | |
| if strings.Contains(v, "=") { | |
| if key := strings.SplitN(v, "=", 2)[0]; key != "" { | |
| envKeys = append(envKeys, key) | |
| } |
Uh oh!
There was an error while loading. Please reload this page.