Move the mount duplicate filter to the modules package

Also simplify the mount validation logic. There are plenty of ways a user can create mount configs that behaves oddly.
This commit is contained in:
Bjørn Erik Pedersen 2019-07-31 08:21:17 +02:00
parent edf9f0a354
commit 4b6c5eba30
6 changed files with 154 additions and 123 deletions

View file

@ -15,7 +15,6 @@ package modules
import (
"fmt"
"path"
"path/filepath"
"strings"
@ -174,18 +173,7 @@ func ApplyProjectConfigDefaults(cfg config.Provider, mod Module) error {
// Prepend the mounts from configuration.
mounts = append(moda.mounts, mounts...)
// Remove duplicates
seen := make(map[string]bool)
tmp := mounts[:0]
for _, m := range mounts {
key := path.Join(m.Lang, m.Source, m.Target)
if !seen[key] {
tmp = append(tmp, m)
}
seen[key] = true
}
moda.mounts = tmp
moda.mounts = mounts
return nil
}