mirror of
https://github.com/minio/minio.git
synced 2025-11-20 18:06:10 -05:00
Support in-place upgrades of new minio binary and releases. (#4961)
This PR allows 'minio update' to not only shows update banner but also allows for in-place upgrades. Updates are done safely by validating the downloaded sha256 of the binary. Fixes #4781
This commit is contained in:
committed by
Dee Koder
parent
8c08571cd9
commit
eb7c690ea9
94
vendor/github.com/segmentio/go-prompt/prompt.go
generated
vendored
Normal file
94
vendor/github.com/segmentio/go-prompt/prompt.go
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
package prompt
|
||||
|
||||
import "github.com/howeyc/gopass"
|
||||
import "strings"
|
||||
import "strconv"
|
||||
import "fmt"
|
||||
|
||||
// String prompt.
|
||||
func String(prompt string, args ...interface{}) string {
|
||||
var s string
|
||||
fmt.Printf(prompt+": ", args...)
|
||||
fmt.Scanln(&s)
|
||||
return s
|
||||
}
|
||||
|
||||
// String prompt (required).
|
||||
func StringRequired(prompt string, args ...interface{}) (s string) {
|
||||
for strings.Trim(s, " ") == "" {
|
||||
s = String(prompt, args...)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Confirm continues prompting until the input is boolean-ish.
|
||||
func Confirm(prompt string, args ...interface{}) bool {
|
||||
for {
|
||||
switch String(prompt, args...) {
|
||||
case "Yes", "yes", "y", "Y":
|
||||
return true
|
||||
case "No", "no", "n", "N":
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Choose prompts for a single selection from `list`, returning in the index.
|
||||
func Choose(prompt string, list []string) int {
|
||||
fmt.Println()
|
||||
for i, val := range list {
|
||||
fmt.Printf(" %d) %s\n", i+1, val)
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
i := -1
|
||||
|
||||
for {
|
||||
s := String(prompt)
|
||||
|
||||
// index
|
||||
n, err := strconv.Atoi(s)
|
||||
if err == nil {
|
||||
if n > 0 && n <= len(list) {
|
||||
i = n - 1
|
||||
break
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// value
|
||||
i = indexOf(s, list)
|
||||
if i != -1 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
// Password prompt.
|
||||
func Password(prompt string, args ...interface{}) string {
|
||||
fmt.Printf(prompt+": ", args...)
|
||||
password, _ := gopass.GetPasswd()
|
||||
s := string(password[0:])
|
||||
return s
|
||||
}
|
||||
|
||||
// Password prompt with mask.
|
||||
func PasswordMasked(prompt string, args ...interface{}) string {
|
||||
fmt.Printf(prompt+": ", args...)
|
||||
password, _ := gopass.GetPasswdMasked()
|
||||
s := string(password[0:])
|
||||
return s
|
||||
}
|
||||
|
||||
// index of `s` in `list`.
|
||||
func indexOf(s string, list []string) int {
|
||||
for i, val := range list {
|
||||
if val == s {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
Reference in New Issue
Block a user