Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profile option to RunBuilder in test helper #3761

Merged
merged 2 commits into from
Mar 1, 2020
Merged
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
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