Skip to content

Commit 923ed64

Browse files
authored
Merge pull request #460 from ndeloof/SkipResolveEnvironment
introduce SkipResolveEnvironment loader option
2 parents cb96a73 + f374845 commit 923ed64

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

cli/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ func WithResourceLoader(r loader.ResourceLoader) ProjectOptionsFn {
328328
}
329329
}
330330

331+
// WithoutEnvironmentResolution disable environment resolution
332+
func WithoutEnvironmentResolution(o *ProjectOptions) error {
333+
o.loadOptions = append(o.loadOptions, func(options *loader.Options) {
334+
options.SkipResolveEnvironment = true
335+
})
336+
return nil
337+
}
338+
331339
// DefaultFileNames defines the Compose file names for auto-discovery (in order of preference)
332340
var DefaultFileNames = []string{"compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml"}
333341

loader/loader.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ type Options struct {
6161
SkipExtends bool
6262
// SkipInclude will ignore `include` and only load model from file(s) set by ConfigDetails
6363
SkipInclude bool
64+
// SkipResolveEnvironment will ignore computing `environment` for services
65+
SkipResolveEnvironment bool
6466
// Interpolation options
6567
Interpolate *interp.Options
6668
// Discard 'env_file' entries after resolving to 'environment' section
@@ -387,9 +389,14 @@ func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options,
387389

388390
project.ApplyProfiles(opts.Profiles)
389391

390-
err := project.ResolveServicesEnvironment(opts.discardEnvFiles)
392+
if !opts.SkipResolveEnvironment {
393+
err := project.ResolveServicesEnvironment(opts.discardEnvFiles)
394+
if err != nil {
395+
return nil, err
396+
}
397+
}
391398

392-
return project, err
399+
return project, nil
393400
}
394401

395402
func InvalidProjectNameErr(v string) error {

0 commit comments

Comments
 (0)