Skip to content

Commit

Permalink
Fix nested OS env config override when parent does not exist
Browse files Browse the repository at this point in the history
Fixes #8618
  • Loading branch information
bep committed Jun 8, 2021
1 parent f55d2f4 commit 1253051
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hugolib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
5 changes: 5 additions & 0 deletions hugolib/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,14 @@ theme_param="themevalue2"
"HUGOxPARAMSxMYTHEME_SECTION2xTHEME_PARAM", "themevalue2_changed",
"HUGO_PARAMS_EMPTY", ``,
"HUGO_PARAMS_HTML", `<a target="_blank" />`,
//
"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)
Expand All @@ -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, `<a target="_blank" />`)

c.Assert(scfg.GoogleAnalytics.ID, qt.Equals, "gaid")
}

0 comments on commit 1253051

Please sign in to comment.