ef70992657
Signed-off-by: Michael Mayer <michael@photoprism.app>
34 lines
691 B
Go
34 lines
691 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/photoprism/photoprism/pkg/list"
|
|
)
|
|
|
|
// Environment names.
|
|
const (
|
|
EnvUnsafe = "unsafe"
|
|
EnvDebug = "debug"
|
|
EnvTrace = "trace"
|
|
EnvDemo = "demo"
|
|
EnvSponsor = "sponsor"
|
|
EnvTest = "test"
|
|
)
|
|
|
|
// EnvVar returns the name of the environment variable for the specified config flag.
|
|
func EnvVar(flag string) string {
|
|
return "PHOTOPRISM_" + strings.ToUpper(strings.ReplaceAll(flag, "-", "_"))
|
|
}
|
|
|
|
// Env checks the presence of environment and command-line flags.
|
|
func Env(vars ...string) bool {
|
|
for _, s := range vars {
|
|
if os.Getenv(EnvVar(s)) == "true" || list.Contains(os.Args, "--"+s) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|