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

Allow fastforward to run non-interactive #2516

Merged
merged 1 commit into from
May 5, 2022
Merged
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
1 change: 1 addition & 0 deletions pkg/fastforward/fastforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (f *FastForward) Run() (err error) {
options := gcb.NewDefaultOptions()
options.FastForward = true
options.NoMock = f.options.NoMock
options.NonInteractive = f.options.NonInteractive
options.Stream = true
options.Project = f.options.GCPProjectID
options.ScratchBucket = "gs://" + f.options.GCPProjectID + "-gcb"
Expand Down
26 changes: 17 additions & 9 deletions pkg/gcp/gcb/gcb.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (g *GCB) SetReleaseClient(client Release) {

type Options struct {
build.Options

// NonInteractive does not ask any questions if set to true.
NonInteractive bool

NoMock bool
Stage bool
Release bool
Expand Down Expand Up @@ -219,17 +223,21 @@ func (g *GCB) Submit() error {
}

if g.options.NoMock {
// TODO: Consider a '--yes' flag so we can mock this
_, nomockSubmit, askErr := util.Ask(
fmt.Sprintf("Really submit a --nomock release job against the %s branch? (yes/no)", g.options.Branch),
"yes",
3,
)
if askErr != nil {
return askErr
submit := true

if !g.options.NonInteractive {
var err error
_, submit, err = util.Ask(
fmt.Sprintf("Really submit a --nomock release job against the %s branch? (yes/no)", g.options.Branch),
"yes",
3,
)
if err != nil {
return err
}
}

if nomockSubmit {
if submit {
gcbSubs["NOMOCK_TAG"] = "nomock"
gcbSubs["NOMOCK"] = fmt.Sprintf("--%s", gcbSubs["NOMOCK_TAG"])
}
Expand Down