introduce --no-path-resolution to skip relative path to be resolved
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
00f72cb553
commit
9b5a4588f9
@ -392,7 +392,7 @@ func RootCommand(streams command.Cli, backend api.Service) *cobra.Command { //no
|
|||||||
psCommand(&opts, streams, backend),
|
psCommand(&opts, streams, backend),
|
||||||
listCommand(streams, backend),
|
listCommand(streams, backend),
|
||||||
logsCommand(&opts, streams, backend),
|
logsCommand(&opts, streams, backend),
|
||||||
convertCommand(&opts, streams, backend),
|
configCommand(&opts, streams, backend),
|
||||||
killCommand(&opts, backend),
|
killCommand(&opts, backend),
|
||||||
runCommand(&opts, streams, backend),
|
runCommand(&opts, streams, backend),
|
||||||
removeCommand(&opts, backend),
|
removeCommand(&opts, backend),
|
||||||
|
@ -40,6 +40,7 @@ type configOptions struct {
|
|||||||
resolveImageDigests bool
|
resolveImageDigests bool
|
||||||
noInterpolate bool
|
noInterpolate bool
|
||||||
noNormalize bool
|
noNormalize bool
|
||||||
|
noResolvePath bool
|
||||||
services bool
|
services bool
|
||||||
volumes bool
|
volumes bool
|
||||||
profiles bool
|
profiles bool
|
||||||
@ -51,14 +52,14 @@ type configOptions struct {
|
|||||||
func (o *configOptions) ToProject(services []string) (*types.Project, error) {
|
func (o *configOptions) ToProject(services []string) (*types.Project, error) {
|
||||||
return o.ProjectOptions.ToProject(services,
|
return o.ProjectOptions.ToProject(services,
|
||||||
cli.WithInterpolation(!o.noInterpolate),
|
cli.WithInterpolation(!o.noInterpolate),
|
||||||
cli.WithResolvedPaths(true),
|
cli.WithResolvedPaths(!o.noResolvePath),
|
||||||
cli.WithNormalization(!o.noNormalize),
|
cli.WithNormalization(!o.noNormalize),
|
||||||
cli.WithConsistency(!o.noConsistency),
|
cli.WithConsistency(!o.noConsistency),
|
||||||
cli.WithProfiles(o.Profiles),
|
cli.WithProfiles(o.Profiles),
|
||||||
cli.WithDiscardEnvFile)
|
cli.WithDiscardEnvFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *cobra.Command {
|
func configCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *cobra.Command {
|
||||||
opts := configOptions{
|
opts := configOptions{
|
||||||
ProjectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
@ -106,6 +107,7 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
|
|||||||
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only validate the configuration, don't print anything.")
|
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only validate the configuration, don't print anything.")
|
||||||
flags.BoolVar(&opts.noInterpolate, "no-interpolate", false, "Don't interpolate environment variables.")
|
flags.BoolVar(&opts.noInterpolate, "no-interpolate", false, "Don't interpolate environment variables.")
|
||||||
flags.BoolVar(&opts.noNormalize, "no-normalize", false, "Don't normalize compose model.")
|
flags.BoolVar(&opts.noNormalize, "no-normalize", false, "Don't normalize compose model.")
|
||||||
|
flags.BoolVar(&opts.noResolvePath, "no-path-resolution", false, "Don't resolve file paths.")
|
||||||
flags.BoolVar(&opts.noConsistency, "no-consistency", false, "Don't check model consistency - warning: may produce invalid Compose output")
|
flags.BoolVar(&opts.noConsistency, "no-consistency", false, "Don't check model consistency - warning: may produce invalid Compose output")
|
||||||
|
|
||||||
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")
|
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")
|
||||||
|
@ -18,6 +18,7 @@ Parse, resolve and render compose file in canonical format
|
|||||||
| `--no-consistency` | | | Don't check model consistency - warning: may produce invalid Compose output |
|
| `--no-consistency` | | | Don't check model consistency - warning: may produce invalid Compose output |
|
||||||
| `--no-interpolate` | | | Don't interpolate environment variables. |
|
| `--no-interpolate` | | | Don't interpolate environment variables. |
|
||||||
| `--no-normalize` | | | Don't normalize compose model. |
|
| `--no-normalize` | | | Don't normalize compose model. |
|
||||||
|
| `--no-path-resolution` | | | Don't resolve file paths. |
|
||||||
| `-o`, `--output` | `string` | | Save to file (default to stdout) |
|
| `-o`, `--output` | `string` | | Save to file (default to stdout) |
|
||||||
| `--profiles` | | | Print the profile names, one per line. |
|
| `--profiles` | | | Print the profile names, one per line. |
|
||||||
| `-q`, `--quiet` | | | Only validate the configuration, don't print anything. |
|
| `-q`, `--quiet` | | | Only validate the configuration, don't print anything. |
|
||||||
|
@ -69,6 +69,16 @@ options:
|
|||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
kubernetes: false
|
kubernetes: false
|
||||||
swarm: false
|
swarm: false
|
||||||
|
- option: no-path-resolution
|
||||||
|
value_type: bool
|
||||||
|
default_value: "false"
|
||||||
|
description: Don't resolve file paths.
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
- option: output
|
- option: output
|
||||||
shorthand: o
|
shorthand: o
|
||||||
value_type: string
|
value_type: string
|
||||||
|
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.20
|
|||||||
require (
|
require (
|
||||||
github.com/AlecAivazis/survey/v2 v2.3.6
|
github.com/AlecAivazis/survey/v2 v2.3.6
|
||||||
github.com/buger/goterm v1.0.4
|
github.com/buger/goterm v1.0.4
|
||||||
github.com/compose-spec/compose-go v1.13.4
|
github.com/compose-spec/compose-go v1.13.5
|
||||||
github.com/containerd/console v1.0.3
|
github.com/containerd/console v1.0.3
|
||||||
github.com/containerd/containerd v1.6.21
|
github.com/containerd/containerd v1.6.21
|
||||||
github.com/cucumber/godog v0.0.0-00010101000000-000000000000 // replaced; see replace for the actual version used
|
github.com/cucumber/godog v0.0.0-00010101000000-000000000000 // replaced; see replace for the actual version used
|
||||||
|
4
go.sum
4
go.sum
@ -165,8 +165,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH
|
|||||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/compose-spec/compose-go v1.13.4 h1:O6xAsPqaY1s9KXteiO7wRCDTJLahv1XP/z/eUO9EfbI=
|
github.com/compose-spec/compose-go v1.13.5 h1:ogqJOGEbe3uRxMg0ZEufOoCQTpX61l8tUeyW4UQgEBk=
|
||||||
github.com/compose-spec/compose-go v1.13.4/go.mod h1:rsiZ8uaOHJYJemDBzTe9UBpaq5ZFVEOO4TxM2G3SJxk=
|
github.com/compose-spec/compose-go v1.13.5/go.mod h1:m0o4G6MQDHjjz9rY7No9FpnNi+9sKic262rzrwuCqic=
|
||||||
github.com/containerd/cgroups v1.0.4 h1:jN/mbWBEaz+T1pi5OFtnkQ+8qnmEbAr1Oo1FRm5B0dA=
|
github.com/containerd/cgroups v1.0.4 h1:jN/mbWBEaz+T1pi5OFtnkQ+8qnmEbAr1Oo1FRm5B0dA=
|
||||||
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
|
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
|
||||||
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
|
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
|
||||||
|
@ -177,26 +177,13 @@ func TestEnvPriority(t *testing.T) {
|
|||||||
func TestEnvInterpolation(t *testing.T) {
|
func TestEnvInterpolation(t *testing.T) {
|
||||||
c := NewParallelCLI(t)
|
c := NewParallelCLI(t)
|
||||||
|
|
||||||
// No variable defined in the Compose file and nor env variable pass to the run command
|
|
||||||
// 1. Command Line (docker compose run --env <KEY[=VAL]>)
|
|
||||||
// 2. Compose File (service::environment section) <-- Result expected (From environment patched by .env as a default --env-file value)
|
|
||||||
// 3. Compose File (service::env_file section file)
|
|
||||||
// 4. Container Image ENV directive
|
|
||||||
// 5. Variable is not defined
|
|
||||||
t.Run("shell priority from run command", func(t *testing.T) {
|
t.Run("shell priority from run command", func(t *testing.T) {
|
||||||
cmd := c.NewDockerComposeCmd(t, "-f", "./fixtures/environment/env-interpolation/compose.yaml", "config")
|
cmd := c.NewDockerComposeCmd(t, "-f", "./fixtures/environment/env-interpolation/compose.yaml", "config")
|
||||||
cmd.Env = append(cmd.Env, "WHEREAMI=shell")
|
cmd.Env = append(cmd.Env, "WHEREAMI=shell")
|
||||||
res := icmd.RunCmd(cmd)
|
res := icmd.RunCmd(cmd)
|
||||||
res.Assert(t, icmd.Expected{Out: `IMAGE: default_env:EnvFile`})
|
res.Assert(t, icmd.Expected{Out: `IMAGE: default_env:shell`})
|
||||||
})
|
})
|
||||||
|
|
||||||
// No variable defined in the Compose file and env variable pass to the run command
|
|
||||||
// 1. Command Line (docker compose run --env <KEY[=VAL]>)
|
|
||||||
// 2. Compose File (service::environment section) <-- Result expected (From environment patched by .env as a default --env-file value.
|
|
||||||
// This variable has a default value in case of an absent variable in the OS environment)
|
|
||||||
// 3. Compose File (service::env_file section file)
|
|
||||||
// 4. Container Image ENV directive
|
|
||||||
// 5. Variable is not defined
|
|
||||||
t.Run("shell priority from run command using default value fallback", func(t *testing.T) {
|
t.Run("shell priority from run command using default value fallback", func(t *testing.T) {
|
||||||
c.RunDockerComposeCmd(t, "-f", "./fixtures/environment/env-interpolation-default-value/compose.yaml", "config").
|
c.RunDockerComposeCmd(t, "-f", "./fixtures/environment/env-interpolation-default-value/compose.yaml", "config").
|
||||||
Assert(t, icmd.Expected{Out: `IMAGE: default_env:EnvFileDefaultValue`})
|
Assert(t, icmd.Expected{Out: `IMAGE: default_env:EnvFileDefaultValue`})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user