Commit 864d2783 authored by Matt Butcher's avatar Matt Butcher

fix(helm): prevent 'helm history' from segfaulting

An release that does not contain chart metadata cannot print its chart
name/version. This fixes a bug found in the wild where a release did not
(for reasons yet unknown) contain a chart.

Closes #1348
parent 62e4d8ca
......@@ -24,6 +24,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/timeconv"
)
......@@ -98,7 +99,7 @@ func formatHistory(rls []*release.Release) string {
tbl.AddRow("REVISION", "UPDATED", "STATUS", "CHART")
for i := len(rls) - 1; i >= 0; i-- {
r := rls[i]
c := fmt.Sprintf("%s-%s", r.Chart.Metadata.Name, r.Chart.Metadata.Version)
c := formatChartname(r.Chart)
t := timeconv.String(r.Info.LastDeployed)
s := r.Info.Status.Code.String()
v := r.Version
......@@ -106,3 +107,12 @@ func formatHistory(rls []*release.Release) string {
}
return tbl.String()
}
func formatChartname(c *chart.Chart) string {
if c == nil || c.Metadata == nil {
// This is an edge case that has happened in prod, though we don't
// know how: https://github.com/kubernetes/helm/issues/1347
return "MISSING"
}
return fmt.Sprintf("%s-%s", c.Metadata.Name, c.Metadata.Version)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment