Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ func (g *Generator) addEnv(env, key string) {
} else {
// else the env doesn't exist, so add it and add it's index to g.envMap
g.Config.Process.Env = append(g.Config.Process.Env, env)
if g.envMap == nil {
g.envMap = map[string]int{}
}
g.envMap[key] = len(g.Config.Process.Env) - 1
}
}
Expand Down
6 changes: 6 additions & 0 deletions generate/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ func TestEnvCaching(t *testing.T) {
}
g.AddProcessEnv("", "")
assert.Equal(t, []string(nil), g.Config.Process.Env)

// Test with nil envMap.
g = generate.Generator{}
expected = []string{"k1=v1"}
g.AddProcessEnv("k1", "v1")
assert.Equal(t, expected, g.Config.Process.Env)
}

func TestMultipleEnvCaching(t *testing.T) {
Expand Down