diff --git a/internal/helm/chart/builder_local.go b/internal/helm/chart/builder_local.go index ed9b7baf..96358881 100644 --- a/internal/helm/chart/builder_local.go +++ b/internal/helm/chart/builder_local.go @@ -99,13 +99,16 @@ func (b *localChartBuilder) Build(ctx context.Context, ref Reference, p string, } // If all the following is true, we do not need to package the chart: - // - Chart version from current metadata matches calculated version + // - Chart name from cached chart matches resolved name + // - Chart version from cached chart matches calculated version // - BuildOptions.Force is False if opts.CachedChart != "" && !opts.Force { - if curMeta, err = LoadChartMetadataFromArchive(opts.CachedChart); err == nil && result.Version == curMeta.Version { - result.Path = opts.CachedChart - result.ValuesFiles = opts.ValuesFiles - return result, nil + if curMeta, err = LoadChartMetadataFromArchive(opts.CachedChart); err == nil { + if result.Name == curMeta.Name && result.Version == curMeta.Version { + result.Path = opts.CachedChart + result.ValuesFiles = opts.ValuesFiles + return result, nil + } } } diff --git a/internal/helm/chart/builder_remote.go b/internal/helm/chart/builder_remote.go index ab58d0e8..617e2ec5 100644 --- a/internal/helm/chart/builder_remote.go +++ b/internal/helm/chart/builder_remote.go @@ -103,13 +103,16 @@ func (b *remoteChartBuilder) Build(_ context.Context, ref Reference, p string, o } // If all the following is true, we do not need to download and/or build the chart: - // - Chart version from current metadata matches calculated version + // - Chart name from cached chart matches resolved name + // - Chart version from cached chart matches calculated version // - BuildOptions.Force is False if opts.CachedChart != "" && !opts.Force { - if curMeta, err := LoadChartMetadataFromArchive(opts.CachedChart); err == nil && result.Version == curMeta.Version { - result.Path = opts.CachedChart - result.ValuesFiles = opts.GetValuesFiles() - return result, nil + if curMeta, err := LoadChartMetadataFromArchive(opts.CachedChart); err == nil { + if result.Name == curMeta.Name && result.Version == curMeta.Version { + result.Path = opts.CachedChart + result.ValuesFiles = opts.GetValuesFiles() + return result, nil + } } } diff --git a/internal/helm/chart/builder_remote_test.go b/internal/helm/chart/builder_remote_test.go index a2c33a6f..56c1fd85 100644 --- a/internal/helm/chart/builder_remote_test.go +++ b/internal/helm/chart/builder_remote_test.go @@ -207,11 +207,12 @@ func TestRemoteBuilder_Build_CachedChart(t *testing.T) { index := []byte(` apiVersion: v1 entries: - grafana: + helmchart: - urls: - - https://example.com/grafana.tgz + - https://example.com/helmchart-0.1.0.tgz description: string version: 0.1.0 + name: helmchart `) mockGetter := &mockIndexChartGetter{ @@ -226,7 +227,7 @@ entries: } } - reference := RemoteReference{Name: "grafana"} + reference := RemoteReference{Name: "helmchart"} repository := mockRepo() _, err = repository.CacheIndex()