Skip to content

Commit

Permalink
Profile with multiple activations should be processed only once. (#5182)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsquared94 authored Dec 23, 2020
1 parent ef6ec47 commit a518ce7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/skaffold/schema/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func activatedProfiles(profiles []latest.Profile, opts cfg.SkaffoldOptions) ([]s
contextSpecificProfiles = append(contextSpecificProfiles, profile.Name)
}
activated = append(activated, profile.Name)
break
}
}
}
Expand All @@ -113,7 +114,7 @@ func activatedProfiles(profiles []latest.Profile, opts cfg.SkaffoldOptions) ([]s
for _, profile := range opts.Profiles {
if strings.HasPrefix(profile, "-") {
activated = removeValue(activated, strings.TrimPrefix(profile, "-"))
} else {
} else if !skutil.StrSliceContains(activated, profile) {
activated = append(activated, profile)
}
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/skaffold/schema/profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,20 @@ func TestActivatedProfiles(t *testing.T) {
{Name: "regex-activated-substring-match", Activation: []latest.Activation{{Env: "KEY=^VAL"}}},
},
expected: []string{"activated", "also-activated", "regex-activated", "regex-activated-two", "regex-activated-substring-match"},
}, {
description: "Profile with multiple valid activations",
envs: map[string]string{"KEY": "VALUE"},
opts: cfg.SkaffoldOptions{
ProfileAutoActivation: true,
Command: "dev",
Profiles: []string{"activated", "also-activated"},
},
profiles: []latest.Profile{
{Name: "activated", Activation: []latest.Activation{{Env: "KEY=VALUE"}, {Command: "dev"}}},
{Name: "not-activated", Activation: []latest.Activation{{Env: "KEY=OTHER"}}},
{Name: "also-activated", Activation: []latest.Activation{{Env: "KEY=!OTHER"}}},
},
expected: []string{"activated", "also-activated"},
}, {
description: "Invalid env variable",
envs: map[string]string{"KEY": "VALUE"},
Expand Down

0 comments on commit a518ce7

Please sign in to comment.