Skip to content

Commit

Permalink
fix: do not export repo-server environment to sidecar (argoproj#9393)
Browse files Browse the repository at this point in the history
getPluginEnvs is both used for local plugins and sidecar plugins. For the later
do not include the environement variables of the repo-server in the supplied
variables.

Fixes: argoproj#9393
Signed-off-by: Pierre Crégut <[email protected]>
  • Loading branch information
pierrecregut committed May 13, 2022
1 parent c026189 commit e28ca33
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ func runConfigManagementPlugin(appPath, repoRoot string, envVars *v1alpha1.Env,
}
}

env, err := getPluginEnvs(envVars, q, creds)
env, err := getPluginEnvs(envVars, q, creds, false)
if err != nil {
return nil, err
}
Expand All @@ -1270,8 +1270,14 @@ func runConfigManagementPlugin(appPath, repoRoot string, envVars *v1alpha1.Env,
return kube.SplitYAML([]byte(out))
}

func getPluginEnvs(envVars *v1alpha1.Env, q *apiclient.ManifestRequest, creds git.Creds) ([]string, error) {
env := append(os.Environ(), envVars.Environ()...)
func getPluginEnvs(envVars *v1alpha1.Env, q *apiclient.ManifestRequest, creds git.Creds, remote bool) ([]string, error) {
env := envVars.Environ()
// Local plugins need also to have access to the local environment variables.
// Remote side car plugins will use the environment in the side car
// container.
if !remote {
env = append(os.Environ(), env...)
}
if creds != nil {
closer, environ, err := creds.Environ()
if err != nil {
Expand Down Expand Up @@ -1311,7 +1317,7 @@ func runConfigManagementPluginSidecars(ctx context.Context, appPath, repoPath st
defer io.Close(conn)

// generate manifests using commands provided in plugin config file in detected cmp-server sidecar
env, err := getPluginEnvs(envVars, q, creds)
env, err := getPluginEnvs(envVars, q, creds, true)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e28ca33

Please sign in to comment.