Merge pull request #6678 from sidharthsurana/fix-nil-pointer-load

Fix the ordering of the APIVersion check to avoid nil pointer
pull/6661/head
Matthew Fisher 5 years ago committed by GitHub
commit e7413bd61c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -104,12 +104,12 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
// Deprecated: requirements.yaml is deprecated use Chart.yaml. // Deprecated: requirements.yaml is deprecated use Chart.yaml.
// We will handle it for you because we are nice people // We will handle it for you because we are nice people
case f.Name == "requirements.yaml": case f.Name == "requirements.yaml":
if c.Metadata.APIVersion != chart.APIVersionV1 {
log.Printf("Warning: Dependencies are handled in Chart.yaml since apiVersion \"v2\". We recommend migrating dependencies to Chart.yaml.")
}
if c.Metadata == nil { if c.Metadata == nil {
c.Metadata = new(chart.Metadata) c.Metadata = new(chart.Metadata)
} }
if c.Metadata.APIVersion != chart.APIVersionV1 {
log.Printf("Warning: Dependencies are handled in Chart.yaml since apiVersion \"v2\". We recommend migrating dependencies to Chart.yaml.")
}
if err := yaml.Unmarshal(f.Data, c.Metadata); err != nil { if err := yaml.Unmarshal(f.Data, c.Metadata); err != nil {
return c, errors.Wrap(err, "cannot load requirements.yaml") return c, errors.Wrap(err, "cannot load requirements.yaml")
} }

@ -58,6 +58,19 @@ func TestLoadV1(t *testing.T) {
verifyDependenciesLock(t, c) verifyDependenciesLock(t, c)
} }
func TestLoadFileV1(t *testing.T) {
l, err := Loader("testdata/frobnitz.v1.tgz")
if err != nil {
t.Fatalf("Failed to load testdata: %s", err)
}
c, err := l.Load()
if err != nil {
t.Fatalf("Failed to load testdata: %s", err)
}
verifyDependencies(t, c)
verifyDependenciesLock(t, c)
}
func TestLoadFile(t *testing.T) { func TestLoadFile(t *testing.T) {
l, err := Loader("testdata/frobnitz-1.2.3.tgz") l, err := Loader("testdata/frobnitz-1.2.3.tgz")
if err != nil { if err != nil {

Binary file not shown.
Loading…
Cancel
Save