Respect original Chart.yaml when 'helm create -p'

Signed-off-by: robert.holosynskyi <robert.holosynskyi@lightspeedhq.com>
pull/10055/head
robert.holosynskyi 4 years ago
parent c7502671ef
commit 0bbab7cbb9
No known key found for this signature in database
GPG Key ID: 01DE5E133936FCD4

@ -24,7 +24,6 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/helmpath"
)
@ -88,14 +87,6 @@ func (o *createOptions) run(out io.Writer) error {
fmt.Fprintf(out, "Creating %s\n", o.name)
chartname := filepath.Base(o.name)
cfile := &chart.Metadata{
Name: chartname,
Description: "A Helm chart for Kubernetes",
Type: "application",
Version: "0.1.0",
AppVersion: "0.1.0",
APIVersion: chart.APIVersionV2,
}
if o.starter != "" {
// Create from the starter
@ -104,7 +95,7 @@ func (o *createOptions) run(out io.Writer) error {
if filepath.IsAbs(o.starter) {
lstarter = o.starter
}
return chartutil.CreateFrom(cfile, filepath.Dir(o.name), lstarter)
return chartutil.CreateFrom(chartname, filepath.Dir(o.name), lstarter)
}
chartutil.Stderr = out

@ -511,13 +511,12 @@ spec:
var Stderr io.Writer = os.Stderr
// CreateFrom creates a new chart, but scaffolds it from the src chart.
func CreateFrom(chartfile *chart.Metadata, dest, src string) error {
func CreateFrom(chartname, dest, src string) error {
schart, err := loader.Load(src)
if err != nil {
return errors.Wrapf(err, "could not load %s", src)
}
schart.Metadata = chartfile
schart.Metadata.Name = chartname
var updatedTemplates []*chart.File

@ -23,7 +23,6 @@ import (
"path/filepath"
"testing"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
)
@ -76,25 +75,21 @@ func TestCreateFrom(t *testing.T) {
}
defer os.RemoveAll(tdir)
cf := &chart.Metadata{
APIVersion: chart.APIVersionV1,
Name: "foo",
Version: "0.1.0",
}
chartname := "foo"
srcdir := "./testdata/frobnitz/charts/mariner"
if err := CreateFrom(cf, tdir, srcdir); err != nil {
if err := CreateFrom(chartname, tdir, srcdir); err != nil {
t.Fatal(err)
}
dir := filepath.Join(tdir, "foo")
c := filepath.Join(tdir, cf.Name)
dir := filepath.Join(tdir, chartname)
c := filepath.Join(tdir, chartname)
mychart, err := loader.LoadDir(c)
if err != nil {
t.Fatalf("Failed to load newly created chart %q: %s", c, err)
}
if mychart.Name() != "foo" {
if mychart.Name() != chartname {
t.Errorf("Expected name to be 'foo', got %q", mychart.Name())
}

Loading…
Cancel
Save