VictoriaMetrics/lib/promauth/util.go

25 lines
426 B
Go
Raw Normal View History

package promauth
import (
"io/ioutil"
"path/filepath"
"strings"
"unicode"
)
func getFilepath(baseDir, path string) string {
if filepath.IsAbs(path) {
return path
}
return filepath.Join(baseDir, path)
}
func readPasswordFromFile(path string) (string, error) {
data, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
pass := strings.TrimRightFunc(string(data), unicode.IsSpace)
return pass, nil
}