mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 13:38:15 -08:00
fix: include time zone name overrides and add KOITO_FORCE_TZ cfg option (#176)
* timezone overrides and force_tz option * docs for force_tz * add link to time zone names in docs
This commit is contained in:
parent
1ed055d098
commit
937f9062b5
4 changed files with 153 additions and 1 deletions
|
|
@ -49,6 +49,7 @@ const (
|
|||
FETCH_IMAGES_DURING_IMPORT_ENV = "KOITO_FETCH_IMAGES_DURING_IMPORT"
|
||||
ARTIST_SEPARATORS_ENV = "KOITO_ARTIST_SEPARATORS_REGEX"
|
||||
LOGIN_GATE_ENV = "KOITO_LOGIN_GATE"
|
||||
FORCE_TZ = "KOITO_FORCE_TZ"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
|
|
@ -87,6 +88,7 @@ type config struct {
|
|||
importAfter time.Time
|
||||
artistSeparators []*regexp.Regexp
|
||||
loginGate bool
|
||||
forceTZ *time.Location
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -213,6 +215,13 @@ func loadConfig(getenv func(string) string, version string) (*config, error) {
|
|||
cfg.loginGate = true
|
||||
}
|
||||
|
||||
if getenv(FORCE_TZ) != "" {
|
||||
cfg.forceTZ, err = time.LoadLocation(getenv(FORCE_TZ))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("forced timezone '%s' is not a valid timezone", getenv(FORCE_TZ))
|
||||
}
|
||||
}
|
||||
|
||||
switch strings.ToLower(getenv(LOG_LEVEL_ENV)) {
|
||||
case "debug":
|
||||
cfg.logLevel = 0
|
||||
|
|
@ -430,3 +439,9 @@ func LoginGate() bool {
|
|||
defer lock.RUnlock()
|
||||
return globalConfig.loginGate
|
||||
}
|
||||
|
||||
func ForceTZ() *time.Location {
|
||||
lock.RLock()
|
||||
defer lock.RUnlock()
|
||||
return globalConfig.forceTZ
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue