ask for pass if missing or use env pass, add token support (#60)

This commit is contained in:
T. von Dein
2026-07-01 10:58:39 +02:00
parent f5c8a23589
commit 6436bcfb22
6 changed files with 258 additions and 171 deletions

View File

@@ -28,7 +28,7 @@ import (
)
const (
Version string = `v0.0.23`
Version string = `v0.0.24`
)
var (
@@ -213,18 +213,17 @@ func (conf *Config) PrintDebug() {
func (conf *Config) LoadEnv() error {
cluster := Cluster{
Uri: os.Getenv("ES_URI"),
User: os.Getenv("ES_USER"),
Pass: os.Getenv("ES_PASS"),
Uri: os.Getenv("ES_URI"),
User: os.Getenv("ES_USER"),
Pass: os.Getenv("ES_PASS"),
Token: os.Getenv("ES_TOKEN"),
}
switch {
case cluster.Uri == "":
return errors.New("ES_URI unset")
case cluster.User == "":
return errors.New("ES_USER unset")
case cluster.Pass == "":
return errors.New("ES_PASS unset")
case cluster.User == "" || cluster.Token == "":
return errors.New("ES_USER and ES_TOKEN unset")
}
conf.Clusters["default"] = &cluster