Skip to content

Commit 81c7af7

Browse files
authored
Merge pull request #624 from weaveworks/policies_date_format
chore(api): use ISO format for policy create time
2 parents 2b29ebd + 739ee0d commit 81c7af7

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

cmd/clusters-service/pkg/server/policies.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"strconv"
8+
"time"
89

910
"github.com/golang/protobuf/ptypes/any"
1011
policiesv1 "github.com/weaveworks/policy-agent/api/v1"
@@ -98,7 +99,7 @@ func toPolicyResponse(policyCRD policiesv1.Policy) (*capiv1_proto.Policy, error)
9899
Labels: policyLabels,
99100
},
100101
Parameters: policyParams,
101-
CreatedAt: policyCRD.CreationTimestamp.UTC().String(),
102+
CreatedAt: policyCRD.CreationTimestamp.Format(time.RFC3339),
102103
}
103104

104105
return policy, nil

cmd/clusters-service/pkg/server/policies_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestListPolicies(t *testing.T) {
4242
Name: "Missing app Label",
4343
Severity: "medium",
4444
Code: "foo",
45-
CreatedAt: "0001-01-01 00:00:00 +0000 UTC",
45+
CreatedAt: "0001-01-01T00:00:00Z",
4646
Targets: &capiv1_proto.PolicyTargets{
4747
Labels: []*capi_server.PolicyTargetLabel{
4848
{
@@ -55,7 +55,7 @@ func TestListPolicies(t *testing.T) {
5555
Name: "Missing Owner Label",
5656
Severity: "high",
5757
Code: "foo",
58-
CreatedAt: "0001-01-01 00:00:00 +0000 UTC",
58+
CreatedAt: "0001-01-01T00:00:00Z",
5959
Targets: &capiv1_proto.PolicyTargets{
6060
Labels: []*capi_server.PolicyTargetLabel{
6161
{
@@ -96,7 +96,7 @@ func TestListPolicies(t *testing.T) {
9696
},
9797
},
9898
},
99-
CreatedAt: "0001-01-01 00:00:00 +0000 UTC",
99+
CreatedAt: "0001-01-01T00:00:00Z",
100100
Parameters: []*capi_server.PolicyParam{
101101
{
102102
Name: "key",
@@ -137,7 +137,7 @@ func TestListPolicies(t *testing.T) {
137137
},
138138
},
139139
},
140-
CreatedAt: "0001-01-01 00:00:00 +0000 UTC",
140+
CreatedAt: "0001-01-01T00:00:00Z",
141141
Parameters: []*capi_server.PolicyParam{
142142
{
143143
Name: "key",
@@ -178,7 +178,7 @@ func TestListPolicies(t *testing.T) {
178178
},
179179
},
180180
},
181-
CreatedAt: "0001-01-01 00:00:00 +0000 UTC",
181+
CreatedAt: "0001-01-01T00:00:00Z",
182182
Parameters: []*capi_server.PolicyParam{
183183
{
184184
Name: "key",
@@ -219,7 +219,7 @@ func TestListPolicies(t *testing.T) {
219219
},
220220
},
221221
},
222-
CreatedAt: "0001-01-01 00:00:00 +0000 UTC",
222+
CreatedAt: "0001-01-01T00:00:00Z",
223223
Parameters: []*capi_server.PolicyParam{
224224
{
225225
Name: "key",
@@ -317,7 +317,7 @@ func TestGetPolicy(t *testing.T) {
317317
},
318318
},
319319
},
320-
CreatedAt: "0001-01-01 00:00:00 +0000 UTC",
320+
CreatedAt: "0001-01-01T00:00:00Z",
321321
},
322322
},
323323
},

0 commit comments

Comments
 (0)