mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
d5c180e680
It is better developing vmctl tool in VictoriaMetrics repository, so it could be released together with the rest of vmutils tools such as vmalert, vmagent, vmbackup, vmrestore and vmauth.
33 lines
729 B
Go
33 lines
729 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmctl/vm"
|
|
)
|
|
|
|
func prompt(question string) bool {
|
|
reader := bufio.NewReader(os.Stdin)
|
|
fmt.Print(question, " [Y/n] ")
|
|
answer, err := reader.ReadString('\n')
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
answer = strings.TrimSpace(strings.ToLower(answer))
|
|
if answer == "" || answer == "yes" || answer == "y" {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func wrapErr(vmErr *vm.ImportError) error {
|
|
var errTS string
|
|
for _, ts := range vmErr.Batch {
|
|
errTS += fmt.Sprintf("%s for timestamps range %d - %d\n",
|
|
ts.String(), ts.Timestamps[0], ts.Timestamps[len(ts.Timestamps)-1])
|
|
}
|
|
return fmt.Errorf("%s with error: %s", errTS, vmErr.Err)
|
|
}
|