Merge pull request #40 from cmars/upstream-fix-nodes-nil-lastseen

Fix nil dereference in nodes list command.
This commit is contained in:
Juan Font 2021-06-20 11:12:10 +02:00 committed by GitHub
commit 73186eeb2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"strings"
"time"
"github.com/spf13/cobra"
)
@ -71,7 +72,11 @@ var ListNodesCmd = &cobra.Command{
if m.AuthKey != nil && m.AuthKey.Ephemeral {
ephemeral = true
}
fmt.Printf("%s\t%s\t%t\n", m.Name, m.LastSeen.Format("2006-01-02 15:04:05"), ephemeral)
var lastSeen time.Time
if m.LastSeen != nil {
lastSeen = *m.LastSeen
}
fmt.Printf("%s\t%s\t%t\n", m.Name, lastSeen.Format("2006-01-02 15:04:05"), ephemeral)
}
},