Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nil pointer panic #26

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions pkg/cmd/describer/k8sdb_describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package describer
import (
"fmt"
"io"
"time"

"github.com/golang/glog"
tapi "github.com/k8sdb/apimachinery/api"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (d *humanReadableDescriber) describeElastic(item *tapi.Elastic, describerSe
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", item.Name)
fmt.Fprintf(out, "Namespace:\t%s\n", item.Namespace)
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", item.CreationTimestamp.Time.Format(time.RFC1123Z))
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", timeToString(&item.CreationTimestamp))
if item.Labels != nil {
printLabelsMultiline(out, "Labels:", item.Labels)
}
Expand Down Expand Up @@ -119,7 +118,7 @@ func (d *humanReadableDescriber) describePostgres(item *tapi.Postgres, describer
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", item.Name)
fmt.Fprintf(out, "Namespace:\t%s\n", item.Namespace)
fmt.Fprintf(out, "StartTimestamp:\t%s\n", item.CreationTimestamp.Time.Format(time.RFC1123Z))
fmt.Fprintf(out, "StartTimestamp:\t%s\n", timeToString(&item.CreationTimestamp))
if item.Labels != nil {
printLabelsMultiline(out, "Labels:", item.Labels)
}
Expand Down Expand Up @@ -173,9 +172,9 @@ func (d *humanReadableDescriber) describeSnapshot(item *tapi.Snapshot, describer
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", item.Name)
fmt.Fprintf(out, "Namespace:\t%s\n", item.Namespace)
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", item.CreationTimestamp.Format(time.RFC1123Z))
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", timeToString(&item.CreationTimestamp))
if item.Status.CompletionTime != nil {
fmt.Fprintf(out, "CompletionTimestamp:\t%s\n", item.Status.CompletionTime.Format(time.RFC1123Z))
fmt.Fprintf(out, "CompletionTimestamp:\t%s\n", timeToString(item.Status.CompletionTime))
}
if item.Labels != nil {
printLabelsMultiline(out, "Labels:", item.Labels)
Expand Down Expand Up @@ -220,12 +219,12 @@ func (d *humanReadableDescriber) describeDeletedDatabase(item *tapi.DeletedDatab
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", item.Name)
fmt.Fprintf(out, "Namespace:\t%s\n", item.Namespace)
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", item.CreationTimestamp.Format(time.RFC1123Z))
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", timeToString(&item.CreationTimestamp))
if item.Status.DeletionTime != nil {
fmt.Fprintf(out, "DeletionTimestamp:\t%s\n", item.Status.DeletionTime.Format(time.RFC1123Z))
fmt.Fprintf(out, "DeletionTimestamp:\t%s\n", timeToString(item.Status.DeletionTime))
}
if item.Status.WipeOutTime != nil {
fmt.Fprintf(out, "WipeOutTimestamp:\t%s\n", item.Status.WipeOutTime.Format(time.RFC1123Z))
fmt.Fprintf(out, "WipeOutTimestamp:\t%s\n", timeToString(item.Status.WipeOutTime))
}
if item.Labels != nil {
printLabelsMultiline(out, "Labels:", item.Labels)
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/describer/kube_describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"sort"
"strings"
"time"

"github.com/k8sdb/kubedb/pkg/cmd/printer"
"github.com/k8sdb/kubedb/pkg/cmd/util"
Expand Down Expand Up @@ -43,7 +42,7 @@ func (d *humanReadableDescriber) describeStatefulSet(namespace, name string, out
fmt.Fprint(out, "StatefulSet:\t\n")
fmt.Fprintf(out, " Name:\t%s\n", ps.Name)
fmt.Fprintf(out, " Replicas:\t%d current / %d desired\n", ps.Status.Replicas, ps.Spec.Replicas)
fmt.Fprintf(out, " CreationTimestamp:\t%s\n", ps.CreationTimestamp.Time.Format(time.RFC1123Z))
fmt.Fprintf(out, " CreationTimestamp:\t%s\n", timeToString(&ps.CreationTimestamp))
fmt.Fprintf(out, " Pods Status:\t%d Running / %d Waiting / %d Succeeded / %d Failed\n", running, waiting, succeeded, failed)
}

Expand Down