export FixTime to allow external use
This commit is contained in:
parent
991b814377
commit
48f8ee1d11
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
// fixTime converts any suspected time.Time binary string representation to time.Time
|
||||
func fixTime(v interface{}) {
|
||||
// FixTime converts any suspected time.Time binary string representation to time.Time
|
||||
func FixTime(v interface{}) {
|
||||
switch v2 := v.(type) {
|
||||
case map[string]interface{}:
|
||||
for ek, ev := range v2 {
|
||||
|
@ -21,12 +21,12 @@ func fixTime(v interface{}) {
|
|||
v2[ek] = *t
|
||||
}
|
||||
} else {
|
||||
fixTime(ev)
|
||||
FixTime(ev)
|
||||
}
|
||||
}
|
||||
case []interface{}:
|
||||
for _, e := range v2 {
|
||||
fixTime(e)
|
||||
FixTime(e)
|
||||
}
|
||||
default:
|
||||
return
|
||||
|
|
|
@ -49,7 +49,7 @@ func TestDecodesTime(t *testing.T) {
|
|||
require.Equal(t, "host", r["Mode"])
|
||||
require.IsType(t, "", r["CreateTime"])
|
||||
|
||||
fixTime(r)
|
||||
FixTime(r)
|
||||
|
||||
expected := map[string]interface{}{
|
||||
"CreateTime": now,
|
||||
|
|
|
@ -117,7 +117,7 @@ func decode(e *raft.Log) (*logMessage, error) {
|
|||
fmt.Fprintf(os.Stderr, "failed to decode log entry at index %d: failed to decode body of %v.%v %v\n", e.Index, e.Type, m.CommandType, err)
|
||||
v = "FAILED TO DECODE DATA"
|
||||
}
|
||||
fixTime(v)
|
||||
FixTime(v)
|
||||
m.Body = v
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue