Skip to content

Commit

Permalink
Fix OCI support (#1667)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mumoshu authored Feb 4, 2021
1 parent 4e1ecb5 commit 257c1f6
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,20 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
}
chartFetchedByGoGetter := chartPath != chartName

isOCI, chartPath, err := st.getOCIChart(release, dir, helm)
if err != nil {
results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)}
return
var isOCI bool

if !chartFetchedByGoGetter {
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))
Expand All @@ -1006,7 +1016,7 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
skipDepsGlobal := opts.SkipDeps
skipDepsRelease := release.SkipDeps != nil && *release.SkipDeps
skipDepsDefault := release.SkipDeps == nil && st.HelmDefaults.SkipDeps
skipDeps := !isLocal || skipDepsGlobal || skipDepsRelease || skipDepsDefault || !isOCI
skipDeps := !isLocal || skipDepsGlobal || skipDepsRelease || skipDepsDefault || isOCI

if chartification != nil {
c := chartify.New(
Expand Down Expand Up @@ -2978,21 +2988,14 @@ func (st *HelmState) Reverse() {
}
}

func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helmexec.Interface) (bool, string, error) {

isOCI := false

func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helmexec.Interface) (*string, error) {
repo, name := st.GetRepositoryAndNameFromChartName(release.Chart)
if repo == nil {
return false, release.Chart, nil
}

if repo.OCI {
isOCI = true
return nil, nil
}

if !isOCI {
return isOCI, release.Chart, nil
if !repo.OCI {
return nil, nil
}

chartVersion := "latest"
Expand All @@ -3004,7 +3007,7 @@ func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helm

err := helm.ChartPull(qualifiedChartName)
if err != nil {
return isOCI, release.Chart, err
return nil, err
}

pathElems := []string{
Expand All @@ -3026,9 +3029,10 @@ func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helm

fullChartPath, err := findChartDirectory(chartPath)
if err != nil {
return isOCI, release.Chart, err
return nil, err
}

chartPath = filepath.Dir(fullChartPath)
return isOCI, chartPath, nil

return &chartPath, nil
}

0 comments on commit 257c1f6

Please sign in to comment.