From 2191bbfee3b42fa425274628591f89ee553bff0e Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Mon, 8 Apr 2024 16:32:41 +0000 Subject: [PATCH 1/3] Move default S3 url style from defaults.yaml to config.go Because we have no way to tell whether defaults in defaults.yaml are user-provided or not, the default there of `Origin.S3UrlStyle` was throwing an error meant to notify users that they have incompatible config variables set. This moves setting of that default into config.go where we now use `viper.SetDefault`, which later on allows us to `viper.IsSet("Origin.S3UrlStyle")` without catching our own default. --- config/config.go | 4 ++++ config/resources/defaults.yaml | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index a7fd67523..81f6fad47 100644 --- a/config/config.go +++ b/config/config.go @@ -983,6 +983,10 @@ func InitServer(ctx context.Context, currentServers ServerType) error { viper.SetDefault("Cache.ExportLocation", "/") viper.SetDefault("Registry.RequireKeyChaining", true) + // Set up the default S3 URL style to be path-style here as opposed to in the defaults.yaml becase + // we want to be able to check if this is user-provided (which we can't do for defaults.yaml) + viper.SetDefault("S3UrlStyle", "path") + if webConfigPath := param.Server_WebConfigFile.GetString(); webConfigPath != "" { err := os.MkdirAll(filepath.Dir(webConfigPath), 0700) if err != nil { diff --git a/config/resources/defaults.yaml b/config/resources/defaults.yaml index 27c04624e..28003418e 100644 --- a/config/resources/defaults.yaml +++ b/config/resources/defaults.yaml @@ -67,7 +67,6 @@ Origin: SelfTest: true Port: 8443 SelfTestInterval: 15s - S3UrlStyle: "path" Registry: InstitutionsUrlReloadMinutes: 15m RequireCacheApproval: false From 916e585289de3b77f623d3a6d788f6fc7559176f Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Mon, 8 Apr 2024 16:44:57 +0000 Subject: [PATCH 2/3] Make mixed config variables non-fatal --- cmd/origin.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/origin.go b/cmd/origin.go index 66ca4ceab..6caefd917 100644 --- a/cmd/origin.go +++ b/cmd/origin.go @@ -60,7 +60,6 @@ var ( // We specifically DON'T want the region, service-url, and url-style flags if the mode is posix if viper.IsSet("Origin.S3Region") || viper.IsSet("Origin.S3ServiceUrl") || viper.IsSet("Origin.S3UrlStyle") { cmd.PrintErrln("The --region, --service-url, and --url-style flags are only used when the origin is launched in S3 mode.") - os.Exit(1) } } else { cmd.PrintErrln(fmt.Sprintf("The --mode flag must be either 'posix' or 's3', but you provided '%s'", ost)) From 635486d96ca7d4c145d82b36a2bd3c8c29d6d82d Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Mon, 8 Apr 2024 17:42:47 +0000 Subject: [PATCH 3/3] Fix bad viper variable --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 81f6fad47..97900b4dd 100644 --- a/config/config.go +++ b/config/config.go @@ -985,7 +985,7 @@ func InitServer(ctx context.Context, currentServers ServerType) error { // Set up the default S3 URL style to be path-style here as opposed to in the defaults.yaml becase // we want to be able to check if this is user-provided (which we can't do for defaults.yaml) - viper.SetDefault("S3UrlStyle", "path") + viper.SetDefault("Origin.S3UrlStyle", "path") if webConfigPath := param.Server_WebConfigFile.GetString(); webConfigPath != "" { err := os.MkdirAll(filepath.Dir(webConfigPath), 0700)