summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-09 10:58:18 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-14 17:00:32 +0200
commitd392893cd73dc00c927f342778f6dca9628d328e (patch)
treee2ea3eec09f36b7122ecdbc498c3c130e240e85c
parenta886dd53b80322e1edf924f2ede4d4ea037c5baf (diff)
Misc config loading fixes
The main motivation behind this is simplicity and correctnes, but the new small config library is also faster: ``` BenchmarkDefaultConfigProvider/Viper-16 252418 4546 ns/op 2720 B/op 30 allocs/op BenchmarkDefaultConfigProvider/Custom-16 450756 2651 ns/op 1008 B/op 6 allocs/op ``` Fixes #8633 Fixes #8618 Fixes #8630 Updates #8591 Closes #6680 Closes #5192
-rw-r--r--cache/filecache/filecache_config.go7
-rw-r--r--cache/filecache/filecache_config_test.go5
-rw-r--r--commands/commandeer.go2
-rw-r--r--commands/commands_test.go9
-rw-r--r--commands/config.go5
-rw-r--r--commands/new_site.go4
-rw-r--r--commands/server_test.go4
-rw-r--r--common/maps/maps.go77
-rw-r--r--common/maps/maps_test.go2
-rw-r--r--common/maps/params.go148
-rw-r--r--common/maps/params_test.go87
-rw-r--r--config/commonConfig_test.go4
-rw-r--r--config/compositeConfig.go113
-rw-r--r--config/compositeConfig_test.go40
-rw-r--r--config/configLoader.go23
-rw-r--r--config/configProvider.go5
-rw-r--r--config/configProvider_test.go3
-rw-r--r--config/defaultConfigProvider.go372
-rw-r--r--config/defaultConfigProvider_test.go315
-rw-r--r--config/docshelper.go45
-rw-r--r--config/privacy/privacyConfig_test.go3
-rw-r--r--config/services/servicesConfig_test.go4
-rw-r--r--create/content_test.go5
-rw-r--r--deploy/deployConfig_test.go4
-rw-r--r--docs/config.toml2
-rw-r--r--docs/content/en/getting-started/configuration.md20
-rw-r--r--docs/data/docs.json59
-rw-r--r--docs/layouts/shortcodes/code-toggle.html59
-rw-r--r--go.mod2
-rw-r--r--go.sum1
-rw-r--r--helpers/content_test.go5
-rw-r--r--helpers/general_test.go4
-rw-r--r--helpers/path_test.go4
-rw-r--r--helpers/testhelpers_test.go21
-rw-r--r--hugofs/fs_test.go9
-rw-r--r--hugofs/rootmapping_fs_test.go4
-rw-r--r--hugolib/config.go680
-rw-r--r--hugolib/config_test.go372
-rw-r--r--hugolib/filesystems/basefs_test.go10
-rw-r--r--hugolib/hugo_modules_test.go30
-rw-r--r--hugolib/hugo_sites.go15
-rw-r--r--hugolib/hugo_sites_build_errors_test.go4
-rw-r--r--hugolib/image_test.go4
-rw-r--r--hugolib/js_test.go11
-rw-r--r--hugolib/minify_publisher_test.go4
-rw-r--r--hugolib/page__meta.go2
-rw-r--r--hugolib/page_test.go5
-rw-r--r--hugolib/pagebundler_test.go18
-rw-r--r--hugolib/pages_capture.go2
-rw-r--r--hugolib/paths/paths_test.go7
-rw-r--r--hugolib/resource_chain_babel_test.go6
-rw-r--r--hugolib/resource_chain_test.go18
-rw-r--r--hugolib/robotstxt_test.go4
-rw-r--r--hugolib/shortcode_test.go7
-rw-r--r--hugolib/site.go22
-rw-r--r--hugolib/site_output_test.go12
-rw-r--r--hugolib/site_test.go5
-rw-r--r--hugolib/template_test.go5
-rw-r--r--hugolib/testhelpers_test.go26
-rw-r--r--langs/config.go8
-rw-r--r--langs/i18n/i18n_test.go7
-rw-r--r--langs/language.go84
-rw-r--r--langs/language_test.go7
-rw-r--r--markup/asciidocext/convert_test.go18
-rw-r--r--markup/blackfriday/convert_test.go6
-rw-r--r--markup/highlight/config_test.go5
-rw-r--r--markup/markup_config/config.go3
-rw-r--r--markup/markup_config/config_test.go6
-rw-r--r--markup/markup_test.go8
-rw-r--r--markup/mmark/convert_test.go4
-rw-r--r--markup/org/convert_test.go5
-rw-r--r--media/mediaType.go4
-rw-r--r--minifiers/config.go4
-rw-r--r--minifiers/config_test.go6
-rw-r--r--minifiers/minifiers_test.go15
-rw-r--r--modules/collect.go2
-rw-r--r--modules/npm/package_builder.go8
-rw-r--r--output/outputFormat.go6
-rw-r--r--publisher/htmlElementsCollector_test.go5
-rw-r--r--related/inverted_index.go11
-rw-r--r--resources/page/pagemeta/page_frontmatter_test.go13
-rw-r--r--resources/page/pagination_test.go4
-rw-r--r--resources/page/testhelpers_test.go4
-rw-r--r--resources/resource_metadata.go2
-rw-r--r--resources/resource_transformers/htesting/testhelpers.go4
-rw-r--r--resources/resource_transformers/js/options.go7
-rw-r--r--resources/testhelpers_test.go6
-rw-r--r--source/filesystem_test.go8
-rw-r--r--tpl/cast/docshelper.go8
-rw-r--r--tpl/collections/collections_test.go4
-rw-r--r--tpl/data/init_test.go4
-rw-r--r--tpl/data/resources_test.go8
-rw-r--r--tpl/encoding/encoding.go3
-rw-r--r--tpl/hugo/init_test.go5
-rw-r--r--tpl/images/images_test.go4
-rw-r--r--tpl/os/os_test.go9
-rw-r--r--tpl/path/path_test.go4
-rw-r--r--tpl/resources/resources.go2
-rw-r--r--tpl/site/init_test.go5
-rw-r--r--tpl/strings/init_test.go5
-rw-r--r--tpl/strings/strings_test.go4
-rw-r--r--tpl/tplimpl/template_funcs_test.go6
-rw-r--r--tpl/transform/remarshal_test.go10
-rw-r--r--tpl/transform/transform_test.go16
-rw-r--r--tpl/transform/unmarshal_test.go9
-rw-r--r--tpl/urls/init_test.go5
-rw-r--r--tpl/urls/urls_test.go5
107 files changed, 2115 insertions, 1016 deletions
diff --git a/cache/filecache/filecache_config.go b/cache/filecache/filecache_config.go
index 0c6b569c1..801799e36 100644
--- a/cache/filecache/filecache_config.go
+++ b/cache/filecache/filecache_config.go
@@ -19,6 +19,8 @@ import (
"strings"
"time"
+ "github.com/gohugoio/hugo/common/maps"
+
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"
@@ -123,6 +125,9 @@ func DecodeConfig(fs afero.Fs, cfg config.Provider) (Configs, error) {
_, isOsFs := fs.(*afero.OsFs)
for k, v := range m {
+ if _, ok := v.(maps.Params); !ok {
+ continue
+ }
cc := defaultCacheConfig
dc := &mapstructure.DecoderConfig{
@@ -137,7 +142,7 @@ func DecodeConfig(fs afero.Fs, cfg config.Provider) (Configs, error) {
}
if err := decoder.Decode(v); err != nil {
- return nil, err
+ return nil, errors.Wrap(err, "failed to decode filecache config")
}
if cc.Dir == "" {
diff --git a/cache/filecache/filecache_config_test.go b/cache/filecache/filecache_config_test.go
index cd1d2c82a..acc127e67 100644
--- a/cache/filecache/filecache_config_test.go
+++ b/cache/filecache/filecache_config_test.go
@@ -25,7 +25,6 @@ import (
"github.com/gohugoio/hugo/config"
qt "github.com/frankban/quicktest"
- "github.com/spf13/viper"
)
func TestDecodeConfig(t *testing.T) {
@@ -178,8 +177,8 @@ dir = "/"
c.Assert(err, qt.Not(qt.IsNil))
}
-func newTestConfig() *viper.Viper {
- cfg := viper.New()
+func newTestConfig() config.Provider {
+ cfg := config.New()
cfg.Set("workingDir", filepath.FromSlash("/my/cool/hugoproject"))
cfg.Set("contentDir", "content")
cfg.Set("dataDir", "data")
diff --git a/commands/commandeer.go b/commands/commandeer.go
index 024651aad..06e27cf18 100644
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -410,7 +410,5 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error {
}
config.Set("cacheDir", cacheDir)
- cfg.Logger.Infoln("Using config file:", config.ConfigFileUsed())
-
return nil
}