common

package
v0.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandStart              = ""
	CommandValidate           = "validate"
	CommandListConfigs        = "ls-config"
	CommandListRoutes         = "ls-routes"
	CommandListIcons          = "ls-icons"
	CommandReload             = "reload"
	CommandDebugListEntries   = "debug-ls-entries"
	CommandDebugListProviders = "debug-ls-providers"
	CommandDebugListMTrace    = "debug-ls-mtrace"
)
View Source
const (
	DotEnvPath        = ".env"
	DotEnvExamplePath = ".env.example"

	ConfigBasePath        = "config"
	ConfigFileName        = "config.yml"
	ConfigExampleFileName = "config.example.yml"
	ConfigPath            = ConfigBasePath + "/" + ConfigFileName

	IconListCachePath = ConfigBasePath + "/.icon_list_cache.json"
	IconCachePath     = ConfigBasePath + "/.icon_cache.json"

	NamespaceHomepageOverrides = ".homepage"
	NamespaceIconCache         = ".icon_cache"

	MiddlewareComposeBasePath = ConfigBasePath + "/middlewares"

	ComposeFileName        = "compose.yml"
	ComposeExampleFileName = "compose.example.yml"

	DataDir = "data"

	ErrorPagesBasePath = "error_pages"
)
View Source
const (
	HealthCheckIntervalDefault = 5 * time.Second
	HealthCheckTimeoutDefault  = 5 * time.Second

	WakeTimeoutDefault = "3m"
	StopTimeoutDefault = "3m"
	StopMethodDefault  = "stop"
)
View Source
const DockerHostFromEnv = "$DOCKER_HOST"

Variables

View Source
var (
	IsTest  = GetEnvBool("TEST", false) || strings.HasSuffix(os.Args[0], ".test")
	IsDebug = GetEnvBool("DEBUG", IsTest)
	IsTrace = GetEnvBool("TRACE", false) && IsDebug

	HTTP3Enabled = GetEnvBool("HTTP3_ENABLED", true)

	ProxyHTTPAddr,
	ProxyHTTPHost,
	ProxyHTTPPort,
	ProxyHTTPURL = GetAddrEnv("HTTP_ADDR", ":80", "http")

	ProxyHTTPSAddr,
	ProxyHTTPSHost,
	ProxyHTTPSPort,
	ProxyHTTPSURL = GetAddrEnv("HTTPS_ADDR", ":443", "https")

	APIHTTPAddr,
	APIHTTPHost,
	APIHTTPPort,
	APIHTTPURL = GetAddrEnv("API_ADDR", "127.0.0.1:8888", "http")

	APIJWTSecure   = GetEnvBool("API_JWT_SECURE", true)
	APIJWTSecret   = decodeJWTKey(GetEnvString("API_JWT_SECRET", ""))
	APIJWTTokenTTL = GetDurationEnv("API_JWT_TOKEN_TTL", 24*time.Hour)
	APIUser        = GetEnvString("API_USER", "admin")
	APIPassword    = GetEnvString("API_PASSWORD", "password")

	DebugDisableAuth = GetEnvBool("DEBUG_DISABLE_AUTH", false)

	// OIDC Configuration.
	OIDCIssuerURL     = GetEnvString("OIDC_ISSUER_URL", "")
	OIDCClientID      = GetEnvString("OIDC_CLIENT_ID", "")
	OIDCClientSecret  = GetEnvString("OIDC_CLIENT_SECRET", "")
	OIDCScopes        = GetCommaSepEnv("OIDC_SCOPES", "openid, profile, email, groups")
	OIDCAllowedUsers  = GetCommaSepEnv("OIDC_ALLOWED_USERS", "")
	OIDCAllowedGroups = GetCommaSepEnv("OIDC_ALLOWED_GROUPS", "")

	// metrics configuration
	MetricsDisableCPU     = GetEnvBool("METRICS_DISABLE_CPU", false)
	MetricsDisableMemory  = GetEnvBool("METRICS_DISABLE_MEMORY", false)
	MetricsDisableDisk    = GetEnvBool("METRICS_DISABLE_DISK", false)
	MetricsDisableNetwork = GetEnvBool("METRICS_DISABLE_NETWORK", false)
	MetricsDisableSensors = GetEnvBool("METRICS_DISABLE_SENSORS", false)
)

Functions

func GetAddrEnv

func GetAddrEnv(key, defaultValue, scheme string) (addr, host string, portInt int, fullURL string)

func GetCommaSepEnv

func GetCommaSepEnv(key string, defaultValue string) []string

func GetDurationEnv

func GetDurationEnv(key string, defaultValue time.Duration) time.Duration

func GetEnv

func GetEnv[T any](key string, defaultValue T, parser func(string) (T, error)) T

func GetEnvBool

func GetEnvBool(key string, defaultValue bool) bool

func GetEnvInt added in v0.10.0

func GetEnvInt(key string, defaultValue int) int

func GetEnvString

func GetEnvString(key string, defaultValue string) string

func RandomJWTKey added in v0.10.0

func RandomJWTKey() []byte

Types

type MainServerCommandValidator added in v0.10.0

type MainServerCommandValidator struct{}

func (MainServerCommandValidator) IsCommandValid added in v0.10.0

func (v MainServerCommandValidator) IsCommandValid(cmd string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL