From 05077735f59ec3027c365aeeb270ddc78727ce14 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Tue, 12 Nov 2019 14:36:47 -0300 Subject: [PATCH] 15642: Fixes legacy config loading for keep-web. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- lib/config/deprecated.go | 77 +++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/lib/config/deprecated.go b/lib/config/deprecated.go index 7b11e090ee..f1714fa0b9 100644 --- a/lib/config/deprecated.go +++ b/lib/config/deprecated.go @@ -370,27 +370,27 @@ const defaultKeepWebConfigPath = "/etc/arvados/keep-web/keep-web.yml" type oldKeepWebConfig struct { Client *arvados.Client - Listen string + Listen *string - AnonymousTokens []string - AttachmentOnlyHost string - TrustAllContent bool + AnonymousTokens *[]string + AttachmentOnlyHost *string + TrustAllContent *bool Cache struct { - TTL arvados.Duration - UUIDTTL arvados.Duration - MaxCollectionEntries int - MaxCollectionBytes int64 - MaxPermissionEntries int - MaxUUIDEntries int + TTL *arvados.Duration + UUIDTTL *arvados.Duration + MaxCollectionEntries *int + MaxCollectionBytes *int64 + MaxPermissionEntries *int + MaxUUIDEntries *int } // Hack to support old command line flag, which is a bool // meaning "get actual token from environment". - deprecatedAllowAnonymous bool + deprecatedAllowAnonymous *bool // Authorization token to be included in all health check requests. - ManagementToken string + ManagementToken *string } func (ldr *Loader) loadOldKeepWebConfig(cfg *arvados.Config) error { @@ -412,22 +412,43 @@ func (ldr *Loader) loadOldKeepWebConfig(cfg *arvados.Config) error { loadOldClientConfig(cluster, oc.Client) - cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: oc.Listen}] = arvados.ServiceInstance{} - cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: oc.Listen}] = arvados.ServiceInstance{} - cluster.Services.WebDAVDownload.ExternalURL = arvados.URL{Host: oc.AttachmentOnlyHost} - cluster.TLS.Insecure = oc.Client.Insecure - cluster.ManagementToken = oc.ManagementToken - cluster.Collections.TrustAllContent = oc.TrustAllContent - cluster.Collections.WebDAVCache.TTL = oc.Cache.TTL - cluster.Collections.WebDAVCache.UUIDTTL = oc.Cache.UUIDTTL - cluster.Collections.WebDAVCache.MaxCollectionEntries = oc.Cache.MaxCollectionEntries - cluster.Collections.WebDAVCache.MaxCollectionBytes = oc.Cache.MaxCollectionBytes - cluster.Collections.WebDAVCache.MaxPermissionEntries = oc.Cache.MaxPermissionEntries - cluster.Collections.WebDAVCache.MaxUUIDEntries = oc.Cache.MaxUUIDEntries - if len(oc.AnonymousTokens) > 0 { - cluster.Users.AnonymousUserToken = oc.AnonymousTokens[0] - if len(oc.AnonymousTokens) > 1 { - ldr.Logger.Warn("More than 1 anonymous tokens configured, using only the first and discarding the rest.") + if oc.Listen != nil { + cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: *oc.Listen}] = arvados.ServiceInstance{} + cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: *oc.Listen}] = arvados.ServiceInstance{} + } + if oc.AttachmentOnlyHost != nil { + cluster.Services.WebDAVDownload.ExternalURL = arvados.URL{Host: *oc.AttachmentOnlyHost} + } + if oc.ManagementToken != nil { + cluster.ManagementToken = *oc.ManagementToken + } + if oc.TrustAllContent != nil { + cluster.Collections.TrustAllContent = *oc.TrustAllContent + } + if oc.Cache.TTL != nil { + cluster.Collections.WebDAVCache.TTL = *oc.Cache.TTL + } + if oc.Cache.UUIDTTL != nil { + cluster.Collections.WebDAVCache.UUIDTTL = *oc.Cache.UUIDTTL + } + if oc.Cache.MaxCollectionEntries != nil { + cluster.Collections.WebDAVCache.MaxCollectionEntries = *oc.Cache.MaxCollectionEntries + } + if oc.Cache.MaxCollectionBytes != nil { + cluster.Collections.WebDAVCache.MaxCollectionBytes = *oc.Cache.MaxCollectionBytes + } + if oc.Cache.MaxPermissionEntries != nil { + cluster.Collections.WebDAVCache.MaxPermissionEntries = *oc.Cache.MaxPermissionEntries + } + if oc.Cache.MaxUUIDEntries != nil { + cluster.Collections.WebDAVCache.MaxUUIDEntries = *oc.Cache.MaxUUIDEntries + } + if oc.AnonymousTokens != nil { + if len(*oc.AnonymousTokens) > 0 { + cluster.Users.AnonymousUserToken = (*oc.AnonymousTokens)[0] + if len(*oc.AnonymousTokens) > 1 { + ldr.Logger.Warn("More than 1 anonymous tokens configured, using only the first and discarding the rest.") + } } } -- 2.30.2