Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
[Array] Ensure unique env vars (#31)
Browse files Browse the repository at this point in the history
* Ensure unique env vars

* Initialize map with enough capacity
  • Loading branch information
EngHabu authored Nov 13, 2019
1 parent c7dd2eb commit 507218d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions go/tasks/plugins/array/awsbatch/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,24 @@ func UpdateBatchInputForArray(_ context.Context, batchInput *batch.SubmitJobInpu
func getEnvVarsForTask(ctx context.Context, tCtx pluginCore.TaskExecutionContext, containerEnvVars []*core.KeyValuePair,
defaultEnvVars map[string]string) []v1.EnvVar {
envVars := flytek8s.DecorateEnvVars(ctx, flytek8s.ToK8sEnvVar(containerEnvVars), tCtx.TaskExecutionMetadata().GetTaskExecutionID())
m := make(map[string]string, len(envVars))
for _, envVar := range envVars {
m[envVar.Name] = envVar.Value
}

for key, value := range defaultEnvVars {
envVars = append(envVars, v1.EnvVar{
m[key] = value
}

finalEnvVars := make([]v1.EnvVar, 0, len(m))
for key, val := range m {
finalEnvVars = append(envVars, v1.EnvVar{
Name: key,
Value: value,
Value: val,
})
}

return envVars
return finalEnvVars
}

func toEnvironmentVariables(_ context.Context, envVars []v1.EnvVar) []*batch.KeyValuePair {
Expand Down

0 comments on commit 507218d

Please sign in to comment.