admin update: Add a prompt for confirmation (#4400)

This commit is contained in:
Anis Elleuch
2022-12-12 07:10:12 -08:00
committed by GitHub
parent daa06599e4
commit 97beb1108d
+14
View File
@@ -18,7 +18,10 @@
package cmd
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/fatih/color"
"github.com/minio/cli"
@@ -103,6 +106,17 @@ func mainAdminServerUpdate(ctx *cli.Context) error {
updateURL := args.Get(1)
if isTerminal() {
fmt.Printf("You are about to upgrade *MinIO Server*, please confirm [y/N]: ")
answer, e := bufio.NewReader(os.Stdin).ReadString('\n')
fatalIf(probe.NewError(e), "Unable to parse user input.")
answer = strings.TrimSpace(answer)
if answer = strings.ToLower(answer); answer != "y" && answer != "yes" {
fmt.Println("Upgrade aborted!")
return nil
}
}
// Update the specified MinIO server, optionally also
// with the provided update URL.
us, e := client.ServerUpdate(globalContext, updateURL)