Skip to content

Commit 6f5d914

Browse files
ndeloofglours
authored andcommitted
exclude remote config paths while computing a default workingdir
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 7eb3472 commit 6f5d914

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cli/options.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ type ProjectOptions struct {
8181
// Callbacks to retrieve metadata information during parse defined before
8282
// creating the project
8383
Listeners []loader.Listener
84+
// ResourceLoaders manages support for remote resources
85+
ResourceLoaders []loader.ResourceLoader
8486
}
8587

8688
type ProjectOptionsFn func(*ProjectOptions) error
@@ -347,8 +349,9 @@ func WithResolvedPaths(resolve bool) ProjectOptionsFn {
347349
// WithResourceLoader register support for ResourceLoader to manage remote resources
348350
func WithResourceLoader(r loader.ResourceLoader) ProjectOptionsFn {
349351
return func(o *ProjectOptions) error {
352+
o.ResourceLoaders = append(o.ResourceLoaders, r)
350353
o.loadOptions = append(o.loadOptions, func(options *loader.Options) {
351-
options.ResourceLoaders = append(options.ResourceLoaders, r)
354+
options.ResourceLoaders = o.ResourceLoaders
352355
})
353356
return nil
354357
}
@@ -390,8 +393,14 @@ func (o *ProjectOptions) GetWorkingDir() (string, error) {
390393
if o.WorkingDir != "" {
391394
return filepath.Abs(o.WorkingDir)
392395
}
396+
PATH:
393397
for _, path := range o.ConfigPaths {
394398
if path != "-" {
399+
for _, l := range o.ResourceLoaders {
400+
if l.Accept(path) {
401+
break PATH
402+
}
403+
}
395404
absPath, err := filepath.Abs(path)
396405
if err != nil {
397406
return "", err

0 commit comments

Comments
 (0)