Skip to content

Commit

Permalink
Update time format for salt update
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronRP committed Jan 13, 2020
1 parent fc826d9 commit 296f81e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion management-interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"sort"
"strconv"
"strings"
"time"

goconfig "github.com/TheCacophonyProject/go-config"

Expand Down Expand Up @@ -130,7 +131,15 @@ func getSaltMinionID() string {

// Return the time of the last salt update.
func getLastSaltUpdate() string {
return strings.TrimSpace(readFile("/etc/cacophony/last-salt-update"))
timeStr := strings.TrimSpace(readFile("/etc/cacophony/last-salt-update"))
if timeStr == "" {
return ""
}
t, err := time.Parse(time.RFC3339, timeStr)
if err != nil {
return ""
}
return t.Format("2006-01-02 15:04:05")
}

// Return context from file returning an empty string if on windows or if read fails
Expand Down

0 comments on commit 296f81e

Please sign in to comment.