8
8
"io/fs"
9
9
"os"
10
10
"path/filepath"
11
+ "regexp"
11
12
"runtime"
12
13
"strings"
13
14
"sync"
@@ -58,7 +59,7 @@ type Manager struct {
58
59
storageDir string
59
60
gitDir string
60
61
runtimeDir string
61
- systemDir string
62
+ systemDirs [] string
62
63
runtimes []Runtime
63
64
credHelperConfig * credHelperConfig
64
65
}
@@ -69,14 +70,22 @@ type credHelperConfig struct {
69
70
cliCfg * config.CLIConfig
70
71
}
71
72
72
- func New (cacheDir string , runtimes ... Runtime ) * Manager {
73
- root := filepath .Join (cacheDir , "repos" )
73
+ func New (cacheDir , systemDir string , runtimes ... Runtime ) * Manager {
74
+ var (
75
+ systemDirs []string
76
+ root = filepath .Join (cacheDir , "repos" )
77
+ )
78
+
79
+ if strings .TrimSpace (systemDir ) != "" {
80
+ systemDirs = regexp .MustCompile ("[;:,]" ).Split (strings .TrimSpace (systemDir ), - 1 )
81
+ }
82
+
74
83
return & Manager {
75
84
cacheDir : cacheDir ,
76
85
storageDir : root ,
77
86
gitDir : filepath .Join (root , "git" ),
78
87
runtimeDir : filepath .Join (root , "runtimes" ),
79
- systemDir : filepath . Join ( root , "system" ) ,
88
+ systemDirs : systemDirs ,
80
89
runtimes : runtimes ,
81
90
}
82
91
}
@@ -273,8 +282,10 @@ func (m *Manager) setup(ctx context.Context, runtime Runtime, tool types.Tool, e
273
282
}
274
283
275
284
func (m * Manager ) GetContext (ctx context.Context , tool types.Tool , cmd , env []string ) (string , []string , error ) {
276
- if strings .HasPrefix (tool .WorkingDir , m .systemDir ) {
277
- return tool .WorkingDir , env , nil
285
+ for _ , systemDir := range m .systemDirs {
286
+ if strings .HasPrefix (tool .WorkingDir , systemDir ) {
287
+ return tool .WorkingDir , env , nil
288
+ }
278
289
}
279
290
280
291
var isLocal bool
0 commit comments