Skip to content

Commit dadfe16

Browse files
authored
Merge pull request #2556 from lizardruss/cyclic-dependency-warning
fix: silence warning for cyclic dependency root
2 parents 9d39a99 + 4a61183 commit dadfe16

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

e2e/tests/dependencies/dependencies.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package dependencies
22

33
import (
4+
"bytes"
45
"context"
56
ginkgo "github.com/onsi/ginkgo/v2"
7+
"github.com/onsi/gomega"
8+
"github.com/sirupsen/logrus"
69
"os"
710
"path/filepath"
811
"time"
@@ -55,16 +58,23 @@ var _ = DevSpaceDescribe("dependencies", func() {
5558
}()
5659

5760
// create a new dev command and start it
61+
output := &bytes.Buffer{}
5862
devCmd := &cmd.RunPipelineCmd{
5963
GlobalFlags: &flags.GlobalFlags{
6064
NoWarn: true,
6165
Namespace: ns,
6266
ConfigPath: "devspace.yaml",
6367
},
6468
Pipeline: "dev",
69+
Log: log.NewStreamLogger(output, output, logrus.DebugLevel),
6570
}
6671
err = devCmd.RunDefault(f)
6772
framework.ExpectNoError(err)
73+
74+
// Expect no multiple dependency warning
75+
gomega.Expect(output.String()).NotTo(
76+
gomega.ContainSubstring("Seems like you have multiple dependencies with name"),
77+
)
6878
})
6979

7080
ginkgo.It("should wait for dependencies", func() {
@@ -478,7 +488,7 @@ dep2dep2wait
478488
framework.ExpectEqual(len(list.Items), 0)
479489
})
480490

481-
ginkgo.It("should resolve and deploy cyclic dependencies", func() {
491+
ginkgo.It("should resolve and deploy cyclic git dependencies", func() {
482492
tempDir, err := framework.CopyToTempDir("tests/dependencies/testdata/cyclic")
483493
framework.ExpectNoError(err)
484494
defer framework.CleanupTempDir(initialDir, tempDir)
@@ -499,18 +509,25 @@ dep2dep2wait
499509
framework.ExpectEqual(dependencies[0].Name(), "dependency")
500510

501511
// create a new deploy command
512+
output := &bytes.Buffer{}
502513
deployCmd := &cmd.RunPipelineCmd{
503514
GlobalFlags: &flags.GlobalFlags{
504515
NoWarn: true,
505516
Namespace: ns,
506517
},
507518
Pipeline: "deploy",
519+
Log: log.NewStreamLogger(output, output, logrus.DebugLevel),
508520
}
509521

510522
// run the command
511523
err = deployCmd.RunDefault(f)
512524
framework.ExpectNoError(err)
513525

526+
// Expect no multiple dependency warning
527+
gomega.Expect(output.String()).NotTo(
528+
gomega.ContainSubstring("Seems like you have multiple dependencies with name"),
529+
)
530+
514531
// expect single deployment
515532
_, err = kubeClient.RawClient().AppsV1().Deployments(ns).Get(context.TODO(), "nginx", metav1.GetOptions{})
516533
framework.ExpectNoError(err)

e2e/tests/dependencies/testdata/cyclic/dependency2/devspace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ version: v2beta1
33
dependencies:
44
dependency:
55
path: ../dependency
6+
root:
7+
git: https://github.com/devspace-sh/devspace.git
8+
subPath: e2e/tests/dependencies/testdata/cyclic
69

710
deployments:
811
nginx2:

pkg/devspace/dependency/resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (r *resolver) resolveRecursive(ctx devspacecontext.Context, basePath, paren
136136
)
137137
if n, ok := r.DependencyGraph.Nodes[dependencyConfig.Name]; ok {
138138
child = n.Data.(*Dependency)
139-
if child != nil && child.Config() != nil && child.Config().Path() != dependencyConfigPath {
139+
if child != nil && child.Config() != nil && child.Config().Path() != dependencyConfigPath && !child.Root() {
140140
ctx.Log().Warnf("Seems like you have multiple dependencies with name %s, but they use different source settings (%s != %s). This can lead to unexpected results and you should make sure that the devspace.yaml name is unique across your dependencies or that you use the dependencies.overrideName option", child.name, child.Config().Path(), dependencyConfigPath)
141141
}
142142

0 commit comments

Comments
 (0)