parent
257c1f62d2
commit
f24b61f100
|
|
@ -149,7 +149,7 @@ func Parse(goGetterSrc string) (*Source, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Remote) Fetch(goGetterSrc string) (string, error) {
|
func (r *Remote) Fetch(goGetterSrc string, cacheDirOpt ...string) (string, error) {
|
||||||
u, err := Parse(goGetterSrc)
|
u, err := Parse(goGetterSrc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
@ -167,6 +167,11 @@ func (r *Remote) Fetch(goGetterSrc string) (string, error) {
|
||||||
|
|
||||||
// This should be shared across variant commands, so that they can share cache for the shared imports
|
// This should be shared across variant commands, so that they can share cache for the shared imports
|
||||||
cacheBaseDir := DefaultCacheDir
|
cacheBaseDir := DefaultCacheDir
|
||||||
|
if len(cacheDirOpt) == 1 {
|
||||||
|
cacheBaseDir = cacheDirOpt[0]
|
||||||
|
} else if len(cacheDirOpt) > 0 {
|
||||||
|
return "", fmt.Errorf("[bug] cacheDirOpt's length: want 0 or 1, got %d", len(cacheDirOpt))
|
||||||
|
}
|
||||||
|
|
||||||
query := u.RawQuery
|
query := u.RawQuery
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,27 @@ type Chartify struct {
|
||||||
Clean func()
|
Clean func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *HelmState) goGetterChart(chart, dir string, force bool) (string, error) {
|
func (st *HelmState) downloadChartWithGoGetter(r *ReleaseSpec) (string, error) {
|
||||||
|
pathElems := []string{
|
||||||
|
remote.DefaultCacheDir,
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Namespace != "" {
|
||||||
|
pathElems = append(pathElems, r.Namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.KubeContext != "" {
|
||||||
|
pathElems = append(pathElems, r.KubeContext)
|
||||||
|
}
|
||||||
|
|
||||||
|
pathElems = append(pathElems, r.Name, r.Chart)
|
||||||
|
|
||||||
|
cacheDir := filepath.Join(pathElems...)
|
||||||
|
|
||||||
|
return st.goGetterChart(r.Chart, r.Directory, cacheDir, r.ForceGoGetter)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (st *HelmState) goGetterChart(chart, dir, cacheDir string, force bool) (string, error) {
|
||||||
if dir != "" && chart == "" {
|
if dir != "" && chart == "" {
|
||||||
chart = dir
|
chart = dir
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +72,7 @@ func (st *HelmState) goGetterChart(chart, dir string, force bool) (string, error
|
||||||
} else {
|
} else {
|
||||||
r := remote.NewRemote(st.logger, st.basePath, st.readFile, directoryExistsAt, fileExistsAt)
|
r := remote.NewRemote(st.logger, st.basePath, st.readFile, directoryExistsAt, fileExistsAt)
|
||||||
|
|
||||||
fetchedDir, err := r.Fetch(chart)
|
fetchedDir, err := r.Fetch(chart, cacheDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("fetching %q: %v", chart, err)
|
return "", fmt.Errorf("fetching %q: %v", chart, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -979,15 +979,13 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
|
||||||
|
|
||||||
chartName := release.Chart
|
chartName := release.Chart
|
||||||
|
|
||||||
chartPath, err := st.goGetterChart(chartName, release.Directory, release.ForceGoGetter)
|
chartPath, err := st.downloadChartWithGoGetter(release)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)}
|
results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
chartFetchedByGoGetter := chartPath != chartName
|
chartFetchedByGoGetter := chartPath != chartName
|
||||||
|
|
||||||
var isOCI bool
|
|
||||||
|
|
||||||
if !chartFetchedByGoGetter {
|
if !chartFetchedByGoGetter {
|
||||||
ociChartPath, err := st.getOCIChart(release, dir, helm)
|
ociChartPath, err := st.getOCIChart(release, dir, helm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -998,7 +996,6 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
|
||||||
|
|
||||||
if ociChartPath != nil {
|
if ociChartPath != nil {
|
||||||
chartPath = *ociChartPath
|
chartPath = *ociChartPath
|
||||||
isOCI = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1016,7 +1013,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
|
||||||
|
|
||||||
if chartification != nil {
|
if chartification != nil {
|
||||||
c := chartify.New(
|
c := chartify.New(
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ func TestGoGetter(t *testing.T) {
|
||||||
basePath: d,
|
basePath: d,
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := st.goGetterChart(tc.chart, tc.dir, false)
|
out, err := st.goGetterChart(tc.chart, tc.dir, "", false)
|
||||||
|
|
||||||
if diff := cmp.Diff(tc.out, out); diff != "" {
|
if diff := cmp.Diff(tc.out, out); diff != "" {
|
||||||
t.Fatalf("Unexpected out:\n%s", diff)
|
t.Fatalf("Unexpected out:\n%s", diff)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue