mirror of
https://github.com/3bbbeau/tfvars-atlantis-config.git
synced 2024-11-21 21:40:52 +00:00
Compare commits
No commits in common. "81c41856ce115a2bbbd4b031102ab0d4ea6fda0e" and "7e9de4fa79fda49b4fe84aa4314ee304ac51f724" have entirely different histories.
81c41856ce
...
7e9de4fa79
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/3bbbeau/tfvars-atlantis-config/logger"
|
||||
@ -169,7 +168,7 @@ const (
|
||||
func discover(ctx context.Context, flags *Flags) ([]repocfg.Component, error) {
|
||||
logger := logger.FromContext(ctx)
|
||||
|
||||
discovered := []repocfg.Component{}
|
||||
var discovered []repocfg.Component
|
||||
|
||||
// Walk the directory tree from the root
|
||||
err := filepath.Walk(flags.Root, func(path string, info os.FileInfo, err error) error {
|
||||
@ -219,27 +218,8 @@ func discover(ctx context.Context, flags *Flags) ([]repocfg.Component, error) {
|
||||
logger.Sugar().Debugf("component %s has var file %s", parent, child)
|
||||
found.VarFiles = append(found.VarFiles, child)
|
||||
|
||||
// Check if the component already exists in the slice
|
||||
// If it does, ensure the var file is not a duplicate and append it.
|
||||
exists := false
|
||||
for idx, component := range discovered {
|
||||
if component.Path == found.Path {
|
||||
exists = true
|
||||
for _, varFile := range found.VarFiles {
|
||||
if !slices.Contains(component.VarFiles, varFile) {
|
||||
discovered[idx].VarFiles = append(discovered[idx].VarFiles, varFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the component does not exist in the slice, then
|
||||
// it can be treated as new component.
|
||||
if !exists {
|
||||
discovered = append(discovered, found)
|
||||
}
|
||||
discovered = append(discovered, found)
|
||||
}
|
||||
|
||||
return err
|
||||
})
|
||||
return filepath.SkipDir
|
||||
|
Loading…
Reference in New Issue
Block a user