Skip to content

Commit

Permalink
Merge pull request #2516 from saschagrunert/non-interactive-gcb
Browse files Browse the repository at this point in the history
Allow fastforward to run non-interactive
  • Loading branch information
k8s-ci-robot committed May 5, 2022
2 parents 77c0cb0 + d6d5b77 commit 6797628
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
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

0 comments on commit 6797628

Please sign in to comment.