agent: use UTC time for intention times, move empty list check to

agent/consul
This commit is contained in:
Mitchell Hashimoto 2018-03-06 09:04:44 -08:00
parent 67b017c95c
commit 6f33b2d070
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 9 additions and 6 deletions

View File

@ -67,7 +67,7 @@ func (s *Intention) Apply(
}
// Set the created at
args.Intention.CreatedAt = time.Now()
args.Intention.CreatedAt = time.Now().UTC()
}
*reply = args.Intention.ID
@ -84,7 +84,7 @@ func (s *Intention) Apply(
}
// We always update the updatedat field. This has no effect for deletion.
args.Intention.UpdatedAt = time.Now()
args.Intention.UpdatedAt = time.Now().UTC()
// Default source type
if args.Intention.SourceType == "" {
@ -169,6 +169,10 @@ func (s *Intention) List(
}
reply.Index, reply.Intentions = index, ixns
if reply.Intentions == nil {
reply.Intentions = make(structs.Intentions, 0)
}
// filterACL
return nil
},

View File

@ -384,6 +384,9 @@ func TestIntentionList(t *testing.T) {
if err := msgpackrpc.CallWithCodec(codec, "Intention.List", req, &resp); err != nil {
t.Fatalf("err: %v", err)
}
if resp.Intentions == nil {
t.Fatal("should not be nil")
}
if len(resp.Intentions) != 0 {
t.Fatalf("bad: %v", resp)

View File

@ -37,10 +37,6 @@ func (s *HTTPServer) IntentionList(resp http.ResponseWriter, req *http.Request)
return nil, err
}
// Use empty list instead of nil.
if reply.Intentions == nil {
reply.Intentions = make(structs.Intentions, 0)
}
return reply.Intentions, nil
}