MCPcopy Index your code
hub / github.com/dreamsofcode-io/zenstats / loadPassword

Function loadPassword

internal/config/database.go:21–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19}
20
21func loadPassword() (string, error) {
22 password, ok := os.LookupEnv("POSTGRES_PASSWORD")
23 if ok {
24 return password, nil
25 }
26
27 passwordFile, ok := os.LookupEnv("POSTGRES_PASSWORD_FILE")
28 if !ok {
29 return "", fmt.Errorf("no POSTGRES_PASSWORD or POSTGRES_PASSWORD_FILE env var set")
30 }
31
32 data, err := os.ReadFile(passwordFile)
33 if err != nil {
34 return "", fmt.Errorf("failed to read from password file: %w", err)
35 }
36
37 return strings.TrimSpace(string(data)), nil
38}
39
40// NewDatabase creates a database configuration based on the environment
41// variables required. If any env variables are not set or are invalid then

Callers 1

NewDatabaseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected