From 12530519d8fb4513c9c18a6494099b7dff8e4fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 8 Jun 2021 09:48:22 +0200 Subject: [PATCH] Fix nested OS env config override when parent does not exist Fixes #8618 --- hugolib/config.go | 2 +- hugolib/config_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hugolib/config.go b/hugolib/config.go index 846cba83c..eaa6710ae 100644 --- a/hugolib/config.go +++ b/hugolib/config.go @@ -221,7 +221,7 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid } else if nestedKey != "" { owner[nestedKey] = env.Value } else { - v.Set(env.Key, env.Value) + v.Set(strings.ReplaceAll(env.Key, delim, "."), env.Value) } } diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 9e01212c7..fb81c927e 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -530,11 +530,14 @@ theme_param="themevalue2" "HUGOxPARAMSxMYTHEME_SECTION2xTHEME_PARAM", "themevalue2_changed", "HUGO_PARAMS_EMPTY", ``, "HUGO_PARAMS_HTML", ``, + // + "HUGO_SERVICES_GOOGLEANALYTICS_ID", `gaid`, ) b.Build(BuildCfg{}) cfg := b.H.Cfg + scfg := b.H.Sites[0].siteConfigConfig.Services c.Assert(cfg.Get("environment"), qt.Equals, "test") c.Assert(cfg.GetBool("enablegitinfo"), qt.Equals, false) @@ -551,4 +554,6 @@ theme_param="themevalue2" c.Assert(cfg.Get("params.mytheme_section2.theme_param"), qt.Equals, "themevalue2_changed") c.Assert(cfg.Get("params.empty"), qt.Equals, ``) c.Assert(cfg.Get("params.html"), qt.Equals, ``) + + c.Assert(scfg.GoogleAnalytics.ID, qt.Equals, "gaid") }