Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Suleiman Dibirov <[email protected]>
  • Loading branch information
idsulik committed Jan 28, 2025
1 parent 0117802 commit 58da1a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions pkg/skaffold/deploy/helm/dependencygraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func NewDependencyGraph(releases []latest.HelmRelease) (*DependencyGraph, error)
if !releaseNames[dep] {
return nil, fmt.Errorf("release %s depends on non-existent release %s", r.Name, dep)
}
if r.Name == dep {
return nil, fmt.Errorf("release %s cannot depend on itself", r.Name)
}
hasDependencies = true
}
graph[r.Name] = r.DependsOn
Expand Down
20 changes: 15 additions & 5 deletions pkg/skaffold/deploy/helm/dependencygraph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import (

func TestNewDependencyGraph(t *testing.T) {
tests := []struct {
description string
releases []latest.HelmRelease
expected map[string][]string
shouldErr bool
description string
releases []latest.HelmRelease
expected map[string][]string
shouldErr bool
errorMessage string
}{
{
description: "simple dependency graph",
Expand Down Expand Up @@ -73,6 +74,15 @@ func TestNewDependencyGraph(t *testing.T) {
{Name: "release2"},
},
shouldErr: true,
errorMessage: "release release1 depends on non-existent release release3",
},
{
description: "dependency on self",
releases: []latest.HelmRelease{
{Name: "release1", DependsOn: []string{"release1"}},
},
shouldErr: true,
errorMessage: "release release1 cannot depend on itself",
},
}

Expand All @@ -81,7 +91,7 @@ func TestNewDependencyGraph(t *testing.T) {
graph, err := NewDependencyGraph(test.releases)

if test.shouldErr {
t.CheckError(test.shouldErr, err)
t.CheckErrorContains(test.errorMessage, err)
return
}
t.CheckDeepEqual(len(test.expected), len(graph.graph))
Expand Down

0 comments on commit 58da1a6

Please sign in to comment.