mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
7f4fb34182
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.
34 lines
729 B
Go
34 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)
|
|
}
|