Skip to content

Commit 9b5a458

Browse files
committed
introduce --no-path-resolution to skip relative path to be resolved
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 00f72cb commit 9b5a458

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

cmd/compose/compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func RootCommand(streams command.Cli, backend api.Service) *cobra.Command { //no
392392
psCommand(&opts, streams, backend),
393393
listCommand(streams, backend),
394394
logsCommand(&opts, streams, backend),
395-
convertCommand(&opts, streams, backend),
395+
configCommand(&opts, streams, backend),
396396
killCommand(&opts, backend),
397397
runCommand(&opts, streams, backend),
398398
removeCommand(&opts, backend),

cmd/compose/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type configOptions struct {
4040
resolveImageDigests bool
4141
noInterpolate bool
4242
noNormalize bool
43+
noResolvePath bool
4344
services bool
4445
volumes bool
4546
profiles bool
@@ -51,14 +52,14 @@ type configOptions struct {
5152
func (o *configOptions) ToProject(services []string) (*types.Project, error) {
5253
return o.ProjectOptions.ToProject(services,
5354
cli.WithInterpolation(!o.noInterpolate),
54-
cli.WithResolvedPaths(true),
55+
cli.WithResolvedPaths(!o.noResolvePath),
5556
cli.WithNormalization(!o.noNormalize),
5657
cli.WithConsistency(!o.noConsistency),
5758
cli.WithProfiles(o.Profiles),
5859
cli.WithDiscardEnvFile)
5960
}
6061

61-
func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *cobra.Command {
62+
func configCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *cobra.Command {
6263
opts := configOptions{
6364
ProjectOptions: p,
6465
}
@@ -106,6 +107,7 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
106107
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only validate the configuration, don't print anything.")
107108
flags.BoolVar(&opts.noInterpolate, "no-interpolate", false, "Don't interpolate environment variables.")
108109
flags.BoolVar(&opts.noNormalize, "no-normalize", false, "Don't normalize compose model.")
110+
flags.BoolVar(&opts.noResolvePath, "no-path-resolution", false, "Don't resolve file paths.")
109111
flags.BoolVar(&opts.noConsistency, "no-consistency", false, "Don't check model consistency - warning: may produce invalid Compose output")
110112

111113
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")

docs/reference/compose_config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Parse, resolve and render compose file in canonical format
1818
| `--no-consistency` | | | Don't check model consistency - warning: may produce invalid Compose output |
1919
| `--no-interpolate` | | | Don't interpolate environment variables. |
2020
| `--no-normalize` | | | Don't normalize compose model. |
21+
| `--no-path-resolution` | | | Don't resolve file paths. |
2122
| `-o`, `--output` | `string` | | Save to file (default to stdout) |
2223
| `--profiles` | | | Print the profile names, one per line. |
2324
| `-q`, `--quiet` | | | Only validate the configuration, don't print anything. |

docs/reference/docker_compose_config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ options:
6969
experimentalcli: false
7070
kubernetes: false
7171
swarm: false
72+
- option: no-path-resolution
73+
value_type: bool
74+
default_value: "false"
75+
description: Don't resolve file paths.
76+
deprecated: false
77+
hidden: false
78+
experimental: false
79+
experimentalcli: false
80+
kubernetes: false
81+
swarm: false
7282
- option: output
7383
shorthand: o
7484
value_type: string

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.20
55
require (
66
github.com/AlecAivazis/survey/v2 v2.3.6
77
github.com/buger/goterm v1.0.4
8-
github.com/compose-spec/compose-go v1.13.4
8+
github.com/compose-spec/compose-go v1.13.5
99
github.com/containerd/console v1.0.3
1010
github.com/containerd/containerd v1.6.21
1111
github.com/cucumber/godog v0.0.0-00010101000000-000000000000 // replaced; see replace for the actual version used

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH
165165
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
166166
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
167167
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
168-
github.com/compose-spec/compose-go v1.13.4 h1:O6xAsPqaY1s9KXteiO7wRCDTJLahv1XP/z/eUO9EfbI=
169-
github.com/compose-spec/compose-go v1.13.4/go.mod h1:rsiZ8uaOHJYJemDBzTe9UBpaq5ZFVEOO4TxM2G3SJxk=
168+
github.com/compose-spec/compose-go v1.13.5 h1:ogqJOGEbe3uRxMg0ZEufOoCQTpX61l8tUeyW4UQgEBk=
169+
github.com/compose-spec/compose-go v1.13.5/go.mod h1:m0o4G6MQDHjjz9rY7No9FpnNi+9sKic262rzrwuCqic=
170170
github.com/containerd/cgroups v1.0.4 h1:jN/mbWBEaz+T1pi5OFtnkQ+8qnmEbAr1Oo1FRm5B0dA=
171171
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
172172
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=

pkg/e2e/compose_environment_test.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,26 +177,13 @@ func TestEnvPriority(t *testing.T) {
177177
func TestEnvInterpolation(t *testing.T) {
178178
c := NewParallelCLI(t)
179179

180-
// No variable defined in the Compose file and nor env variable pass to the run command
181-
// 1. Command Line (docker compose run --env <KEY[=VAL]>)
182-
// 2. Compose File (service::environment section) <-- Result expected (From environment patched by .env as a default --env-file value)
183-
// 3. Compose File (service::env_file section file)
184-
// 4. Container Image ENV directive
185-
// 5. Variable is not defined
186180
t.Run("shell priority from run command", func(t *testing.T) {
187181
cmd := c.NewDockerComposeCmd(t, "-f", "./fixtures/environment/env-interpolation/compose.yaml", "config")
188182
cmd.Env = append(cmd.Env, "WHEREAMI=shell")
189183
res := icmd.RunCmd(cmd)
190-
res.Assert(t, icmd.Expected{Out: `IMAGE: default_env:EnvFile`})
184+
res.Assert(t, icmd.Expected{Out: `IMAGE: default_env:shell`})
191185
})
192186

193-
// No variable defined in the Compose file and env variable pass to the run command
194-
// 1. Command Line (docker compose run --env <KEY[=VAL]>)
195-
// 2. Compose File (service::environment section) <-- Result expected (From environment patched by .env as a default --env-file value.
196-
// This variable has a default value in case of an absent variable in the OS environment)
197-
// 3. Compose File (service::env_file section file)
198-
// 4. Container Image ENV directive
199-
// 5. Variable is not defined
200187
t.Run("shell priority from run command using default value fallback", func(t *testing.T) {
201188
c.RunDockerComposeCmd(t, "-f", "./fixtures/environment/env-interpolation-default-value/compose.yaml", "config").
202189
Assert(t, icmd.Expected{Out: `IMAGE: default_env:EnvFileDefaultValue`})

0 commit comments

Comments
 (0)