Fix self-mounts on the main project

Fixes #6143
This commit is contained in:
Bjørn Erik Pedersen
2019-07-30 13:35:16 +02:00
parent 53ade40ba4
commit 36220851e4
3 changed files with 49 additions and 14 deletions

View File

@@ -305,21 +305,25 @@ func (c *collector) addAndRecurse(owner *moduleAdapter, disabled bool) error {
func (c *collector) applyMounts(moduleImport Import, mod *moduleAdapter) error {
mounts := moduleImport.Mounts
if !mod.projectMod && len(mounts) == 0 {
modConfig := mod.Config()
modConfig := mod.Config()
if len(mounts) == 0 {
// Mounts not defined by the import.
mounts = modConfig.Mounts
if len(mounts) == 0 {
// Create default mount points for every component folder that
// exists in the module.
for _, componentFolder := range files.ComponentFolders {
sourceDir := filepath.Join(mod.Dir(), componentFolder)
_, err := c.fs.Stat(sourceDir)
if err == nil {
mounts = append(mounts, Mount{
Source: componentFolder,
Target: componentFolder,
})
}
}
if !mod.projectMod && len(mounts) == 0 {
// Create default mount points for every component folder that
// exists in the module.
for _, componentFolder := range files.ComponentFolders {
sourceDir := filepath.Join(mod.Dir(), componentFolder)
_, err := c.fs.Stat(sourceDir)
if err == nil {
mounts = append(mounts, Mount{
Source: componentFolder,
Target: componentFolder,
})
}
}
}

View File

@@ -171,6 +171,9 @@ func ApplyProjectConfigDefaults(cfg config.Provider, mod Module) error {
mounts = append(mounts, Mount{Source: dirKey.component, Target: dirKey.component})
}
// Prepend the mounts from configuration.
mounts = append(moda.mounts, mounts...)
// Remove duplicates
seen := make(map[string]bool)
tmp := mounts[:0]