diff --git a/pkg/skaffold/schema/profiles.go b/pkg/skaffold/schema/profiles.go index feaec4eea19..9fd467b4dec 100644 --- a/pkg/skaffold/schema/profiles.go +++ b/pkg/skaffold/schema/profiles.go @@ -105,6 +105,7 @@ func activatedProfiles(profiles []latest.Profile, opts cfg.SkaffoldOptions) ([]s contextSpecificProfiles = append(contextSpecificProfiles, profile.Name) } activated = append(activated, profile.Name) + break } } } @@ -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) } } diff --git a/pkg/skaffold/schema/profiles_test.go b/pkg/skaffold/schema/profiles_test.go index 1705458f032..bcafd189935 100644 --- a/pkg/skaffold/schema/profiles_test.go +++ b/pkg/skaffold/schema/profiles_test.go @@ -555,6 +555,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"},