mirror of https://github.com/docker/compose.git
Apply no-deps before we select and mutate target service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
e90df62bb0
commit
e6a7694b8d
|
@ -63,6 +63,13 @@ type runOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (options runOptions) apply(project *types.Project) error {
|
func (options runOptions) apply(project *types.Project) error {
|
||||||
|
if options.noDeps {
|
||||||
|
err := project.ForServices([]string{options.Service}, types.IgnoreDependencies)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
target, err := project.GetService(options.Service)
|
target, err := project.GetService(options.Service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -93,13 +100,6 @@ func (options runOptions) apply(project *types.Project) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.noDeps {
|
|
||||||
err := project.ForServices([]string{options.Service}, types.IgnoreDependencies)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, s := range project.Services {
|
for i, s := range project.Services {
|
||||||
if s.Name == options.Service {
|
if s.Name == options.Service {
|
||||||
project.Services[i] = target
|
project.Services[i] = target
|
||||||
|
|
|
@ -136,4 +136,12 @@ func TestLocalComposeRun(t *testing.T) {
|
||||||
|
|
||||||
c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/deps.yaml", "down", "--remove-orphans")
|
c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/deps.yaml", "down", "--remove-orphans")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("run without dependencies", func(t *testing.T) {
|
||||||
|
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/deps.yaml", "run", "--no-deps", "service_a")
|
||||||
|
assert.Assert(t, !strings.Contains(res.Combined(), "shared_dep"), res.Combined())
|
||||||
|
assert.Assert(t, !strings.Contains(res.Combined(), "service_b"), res.Combined())
|
||||||
|
|
||||||
|
c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/deps.yaml", "down", "--remove-orphans")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue