diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 21a41b9f9..9f8069335 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -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 } diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index e3013d713..350a931ad 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -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)