mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-26 14:28:04 +00:00
Added greater granularity for boolean environment variables (#511)
* Added greater granularity for boolean environment variables * Improved solution as reviewed
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -116,3 +117,13 @@ func GetQueryProps(c *gin.Context) (*QueryProps, error) {
|
||||
|
||||
return &qp, nil
|
||||
}
|
||||
|
||||
func EnvAsBool(envKey string, envDef bool) bool {
|
||||
validSettableValues := []string{"false", "true", "0", "1"}
|
||||
envValue := os.Getenv(envKey)
|
||||
if slices.Contains(validSettableValues, envValue) {
|
||||
return envValue == "true" || envValue == "1"
|
||||
} else {
|
||||
return envDef
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user