modules: Add module.import.noMounts config
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 28 Jun 2021 08:39:52 +0000 (10:39 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 28 Jun 2021 08:39:52 +0000 (10:39 +0200)
Fixes #8708

docs/content/en/hugo-modules/configuration.md
modules/collect.go
modules/config.go

index 4bb19dde4c40bf00c21a09671e09e036c5bff777..1a3a285c76551a5a56be89d647d0148cd54a4fe0 100644 (file)
@@ -101,6 +101,12 @@ ignoreImports {{< new-in "0.80.0" >}}
 disable
 : Set to `true` to disable the module while keeping any version info in the `go.*` files.
 
+noMounts {{< new-in "0.84.2" >}}
+:  Do not mount any folder in this import.
+
+noVendor
+:  Never vendor this import (only allowed in main project).
+
 {{< gomodules-info >}}
 
 
index 52d75af59a55ff3de1f1be8b422cc67c55e55c27..026373b54574a0a6983b8cd1a07056eb50d43eca 100644 (file)
@@ -354,6 +354,11 @@ func (c *collector) addAndRecurse(owner *moduleAdapter, disabled bool) error {
 }
 
 func (c *collector) applyMounts(moduleImport Import, mod *moduleAdapter) error {
+       if moduleImport.NoMounts {
+               mod.mounts = nil
+               return nil
+       }
+
        mounts := moduleImport.Mounts
 
        modConfig := mod.Config()
index 1e3e3c79804e15f1cfec13bf2118a5488e014954..45a2f22ee1fdb517f04ebf2c13beb0576baadd20 100644 (file)
@@ -367,6 +367,7 @@ type Import struct {
        pathProjectReplaced bool   // Set when Path is replaced in project config.
        IgnoreConfig        bool   // Ignore any config in config.toml (will still folow imports).
        IgnoreImports       bool   // Do not follow any configured imports.
+       NoMounts            bool   // Do not mount any folder in this import.
        NoVendor            bool   // Never vendor this import (only allowed in main project).
        Disable             bool   // Turn off this module.
        Mounts              []Mount