@@ -11,10 +11,12 @@ import (
1111 "path/filepath"
1212 "slices"
1313 "strings"
14+ "strconv"
1415)
1516
1617var defaultContainerBasePath = "/var/container:/srv/container"
1718var defaultContainerExecCommand = "docker compose -f %COMPOSE exec --user root %SERVICE /bin/sh"
19+ var defaultMaxDepth = 2
1820
1921//go:embed HELP.md
2022var help string
@@ -29,8 +31,7 @@ func isDirectory(path string) (bool, error) {
2931 return info .IsDir (), nil
3032}
3133
32- func getComposeFilesInDir (basePath string ) ([]string , error ) {
33- maxDepth := 3
34+ func getComposeFilesInDir (basePath string , maxDepth int ) ([]string , error ) {
3435 isDir , err := isDirectory (basePath )
3536 if err != nil {
3637 return nil , err
@@ -103,8 +104,20 @@ func getAllComposeFiles() ([]string, string, error) {
103104 var composeFilePaths []string
104105 paths := getAllComposeSearchPaths ()
105106
107+ maxDepthString := os .Getenv ("CONTAINER_BASE_PATH_MAX_DEPTH" )
108+ maxDepth , err := strconv .Atoi (maxDepthString )
109+ if err != nil {
110+ if maxDepthString != "" {
111+ fmt .Printf ("Invalid value for CONTAINER_BASE_PATH_MAX_DEPTH: %s. Using default: %d\n " , maxDepthString , defaultMaxDepth )
112+ }
113+ maxDepth = defaultMaxDepth
114+ }
115+ if maxDepth < 1 {
116+ maxDepth = 1
117+ }
118+
106119 for _ , path := range paths {
107- currentComposeFilePaths , _ := getComposeFilesInDir (path )
120+ currentComposeFilePaths , _ := getComposeFilesInDir (path , maxDepth )
108121 composeFilePaths = append (composeFilePaths , currentComposeFilePaths ... )
109122 }
110123
0 commit comments