@ -30,7 +30,6 @@ import (
"strings"
"strings"
"time"
"time"
"github.com/fatih/color"
"github.com/inconshreveable/go-update"
"github.com/inconshreveable/go-update"
"github.com/minio/cli"
"github.com/minio/cli"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/cmd/logger"
@ -458,7 +457,7 @@ func getUpdateInfo(timeout time.Duration, mode string) (updateMsg string, sha256
func doUpdate ( sha256Hex string , latestReleaseTime time . Time , ok bool ) ( updateStatusMsg string , err error ) {
func doUpdate ( sha256Hex string , latestReleaseTime time . Time , ok bool ) ( updateStatusMsg string , err error ) {
if ! ok {
if ! ok {
updateStatusMsg = greenColorSprintf ( "Minio update to version RELEASE.%s canceled." ,
updateStatusMsg = colorGreenBold ( "Minio update to version RELEASE.%s canceled." ,
latestReleaseTime . Format ( minioReleaseTagTimeLayout ) )
latestReleaseTime . Format ( minioReleaseTagTimeLayout ) )
return updateStatusMsg , nil
return updateStatusMsg , nil
}
}
@ -484,21 +483,18 @@ func doUpdate(sha256Hex string, latestReleaseTime time.Time, ok bool) (updateSta
return updateStatusMsg , err
return updateStatusMsg , err
}
}
return greenColorSprintf ( "Minio updated to version RELEASE.%s successfully." ,
return colorGreenBold ( "Minio updated to version RELEASE.%s successfully." ,
latestReleaseTime . Format ( minioReleaseTagTimeLayout ) ) , nil
latestReleaseTime . Format ( minioReleaseTagTimeLayout ) ) , nil
}
}
func shouldUpdate ( quiet bool , sha256Hex string , latestReleaseTime time . Time ) ( ok bool ) {
func shouldUpdate ( quiet bool , sha256Hex string , latestReleaseTime time . Time ) ( ok bool ) {
ok = true
ok = true
if ! quiet {
if ! quiet {
ok = prompt . Confirm ( greenColorSprintf ( "Update to RELEASE.%s [%s]" , latestReleaseTime . Format ( minioReleaseTagTimeLayout ) , "yes" ) )
ok = prompt . Confirm ( colorGreenBold ( "Update to RELEASE.%s [%s]" , latestReleaseTime . Format ( minioReleaseTagTimeLayout ) , "yes" ) )
}
}
return ok
return ok
}
}
var greenColorSprintf = color . New ( color . FgGreen , color . Bold ) . SprintfFunc ( )
var redColorSprintf = color . New ( color . FgRed , color . Bold ) . SprintfFunc ( )
func mainUpdate ( ctx * cli . Context ) {
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 )
@ -520,7 +516,7 @@ func mainUpdate(ctx *cli.Context) {
// Nothing to update running the latest release.
// Nothing to update running the latest release.
if updateMsg == "" {
if updateMsg == "" {
logger . Info ( greenColorSprintf ( "You are already running the most recent version of ‘minio’." ) )
logger . Info ( colorGreenBold ( "You are already running the most recent version of ‘minio’." ) )
os . Exit ( 0 )
os . Exit ( 0 )
}
}
@ -531,7 +527,7 @@ func mainUpdate(ctx *cli.Context) {
var updateStatusMsg string
var updateStatusMsg string
updateStatusMsg , err = doUpdate ( sha256Hex , latestReleaseTime , shouldUpdate ( quiet , sha256Hex , latestReleaseTime ) )
updateStatusMsg , err = doUpdate ( sha256Hex , latestReleaseTime , shouldUpdate ( quiet , sha256Hex , latestReleaseTime ) )
if err != nil {
if err != nil {
logger . Info ( redColorSprintf ( "Unable to update ‘minio’." ) )
logger . Info ( colorRedBold ( "Unable to update ‘minio’." ) )
logger . Info ( err . Error ( ) )
logger . Info ( err . Error ( ) )
os . Exit ( - 1 )
os . Exit ( - 1 )
}
}