Skip to content

Commit

Permalink
Merge pull request #988 from souleb/fix-aliased-deps-resolution
Browse files Browse the repository at this point in the history
Fix aliased chart dependencies resolution
  • Loading branch information
souleb authored Dec 19, 2022
2 parents 2eb984a + 6b5d0b1 commit 0f7a263
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controllers/helmchart_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
serror "github.com/fluxcd/source-controller/internal/error"
"github.com/fluxcd/source-controller/internal/helm/chart"
"github.com/fluxcd/source-controller/internal/helm/chart/secureloader"
"github.com/fluxcd/source-controller/internal/helm/registry"
"github.com/fluxcd/source-controller/internal/oci"
sreconcile "github.com/fluxcd/source-controller/internal/reconcile"
Expand Down Expand Up @@ -1159,6 +1160,11 @@ func TestHelmChartReconciler_buildFromTarballArtifact(t *testing.T) {
g.Expect(build.Version).To(Equal("0.1.0"))
g.Expect(build.ResolvedDependencies).To(Equal(4))
g.Expect(build.Path).To(BeARegularFile())
chart, err := secureloader.LoadFile(build.Path)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(chart.Metadata.Name).To(Equal("helmchartwithdeps"))
g.Expect(chart.Metadata.Version).To(Equal("0.1.0"))
g.Expect(chart.Dependencies()).To(HaveLen(4))
},
cleanFunc: func(g *WithT, build *chart.Build) {
g.Expect(os.Remove(build.Path)).To(Succeed())
Expand Down
8 changes: 8 additions & 0 deletions internal/helm/chart/dependency_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ func (dm *DependencyManager) addLocalDependency(ref LocalReference, c *chartWith
return err
}

if dep.Alias != "" {
ch.Metadata.Name = dep.Alias
}

c.mu.Lock()
c.AddDependency(ch)
c.mu.Unlock()
Expand Down Expand Up @@ -246,6 +250,10 @@ func (dm *DependencyManager) addRemoteDependency(chart *chartWithLock, dep *helm
return fmt.Errorf("failed to load downloaded archive of version '%s': %w", ver.Version, err)
}

if dep.Alias != "" {
ch.Metadata.Name = dep.Alias
}

chart.mu.Lock()
chart.AddDependency(ch)
chart.mu.Unlock()
Expand Down

0 comments on commit 0f7a263

Please sign in to comment.