diff --git a/pkg/action/action.go b/pkg/action/action.go index 79bb4f638..e08c37ca7 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -21,7 +21,6 @@ import ( "fmt" "os" "path" - "path/filepath" "regexp" "strings" @@ -177,20 +176,10 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values } return hs, b, "", err } - - // Aggregate all valid manifests into one big doc. - fileWritten := make(map[string]bool) - if includeCrds { for _, crd := range ch.CRDObjects() { if outputDir == "" { fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Name, string(crd.File.Data[:])) - } else { - err = writeToFile(outputDir, crd.Filename, string(crd.File.Data[:]), fileWritten[crd.Name]) - if err != nil { - return hs, b, "", err - } - fileWritten[crd.Name] = true } } } @@ -198,20 +187,6 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values for _, m := range manifests { if outputDir == "" { fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) - } else { - newDir := outputDir - if useReleaseName { - newDir = filepath.Join(outputDir, releaseName) - } - // NOTE: We do not have to worry about the post-renderer because - // output dir is only used by `helm template`. In the next major - // release, we should move this logic to template only as it is not - // used by install or upgrade - err = writeToFile(newDir, m.Name, m.Content, fileWritten[m.Name]) - if err != nil { - return hs, b, "", err - } - fileWritten[m.Name] = true } } diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 2237e1de6..8c33af1b1 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -19,16 +19,12 @@ package action import ( "fmt" "io/ioutil" - "log" - "os" - "path/filepath" "regexp" "strings" "testing" "github.com/stretchr/testify/assert" - "helm.sh/helm/v3/internal/test" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chartutil" kubefake "helm.sh/helm/v3/pkg/kube/fake" @@ -489,82 +485,6 @@ func TestNameTemplate(t *testing.T) { } } -func TestInstallReleaseOutputDir(t *testing.T) { - is := assert.New(t) - instAction := installAction(t) - vals := map[string]interface{}{} - - dir, err := ioutil.TempDir("", "output-dir") - if err != nil { - log.Fatal(err) - } - defer os.RemoveAll(dir) - - instAction.OutputDir = dir - - _, err = instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals) - if err != nil { - t.Fatalf("Failed install: %s", err) - } - - _, err = os.Stat(filepath.Join(dir, "hello/templates/goodbye")) - is.NoError(err) - - _, err = os.Stat(filepath.Join(dir, "hello/templates/hello")) - is.NoError(err) - - _, err = os.Stat(filepath.Join(dir, "hello/templates/with-partials")) - is.NoError(err) - - _, err = os.Stat(filepath.Join(dir, "hello/templates/rbac")) - is.NoError(err) - - test.AssertGoldenFile(t, filepath.Join(dir, "hello/templates/rbac"), "rbac.txt") - - _, err = os.Stat(filepath.Join(dir, "hello/templates/empty")) - is.True(os.IsNotExist(err)) -} - -func TestInstallOutputDirWithReleaseName(t *testing.T) { - is := assert.New(t) - instAction := installAction(t) - vals := map[string]interface{}{} - - dir, err := ioutil.TempDir("", "output-dir") - if err != nil { - log.Fatal(err) - } - defer os.RemoveAll(dir) - - instAction.OutputDir = dir - instAction.UseReleaseName = true - instAction.ReleaseName = "madra" - - newDir := filepath.Join(dir, instAction.ReleaseName) - - _, err = instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals) - if err != nil { - t.Fatalf("Failed install: %s", err) - } - - _, err = os.Stat(filepath.Join(newDir, "hello/templates/goodbye")) - is.NoError(err) - - _, err = os.Stat(filepath.Join(newDir, "hello/templates/hello")) - is.NoError(err) - - _, err = os.Stat(filepath.Join(newDir, "hello/templates/with-partials")) - is.NoError(err) - - _, err = os.Stat(filepath.Join(newDir, "hello/templates/rbac")) - is.NoError(err) - - test.AssertGoldenFile(t, filepath.Join(newDir, "hello/templates/rbac"), "rbac.txt") - - _, err = os.Stat(filepath.Join(newDir, "hello/templates/empty")) - is.True(os.IsNotExist(err)) -} - func TestNameAndChart(t *testing.T) { is := assert.New(t) instAction := installAction(t)