Skip to content

Commit

Permalink
Add profile option to RunBuilder in test helper (#3761)
Browse files Browse the repository at this point in the history
* Add profile option to RunBuilder in test helper

* Update integration/skaffold/helper.go

Co-Authored-By: David Gageot <[email protected]>

Co-authored-by: David Gageot <[email protected]>
  • Loading branch information
loosebazooka and dgageot authored Mar 1, 2020
1 parent a9c7b3a commit 54c9796
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions integration/skaffold/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type RunBuilder struct {
dir string
ns string
repo string
profiles []string
args []string
env []string
stdin []byte
Expand Down Expand Up @@ -150,6 +151,12 @@ func (b *RunBuilder) WithEnv(env []string) *RunBuilder {
return b
}

// WithProfiles sets profiles.
func (b *RunBuilder) WithProfiles(profiles []string) *RunBuilder {
b.profiles = profiles
return b
}

// RunBackground runs the skaffold command in the background.
// Returns a teardown function that stops skaffold.
func (b *RunBuilder) RunBackground(t *testing.T) context.CancelFunc {
Expand Down Expand Up @@ -262,6 +269,9 @@ func (b *RunBuilder) cmd(ctx context.Context) *exec.Cmd {
if b.repo != "" && command.Flags().Lookup("default-repo") != nil {
args = append(args, "--default-repo", b.repo)
}
if len(b.profiles) > 0 && command.Flags().Lookup("profile") != nil {
args = append(args, "--profile", strings.Join(b.profiles, ","))
}
args = append(args, b.args...)

cmd := exec.CommandContext(ctx, "skaffold", args...)
Expand Down

0 comments on commit 54c9796

Please sign in to comment.