diff --git a/config/config.go b/config/config.go index acbfb451..b11362b9 100644 --- a/config/config.go +++ b/config/config.go @@ -575,11 +575,8 @@ func ValidateUniqueKeys(config *Config) error { func ValidateSecurityConfig(config *Config) error { if config.Security != nil { - if config.Security.ValidateAndSetDefaults() { + if !config.Security.ValidateAndSetDefaults() { logr.Debug("[config.ValidateSecurityConfig] Basic security configuration has been validated") - } else { - // If there was an attempt to configure security, then it must mean that some confidential or private - // data are exposed. As a result, we'll force a panic because it's better to be safe than sorry. return ErrInvalidSecurityConfig } } diff --git a/config/maintenance/maintenance.go b/config/maintenance/maintenance.go index 72ab5f56..5483d607 100644 --- a/config/maintenance/maintenance.go +++ b/config/maintenance/maintenance.go @@ -31,17 +31,17 @@ var ( // // Uses UTC by default. type Config struct { - Enabled *bool `yaml:"enabled"` // Whether the maintenance period is enabled. Enabled by default if nil. - Start string `yaml:"start"` // Time at which the maintenance period starts (e.g. 23:00) - Duration time.Duration `yaml:"duration"` // Duration of the maintenance period (e.g. 4h) - Timezone string `yaml:"timezone"` // Timezone in string format which the maintenance period is configured (e.g. America/Sao_Paulo) + Enabled *bool `yaml:"enabled"` // Whether the maintenance period is enabled. Enabled by default if nil. + Start string `yaml:"start,omitempty"` // Time at which the maintenance period starts (e.g. 23:00) + Duration time.Duration `yaml:"duration,omitempty"` // Duration of the maintenance period (e.g. 4h) + Timezone string `yaml:"timezone,omitempty"` // Timezone in string format which the maintenance period is configured (e.g. America/Sao_Paulo) // Every is a list of days of the week during which maintenance period applies. // See longDayNames for list of valid values. // Every day if empty. - Every []string `yaml:"every"` + Every []string `yaml:"every,omitempty"` - TimezoneLocation *time.Location // Timezone in location format which the maintenance period is configured + timezoneLocation *time.Location durationToStartFromMidnight time.Duration } @@ -90,13 +90,13 @@ func (c *Config) ValidateAndSetDefaults() error { return errInvalidMaintenanceDuration } if c.Timezone != "" { - c.TimezoneLocation, err = time.LoadLocation(c.Timezone) + c.timezoneLocation, err = time.LoadLocation(c.Timezone) if err != nil { return fmt.Errorf("%w: %w", errInvalidTimezone, err) } } else { c.Timezone = "UTC" - c.TimezoneLocation = time.UTC + c.timezoneLocation = time.UTC } return nil } @@ -107,8 +107,8 @@ func (c *Config) IsUnderMaintenance() bool { return false } now := time.Now() - if c.TimezoneLocation != nil { - now = now.In(c.TimezoneLocation) + if c.timezoneLocation != nil { + now = now.In(c.timezoneLocation) } adjustedDate := now.Day() if now.Hour() < int(c.durationToStartFromMidnight.Hours()) {