diff --git a/cmd/digger/main.go b/cmd/digger/main.go index cb635723b..77e86e44b 100644 --- a/cmd/digger/main.go +++ b/cmd/digger/main.go @@ -101,8 +101,11 @@ func gitHubCI(lock core_locking.Lock) { CiService: githubPrService, PrNumber: prNumber, } - - allAppliesSuccessful, atLeastOneApply, err := digger.RunCommandsPerProject(commandsToRunPerProject, parsedGhContext.Repository, githubActor, eventName, prNumber, githubPrService, lock, reporter, planStorage, "") + currentDir, err := os.Getwd() + if err != nil { + reportErrorAndExit(githubActor, fmt.Sprintf("Failed to get current dir. %s", err), 4) + } + allAppliesSuccessful, atLeastOneApply, err := digger.RunCommandsPerProject(commandsToRunPerProject, parsedGhContext.Repository, githubActor, eventName, prNumber, githubPrService, lock, reporter, planStorage, currentDir) if err != nil { reportErrorAndExit(githubActor, fmt.Sprintf("Failed to run commands. %s", err), 8) } diff --git a/pkg/configuration/digger_config.go b/pkg/configuration/digger_config.go index b23e2204f..a5361a00c 100644 --- a/pkg/configuration/digger_config.go +++ b/pkg/configuration/digger_config.go @@ -36,6 +36,24 @@ func GetFilesWithExtension(workingDir string, ext string) ([]string, error) { return files, nil } +func GetFilesWithExtension(workingDir string, ext string) ([]string, error) { + var files []string + listOfFiles, err := os.ReadDir(workingDir) + if err != nil { + return nil, errors.New(fmt.Sprintf("error reading directory %s: %v", workingDir, err)) + } + for _, f := range listOfFiles { + if !f.IsDir() { + r, err := regexp.MatchString(ext, f.Name()) + if err == nil && r { + files = append(files, f.Name()) + } + } + } + + return files, nil +} + func (walker *FileSystemDirWalker) GetDirs(workingDir string) ([]string, error) { var dirs []string err := filepath.Walk(workingDir, @@ -61,6 +79,7 @@ func (walker *FileSystemDirWalker) GetDirs(workingDir string) ([]string, error) var ErrDiggerConfigConflict = errors.New("more than one digger config file detected, please keep either 'digger.yml' or 'digger.yaml'") + func LoadDiggerConfig(workingDir string, walker DirWalker) (*DiggerConfig, error) { configYaml := &DiggerConfigYaml{} config := &DiggerConfig{}