Exitcode with '1' when update is available (#5354)

--quiet should simply update the binary without any prompt.

Fixes #5347
master
Harshavardhana 7 years ago committed by Nitish Tiwari
parent 1e5fb4b79a
commit cc2497f52f
  1. 10
      cmd/update-main.go

@ -44,7 +44,7 @@ var updateCmd = cli.Command{
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: "quiet", Name: "quiet",
Usage: "Disable any update messages.", Usage: "Disable any update prompt message.",
}, },
}, },
CustomHelpTemplate: `Name: CustomHelpTemplate: `Name:
@ -63,7 +63,7 @@ EXIT STATUS:
EXAMPLES: EXAMPLES:
1. Check and update minio: 1. Check and update minio:
$ {{.HelpName} $ {{.HelpName}}
`, `,
} }
@ -476,7 +476,7 @@ func shouldUpdate(quiet bool, sha256Hex string, latestReleaseTime time.Time) (ok
var greenColorSprintf = color.New(color.FgGreen, color.Bold).SprintfFunc() var greenColorSprintf = color.New(color.FgGreen, color.Bold).SprintfFunc()
func mainUpdate(ctx *cli.Context) error { func mainUpdate(ctx *cli.Context) {
if len(ctx.Args()) != 0 { if len(ctx.Args()) != 0 {
cli.ShowCommandHelpAndExit(ctx, "update", -1) cli.ShowCommandHelpAndExit(ctx, "update", -1)
} }
@ -498,7 +498,7 @@ func mainUpdate(ctx *cli.Context) error {
// Nothing to update running the latest release. // Nothing to update running the latest release.
if updateMsg == "" { if updateMsg == "" {
log.Println(greenColorSprintf("You are already running the most recent version of ‘minio’.")) log.Println(greenColorSprintf("You are already running the most recent version of ‘minio’."))
return nil os.Exit(0)
} }
log.Println(updateMsg) log.Println(updateMsg)
@ -512,6 +512,6 @@ func mainUpdate(ctx *cli.Context) error {
os.Exit(-1) os.Exit(-1)
} }
log.Println(successMsg) log.Println(successMsg)
os.Exit(1)
} }
return nil
} }

Loading…
Cancel
Save