[#493] Fix of receiving VHS namespaces map
All checks were successful
/ DCO (pull_request) Successful in 48s
/ Vulncheck (pull_request) Successful in 1m18s
/ Builds (pull_request) Successful in 1m25s
/ Lint (pull_request) Successful in 2m23s
/ Tests (pull_request) Successful in 1m25s

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 7cb36ec3ec
commit 57dc2e4bbf

View file

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