Skip to content

Commit

Permalink
Merge pull request #460 from ndeloof/SkipResolveEnvironment
Browse files Browse the repository at this point in the history
introduce SkipResolveEnvironment loader option
  • Loading branch information
glours authored Sep 20, 2023
2 parents cb96a73 + f374845 commit 923ed64
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cli/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ func WithResourceLoader(r loader.ResourceLoader) ProjectOptionsFn {
}
}

// WithoutEnvironmentResolution disable environment resolution
func WithoutEnvironmentResolution(o *ProjectOptions) error {
o.loadOptions = append(o.loadOptions, func(options *loader.Options) {
options.SkipResolveEnvironment = true
})
return nil
}

// DefaultFileNames defines the Compose file names for auto-discovery (in order of preference)
var DefaultFileNames = []string{"compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml"}

Expand Down
11 changes: 9 additions & 2 deletions loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type Options struct {
SkipExtends bool
// SkipInclude will ignore `include` and only load model from file(s) set by ConfigDetails
SkipInclude bool
// SkipResolveEnvironment will ignore computing `environment` for services
SkipResolveEnvironment bool
// Interpolation options
Interpolate *interp.Options
// Discard 'env_file' entries after resolving to 'environment' section
Expand Down Expand Up @@ -387,9 +389,14 @@ func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options,

project.ApplyProfiles(opts.Profiles)

err := project.ResolveServicesEnvironment(opts.discardEnvFiles)
if !opts.SkipResolveEnvironment {
err := project.ResolveServicesEnvironment(opts.discardEnvFiles)
if err != nil {
return nil, err
}
}

return project, err
return project, nil
}

func InvalidProjectNameErr(v string) error {
Expand Down

0 comments on commit 923ed64

Please sign in to comment.