feat(cmd) Add Pluggable InMemory Cache for downloading charts

This feature allows us to use the --use-inmemory-cache flag to
use a chart without downloading it to the helm repository cache,
instead which is downloaded to InMemoryCache

Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
pull/7758/head
Vibhav Bobade 6 years ago
parent fa5eb64f32
commit 9464070ede

@ -19,6 +19,8 @@ package main
import (
"fmt"
"io"
"os"
"strings"
"time"
"github.com/pkg/errors"
@ -151,6 +153,7 @@ func addInstallFlags(f *pflag.FlagSet, client *action.Install, valueOpts *values
f.BoolVar(&client.Atomic, "atomic", false, "if set, the installation process deletes the installation on failure. The --wait flag will be set automatically if --atomic is used")
f.BoolVar(&client.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed. By default, CRDs are installed if not already present")
f.BoolVar(&client.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent")
f.BoolVar(&client.ReadOnlyFS, "readonly-fs", false, "if set, do not download charts to the HELM_REPOSITORY_CACHE")
addValueOptionsFlags(f, valueOpts)
addChartPathOptionsFlags(f, &client.ChartPathOptions)
}
@ -162,13 +165,13 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
client.Version = ">0.0.0-0"
}
name, chart, err := client.NameAndChart(args)
name, schart, err := client.NameAndChart(args)
if err != nil {
return nil, err
}
client.ReleaseName = name
cp, err := client.ChartPathOptions.LocateChart(chart, settings)
cp, err := client.ChartPathOptions.LocateChart(schart, settings)
if err != nil {
return nil, err
}
@ -181,8 +184,17 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
return nil, err
}
// Check chart dependencies to make sure all are present in /charts
chartRequested, err := loader.Load(cp)
// Check chart dependencies to make sure all are present in the inMemoryCache or in /charts
var chartRequested *chart.Chart
if client.ReadOnlyFS {
if _, err = os.Stat(cp); err == nil {
chartRequested, err = loader.Load(cp)
} else {
chartRequested, err = downloader.GetChart(schart, strings.TrimSpace(client.ChartPathOptions.Version))
}
} else {
chartRequested, err = loader.Load(cp)
}
if err != nil {
return nil, err
}

@ -195,6 +195,12 @@ func TestInstall(t *testing.T) {
cmd: "install aeneas testdata/testcharts/deprecated --namespace default",
golden: "output/deprecated-chart.txt",
},
// Install with non url and in-memory-cache enabled
{
name: "install with inMemory cache enabled ",
cmd: "install cached testdata/testcharts/empty --namespace default --use-inmemory-cache",
wantError: true,
},
}
runTestActionCmd(t, tests)

Loading…
Cancel
Save