Fixes issue where <CHARTNAME> is left in starter values file

This is a leftover bug from #7201.

Closes #7532

Signed-off-by: Matt Farina <matt@mattfarina.com>
pull/7542/head
Matt Farina 5 years ago
parent 0dce5c1418
commit 1bd819a7b2
No known key found for this signature in database
GPG Key ID: 9436E80BFBA46909

@ -445,6 +445,15 @@ func CreateFrom(chartfile *chart.Metadata, dest, src string) error {
}
schart.Values = m
// SaveDir looks for the file values.yaml when saving rather than the values
// key in order to preserve the comments in the YAML. The name placeholder
// needs to be replaced on that file.
for _, f := range schart.Raw {
if f.Name == ValuesfileName {
f.Data = transform(string(f.Data), schart.Name())
}
}
return SaveDir(schart, dest)
}

@ -17,6 +17,7 @@ limitations under the License.
package chartutil
import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
@ -105,5 +106,14 @@ func TestCreateFrom(t *testing.T) {
if _, err := os.Stat(filepath.Join(dir, f)); err != nil {
t.Errorf("Expected %s file: %s", f, err)
}
// Check each file to make sure <CHARTNAME> has been replaced
b, err := ioutil.ReadFile(filepath.Join(dir, f))
if err != nil {
t.Errorf("Unable to read file %s: %s", f, err)
}
if bytes.Contains(b, []byte("<CHARTNAME>")) {
t.Errorf("File %s contains <CHARTNAME>", f)
}
}
}

Loading…
Cancel
Save