Skip to content

Commit 12f028f

Browse files
committed
introduce config --no-env-resolution
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 0c5bd16 commit 12f028f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cmd/compose/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type configOptions struct {
4747
noInterpolate bool
4848
noNormalize bool
4949
noResolvePath bool
50+
noResolveEnv bool
5051
services bool
5152
volumes bool
5253
profiles bool
@@ -135,6 +136,7 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
135136
flags.BoolVar(&opts.noNormalize, "no-normalize", false, "Don't normalize compose model")
136137
flags.BoolVar(&opts.noResolvePath, "no-path-resolution", false, "Don't resolve file paths")
137138
flags.BoolVar(&opts.noConsistency, "no-consistency", false, "Don't check model consistency - warning: may produce invalid Compose output")
139+
flags.BoolVar(&opts.noResolveEnv, "no-env-resolution", false, "Don't resolve service env files")
138140

139141
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")
140142
flags.BoolVar(&opts.volumes, "volumes", false, "Print the volume names, one per line.")
@@ -190,6 +192,13 @@ func runConfigInterpolate(ctx context.Context, dockerCli command.Cli, opts confi
190192
}
191193
}
192194

195+
if !opts.noResolveEnv {
196+
project, err = project.WithServicesEnvironmentResolved(true)
197+
if err != nil {
198+
return nil, err
199+
}
200+
}
201+
193202
if !opts.noConsistency {
194203
err := project.CheckContainerNameUnicity()
195204
if err != nil {

pkg/compose/run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts
151151
v, ok := envResolver(project.Environment)(s)
152152
return v, ok
153153
}).RemoveEmpty()
154+
if service.Environment == nil {
155+
service.Environment = types.MappingWithEquals{}
156+
}
154157
service.Environment.OverrideBy(serviceOverrideEnv)
155158
}
156159
for k, v := range opts.Labels {

0 commit comments

Comments
 (0)