Skip to content

Commit

Permalink
krel/announce: ask for confirmation before sending the email
Browse files Browse the repository at this point in the history
The changes preserve the existing behavior when --nomock is not passed.
Only when, --nomock is passed, a confirmation is seeked.

Signed-off-by: Nabarun Pal <[email protected]>
  • Loading branch information
palnabarun committed Nov 15, 2021
1 parent 365489a commit 7e4ed4a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/krel/cmd/announce_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,20 @@ func runAnnounce(opts *sendAnnounceOptions, announceRootOpts *announceOptions, r

logrus.Info("Sending mail")
subject := fmt.Sprintf("Kubernetes %s is live!", tag)
if err := m.Send(content, subject); err != nil {
return errors.Wrap(err, "unable to send mail")

yes := true

if rootOpts.nomock {
_, yes, err = util.Ask(fmt.Sprintf("%s (Y/n)", "Send email?"), "y:Y:yes|n:N:no|y", 10)
if err != nil {
return err
}
}

if yes {
if err := m.Send(content, subject); err != nil {
return errors.Wrap(err, "unable to send mail")
}
}

return nil
Expand Down

0 comments on commit 7e4ed4a

Please sign in to comment.