Skip to content

Commit 82db20d

Browse files
authored
chore(controller-sdk-go): unified time format
1 parent c3849cd commit 82db20d

10 files changed

Lines changed: 39 additions & 55 deletions

File tree

api/certs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import "github.com/drycc/controller-sdk-go/pkg/time"
66
// Some fields are omtempty because they are only
77
// returned when creating or getting a cert.
88
type Cert struct {
9-
Updated time.Time `json:"updated,omitempty"`
10-
Created time.Time `json:"created,omitempty"`
9+
Updated string `json:"updated,omitempty"`
10+
Created string `json:"created,omitempty"`
1111
Name string `json:"name"`
1212
CommonName string `json:"common_name"`
1313
Expires time.Time `json:"expires"`

api/events.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package api
22

3-
import "github.com/drycc/controller-sdk-go/pkg/time"
4-
53
// Event defines the structure of event.
64
type AppEvent struct {
7-
Reason string `json:"reason"`
8-
Message string `json:"message"`
9-
Created time.Time `json:"created"`
5+
Reason string `json:"reason"`
6+
Message string `json:"message"`
7+
Created string `json:"created"`
108
}
119

1210
type AppEvents []AppEvent

api/ps.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package api
22

3-
import "github.com/drycc/controller-sdk-go/pkg/time"
4-
53
// ProcessType represents the key/value mappings of a process type to a process inside
64
// a Heroku Procfile.
75
//
@@ -10,13 +8,13 @@ type ProcessType map[string]string
108

119
// Pods defines the structure of a process.
1210
type Pods struct {
13-
Release string `json:"release"`
14-
Type string `json:"type"`
15-
Name string `json:"name"`
16-
State string `json:"state"`
17-
Ready string `json:"ready"`
18-
Restarts int `json:"restarts"`
19-
Started time.Time `json:"started"`
11+
Release string `json:"release"`
12+
Type string `json:"type"`
13+
Name string `json:"name"`
14+
State string `json:"state"`
15+
Ready string `json:"ready"`
16+
Restarts int `json:"restarts"`
17+
Started string `json:"started"`
2018
}
2119

2220
// PodsList defines a collection of app pods.

api/ps_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ package api
33
import (
44
"sort"
55
"testing"
6-
7-
"github.com/drycc/controller-sdk-go/pkg/time"
86
)
97

108
func TestPodsListSorted(t *testing.T) {
119
pods := PodsList{
12-
{"", "web", "web.fsdfgh4", "up", "1/1", 0, time.Time{}},
13-
{"", "web", "web.asdfgh1", "up", "1/1", 0, time.Time{}},
14-
{"", "web", "web.csdfgh3", "up", "1/1", 0, time.Time{}},
15-
{"", "web", "web.bsdfgh2", "up", "1/1", 0, time.Time{}},
10+
{"", "web", "web.fsdfgh4", "up", "1/1", 0, ""},
11+
{"", "web", "web.asdfgh1", "up", "1/1", 0, ""},
12+
{"", "web", "web.csdfgh3", "up", "1/1", 0, ""},
13+
{"", "web", "web.bsdfgh2", "up", "1/1", 0, ""},
1614
}
1715

1816
sort.Sort(pods)

api/pts.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package api
22

3-
import "github.com/drycc/controller-sdk-go/pkg/time"
4-
53
// Ptype defines the structure of ptype deployment.
64
type Ptype struct {
7-
Name string `json:"name"`
8-
Release string `json:"release"`
9-
Ready string `json:"ready"`
10-
UpToDate int `json:"up_to_date"`
11-
AvailableReplicas int `json:"available_replicas"`
12-
Started time.Time `json:"started"`
5+
Name string `json:"name"`
6+
Release string `json:"release"`
7+
Ready string `json:"ready"`
8+
UpToDate int `json:"up_to_date"`
9+
AvailableReplicas int `json:"available_replicas"`
10+
Started string `json:"started"`
1311
}
1412

1513
// Ptypes defines a collection of app Ptypes.

api/pts_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ package api
33
import (
44
"sort"
55
"testing"
6-
7-
"github.com/drycc/controller-sdk-go/pkg/time"
86
)
97

108
func TestPtypesSorted(t *testing.T) {
119
ptypes := Ptypes{
12-
{"web", "v1", "1/1", 1, 1, time.Time{}},
13-
{"cronjob", "v1", "1/1", 1, 1, time.Time{}},
14-
{"sleep", "v1", "1/1", 1, 1, time.Time{}},
10+
{"web", "v1", "1/1", 1, 1, ""},
11+
{"cronjob", "v1", "1/1", 1, 1, ""},
12+
{"sleep", "v1", "1/1", 1, 1, ""},
1513
}
1614

1715
sort.Sort(ptypes)

certs/certs_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"reflect"
99
"testing"
1010

11+
"github.com/drycc/controller-sdk-go/pkg/time"
12+
1113
drycc "github.com/drycc/controller-sdk-go"
1214
"github.com/drycc/controller-sdk-go/api"
13-
"github.com/drycc/controller-sdk-go/pkg/time"
1415
)
1516

1617
const certsFixture string = `
@@ -141,15 +142,16 @@ func TestCertsList(t *testing.T) {
141142
func TestCert(t *testing.T) {
142143
t.Parallel()
143144

144-
created := time.Time{}
145-
created.UnmarshalText([]byte("2014-01-01T00:00:00UTC"))
145+
created := "2014-01-01T00:00:00UTC"
146+
starts := time.Time{}
147+
starts.UnmarshalText([]byte("2014-01-01T00:00:00UTC"))
146148
expires := time.Time{}
147149
expires.UnmarshalText([]byte("2015-01-01T00:00:00UTC"))
148150

149151
expected := api.Cert{
150152
Updated: created,
151153
Created: created,
152-
Starts: created,
154+
Starts: starts,
153155
Expires: expires,
154156
Fingerprint: "12:34:56:78:90",
155157
Name: "test-example-com",
@@ -180,15 +182,16 @@ func TestCert(t *testing.T) {
180182
func TestCertInfo(t *testing.T) {
181183
t.Parallel()
182184

183-
created := time.Time{}
184-
created.UnmarshalText([]byte("2014-01-01T00:00:00UTC"))
185+
created := "2014-01-01T00:00:00UTC"
186+
starts := time.Time{}
187+
starts.UnmarshalText([]byte("2014-01-01T00:00:00UTC"))
185188
expires := time.Time{}
186189
expires.UnmarshalText([]byte("2015-01-01T00:00:00UTC"))
187190

188191
expected := api.Cert{
189192
Updated: created,
190193
Created: created,
191-
Starts: created,
194+
Starts: starts,
192195
Expires: expires,
193196
Fingerprint: "12:34:56:78:90",
194197
Name: "test-example-com",

events/events_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
drycc "github.com/drycc/controller-sdk-go"
1111
"github.com/drycc/controller-sdk-go/api"
12-
"github.com/drycc/controller-sdk-go/pkg/time"
1312
)
1413

1514
const podEventsFixture string = `
@@ -61,8 +60,7 @@ func (fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
6160
func TestEvents(t *testing.T) {
6261
t.Parallel()
6362

64-
created := time.Time{}
65-
created.UnmarshalText([]byte("2024-07-03T16:28:00"))
63+
created := "2024-07-03T16:28:00"
6664
podExpected := api.AppEvents{
6765
{
6866
Reason: "Scheduled",

ps/ps_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
drycc "github.com/drycc/controller-sdk-go"
1414
"github.com/drycc/controller-sdk-go/api"
15-
"github.com/drycc/controller-sdk-go/pkg/time"
1615
"golang.org/x/net/websocket"
1716
)
1817

@@ -107,8 +106,7 @@ func (fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
107106
func TestProcessesList(t *testing.T) {
108107
t.Parallel()
109108

110-
started := time.Time{}
111-
started.UnmarshalText([]byte("2016-02-13T00:47:52"))
109+
started := "2016-02-13T00:47:52"
112110
expected := api.PodsList{
113111
{
114112
Release: "v2",
@@ -272,8 +270,7 @@ func TestDescribe(t *testing.T) {
272270
func TestByType(t *testing.T) {
273271
t.Parallel()
274272

275-
started := time.Time{}
276-
started.UnmarshalText([]byte("2016-02-13T00:47:52"))
273+
started := "2016-02-13T00:47:52"
277274

278275
expected := api.PodTypes{
279276
{

pts/pts_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
drycc "github.com/drycc/controller-sdk-go"
1212
"github.com/drycc/controller-sdk-go/api"
13-
"github.com/drycc/controller-sdk-go/pkg/time"
1413
)
1514

1615
const ptypesFixture string = `
@@ -127,8 +126,7 @@ func (fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
127126
func TestPtype(t *testing.T) {
128127
t.Parallel()
129128

130-
started := time.Time{}
131-
started.UnmarshalText([]byte("2024-07-03T16:28:00"))
129+
started := "2024-07-03T16:28:00"
132130
expected := api.Ptypes{
133131
{
134132
Name: "example-go-web",
@@ -211,8 +209,6 @@ func TestDescribe(t *testing.T) {
211209
func TestAppsRestart(t *testing.T) {
212210
t.Parallel()
213211

214-
started := time.Time{}
215-
started.UnmarshalText([]byte("2016-02-13T00:47:52"))
216212
types := map[string]string{
217213
"types": "web,worker",
218214
}

0 commit comments

Comments
 (0)