Fix OCI support (#1667)

* Fix OCI support

I have seen various issues related to the OCI repository support recently added to Helmfile.
This is the patch that should fix all the issues Im aware of until now.
This commit is contained in:
Yusuke Kuoka 2021-02-04 09:33:35 +09:00 committed by GitHub
parent 4e1ecb5890
commit 257c1f62d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 19 deletions

View File

@ -986,10 +986,20 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
} }
chartFetchedByGoGetter := chartPath != chartName chartFetchedByGoGetter := chartPath != chartName
isOCI, chartPath, err := st.getOCIChart(release, dir, helm) var isOCI bool
if err != nil {
results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)} if !chartFetchedByGoGetter {
return ociChartPath, err := st.getOCIChart(release, dir, helm)
if err != nil {
results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)}
return
}
if ociChartPath != nil {
chartPath = *ociChartPath
isOCI = true
}
} }
isLocal := st.directoryExistsAt(normalizeChart(st.basePath, chartName)) isLocal := st.directoryExistsAt(normalizeChart(st.basePath, chartName))
@ -1006,7 +1016,7 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
skipDepsGlobal := opts.SkipDeps skipDepsGlobal := opts.SkipDeps
skipDepsRelease := release.SkipDeps != nil && *release.SkipDeps skipDepsRelease := release.SkipDeps != nil && *release.SkipDeps
skipDepsDefault := release.SkipDeps == nil && st.HelmDefaults.SkipDeps skipDepsDefault := release.SkipDeps == nil && st.HelmDefaults.SkipDeps
skipDeps := !isLocal || skipDepsGlobal || skipDepsRelease || skipDepsDefault || !isOCI skipDeps := !isLocal || skipDepsGlobal || skipDepsRelease || skipDepsDefault || isOCI
if chartification != nil { if chartification != nil {
c := chartify.New( c := chartify.New(
@ -2978,21 +2988,14 @@ func (st *HelmState) Reverse() {
} }
} }
func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helmexec.Interface) (bool, string, error) { func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helmexec.Interface) (*string, error) {
isOCI := false
repo, name := st.GetRepositoryAndNameFromChartName(release.Chart) repo, name := st.GetRepositoryAndNameFromChartName(release.Chart)
if repo == nil { if repo == nil {
return false, release.Chart, nil return nil, nil
} }
if repo.OCI { if !repo.OCI {
isOCI = true return nil, nil
}
if !isOCI {
return isOCI, release.Chart, nil
} }
chartVersion := "latest" chartVersion := "latest"
@ -3004,7 +3007,7 @@ func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helm
err := helm.ChartPull(qualifiedChartName) err := helm.ChartPull(qualifiedChartName)
if err != nil { if err != nil {
return isOCI, release.Chart, err return nil, err
} }
pathElems := []string{ pathElems := []string{
@ -3026,9 +3029,10 @@ func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helm
fullChartPath, err := findChartDirectory(chartPath) fullChartPath, err := findChartDirectory(chartPath)
if err != nil { if err != nil {
return isOCI, release.Chart, err return nil, err
} }
chartPath = filepath.Dir(fullChartPath) chartPath = filepath.Dir(fullChartPath)
return isOCI, chartPath, nil
return &chartPath, nil
} }