[##] Fix of receiving VHS namespaces map
Some checks failed
/ DCO (pull_request) Failing after 51s
/ Vulncheck (pull_request) Successful in 1m13s
/ Builds (pull_request) Successful in 1m25s
/ Lint (pull_request) Successful in 2m23s
/ Tests (pull_request) Successful in 1m26s

In the process of forming a map with namespaces
for which VHS is enabled, we resolve the alias
of the namespace. The problem is that to resolve,
we need default namespace names, which in turn do
not have time to decide by this time. Therefore,
the receipt of a card with VHS namespaces must
be postponed after reading the default names for
the namespace.

Signed-off-by: Roman Loginov <r.loginov@yadro.com>
This commit is contained in:
Roman Loginov 2024-09-16 13:43:07 +03:00
parent a0aba8bcb1
commit 4424aeeb71

View file

@ -253,7 +253,6 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) {
vhsEnabled := v.GetBool(cfgVHSEnabled) vhsEnabled := v.GetBool(cfgVHSEnabled)
vhsHeader := v.GetString(cfgVHSHeader) vhsHeader := v.GetString(cfgVHSHeader)
servernameHeader := v.GetString(cfgServernameHeader) servernameHeader := v.GetString(cfgServernameHeader)
vhsNamespacesEnabled := s.prepareVHSNamespaces(v, log)
httpLoggingEnabled := v.GetBool(cfgHTTPLoggingEnabled) httpLoggingEnabled := v.GetBool(cfgHTTPLoggingEnabled)
httpLoggingMaxBody := v.GetInt64(cfgHTTPLoggingMaxBody) httpLoggingMaxBody := v.GetInt64(cfgHTTPLoggingMaxBody)
httpLoggingMaxLogSize := v.GetInt(cfgHTTPLoggingMaxLogSize) httpLoggingMaxLogSize := v.GetInt(cfgHTTPLoggingMaxLogSize)
@ -261,7 +260,6 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) {
httpLoggingUseGzip := v.GetBool(cfgHTTPLoggingGzip) httpLoggingUseGzip := v.GetBool(cfgHTTPLoggingGzip)
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock()
s.httpLogging.Enabled = httpLoggingEnabled s.httpLogging.Enabled = httpLoggingEnabled
s.httpLogging.MaxBody = httpLoggingMaxBody s.httpLogging.MaxBody = httpLoggingMaxBody
@ -287,17 +285,22 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) {
s.vhsEnabled = vhsEnabled s.vhsEnabled = vhsEnabled
s.vhsHeader = vhsHeader s.vhsHeader = vhsHeader
s.servernameHeader = servernameHeader s.servernameHeader = servernameHeader
s.vhsNamespacesEnabled = vhsNamespacesEnabled
s.mu.Unlock()
s.prepareVHSNamespaces(v, log)
} }
func (s *appSettings) prepareVHSNamespaces(v *viper.Viper, log *zap.Logger) map[string]bool { func (s *appSettings) prepareVHSNamespaces(v *viper.Viper, log *zap.Logger) {
nsMap := fetchVHSNamespaces(v, log) nsMap := fetchVHSNamespaces(v, log)
vhsNamespaces := make(map[string]bool, len(nsMap)) vhsNamespaces := make(map[string]bool, len(nsMap))
for ns, flag := range nsMap { for ns, flag := range nsMap {
vhsNamespaces[s.ResolveNamespaceAlias(ns)] = flag vhsNamespaces[s.ResolveNamespaceAlias(ns)] = flag
} }
return vhsNamespaces s.mu.Lock()
s.vhsNamespacesEnabled = vhsNamespaces
s.mu.Unlock()
} }
func (s *appSettings) Domains() []string { func (s *appSettings) Domains() []string {