Skip to content

Commit 18548f5

Browse files
abrightwellcahoonpwork
authored andcommitted
change type of event timestamp from string to time.Time (CrunchyData#965)
1 parent cf27e81 commit 18548f5

File tree

21 files changed

+58
-54
lines changed

21 files changed

+58
-54
lines changed

apiserver/clusterservice/clusterimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ func TestCluster(name, selector, ns, pgouser string, allFlag bool) msgs.ClusterT
402402
Namespace: ns,
403403
Username: pgouser,
404404
Topic: topics,
405-
Timestamp: events.GetTimestamp(),
405+
Timestamp: time.Now(),
406406
EventType: events.EventTestCluster,
407407
},
408408
Clustername: c.Name,

apiserver/loadservice/loadimpl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
v1batch "k8s.io/api/batch/v1"
3131
"k8s.io/apimachinery/pkg/labels"
3232
"strings"
33+
"time"
3334
)
3435

3536
type loadJobTemplateFields struct {
@@ -190,7 +191,7 @@ func Load(request *msgs.LoadRequest, ns, pgouser string) msgs.LoadResponse {
190191
Namespace: ns,
191192
Username: pgouser,
192193
Topic: topics,
193-
Timestamp: events.GetTimestamp(),
194+
Timestamp: time.Now(),
194195
EventType: events.EventLoad,
195196
},
196197
Clustername: c.Name,

apiserver/pgoroleservice/pgoroleimpl.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/api/core/v1"
2828
"k8s.io/client-go/kubernetes"
2929
"strings"
30+
"time"
3031
)
3132

3233
// CreatePgorole ...
@@ -60,7 +61,7 @@ func CreatePgorole(clientset *kubernetes.Clientset, createdBy string, request *m
6061
Namespace: apiserver.PgoNamespace,
6162
Username: createdBy,
6263
Topic: topics,
63-
Timestamp: events.GetTimestamp(),
64+
Timestamp: time.Now(),
6465
EventType: events.EventPGOCreateRole,
6566
},
6667
CreatedRolename: request.PgoroleName,
@@ -146,7 +147,7 @@ func DeletePgorole(clientset *kubernetes.Clientset, deletedBy string, request *m
146147
Namespace: apiserver.PgoNamespace,
147148
Username: deletedBy,
148149
Topic: topics,
149-
Timestamp: events.GetTimestamp(),
150+
Timestamp: time.Now(),
150151
EventType: events.EventPGODeleteRole,
151152
},
152153
DeletedRolename: v,
@@ -217,7 +218,7 @@ func UpdatePgorole(clientset *kubernetes.Clientset, updatedBy string, request *m
217218
Namespace: apiserver.PgoNamespace,
218219
Username: updatedBy,
219220
Topic: topics,
220-
Timestamp: events.GetTimestamp(),
221+
Timestamp: time.Now(),
221222
EventType: events.EventPGOUpdateRole,
222223
},
223224
UpdatedRolename: request.PgoroleName,

apiserver/pgouserservice/pgouserimpl.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"k8s.io/api/core/v1"
2929
"k8s.io/client-go/kubernetes"
3030
"strings"
31+
"time"
3132
)
3233

3334
const MAP_KEY_USERNAME = "username"
@@ -78,7 +79,7 @@ func CreatePgouser(clientset *kubernetes.Clientset, createdBy string, request *m
7879
Namespace: apiserver.PgoNamespace,
7980
Username: createdBy,
8081
Topic: topics,
81-
Timestamp: events.GetTimestamp(),
82+
Timestamp: time.Now(),
8283
EventType: events.EventPGOCreateUser,
8384
},
8485
CreatedUsername: request.PgouserName,
@@ -172,7 +173,7 @@ func DeletePgouser(clientset *kubernetes.Clientset, deletedBy string, request *m
172173
Namespace: apiserver.PgoNamespace,
173174
Username: deletedBy,
174175
Topic: topics,
175-
Timestamp: events.GetTimestamp(),
176+
Timestamp: time.Now(),
176177
EventType: events.EventPGODeleteUser,
177178
},
178179
DeletedUsername: v,

apiserver/policyservice/policyimpl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"k8s.io/api/apps/v1"
2929
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
"k8s.io/client-go/rest"
31+
"time"
3132
)
3233

3334
// CreatePolicy ...
@@ -270,7 +271,7 @@ func ApplyPolicy(request *msgs.ApplyPolicyRequest, ns, pgouser string) msgs.Appl
270271
Namespace: ns,
271272
Username: pgouser,
272273
Topic: topics,
273-
Timestamp: events.GetTimestamp(),
274+
Timestamp: time.Now(),
274275
EventType: events.EventApplyPolicy,
275276
},
276277
Clustername: d.ObjectMeta.Labels[config.LABEL_PG_CLUSTER],

apiserver/reloadservice/reloadimpl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/client-go/kubernetes"
2828
"k8s.io/client-go/rest"
2929
"strings"
30+
"time"
3031
)
3132

3233
// Reload ...
@@ -114,7 +115,7 @@ func Reload(request *msgs.ReloadRequest, ns, username string) msgs.ReloadRespons
114115
Namespace: ns,
115116
Username: username,
116117
Topic: topics,
117-
Timestamp: events.GetTimestamp(),
118+
Timestamp: time.Now(),
118119
EventType: events.EventReloadCluster,
119120
},
120121
Clustername: cluster.Spec.Name,

apiserver/userservice/userimpl.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func UpdateUser(request *msgs.UpdateUserRequest, pgouser string) msgs.UpdateUser
186186
EventHeader: events.EventHeader{
187187
Namespace: request.Namespace,
188188
Username: pgouser,
189-
Timestamp: events.GetTimestamp(),
189+
Timestamp: time.Now(),
190190
Topic: topics,
191191
EventType: events.EventChangePasswordUser,
192192
},
@@ -711,7 +711,7 @@ func CreateUser(request *msgs.CreateUserRequest, pgouser string) msgs.CreateUser
711711
Namespace: request.Namespace,
712712
Username: pgouser,
713713
Topic: topics,
714-
Timestamp: events.GetTimestamp(),
714+
Timestamp: time.Now(),
715715
EventType: events.EventCreateUser,
716716
},
717717
Clustername: c.Name,
@@ -853,7 +853,7 @@ func DeleteUser(request *msgs.DeleteUserRequest, pgouser string) msgs.DeleteUser
853853
Namespace: request.Namespace,
854854
Username: pgouser,
855855
Topic: topics,
856-
Timestamp: events.GetTimestamp(),
856+
Timestamp: time.Now(),
857857
EventType: events.EventDeleteUser,
858858
},
859859
Clustername: clusterName,

controller/jobcontroller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func (c *JobController) onUpdate(oldObj, newObj interface{}) {
302302
Namespace: job.ObjectMeta.Namespace,
303303
Username: job.ObjectMeta.Labels[config.LABEL_PGOUSER],
304304
Topic: topics,
305-
Timestamp: events.GetTimestamp(),
305+
Timestamp: time.Now(),
306306
EventType: events.EventBenchmarkCompleted,
307307
},
308308
Clustername: labels[config.LABEL_PG_CLUSTER],
@@ -476,7 +476,7 @@ func publishBackupComplete(clusterName, clusterIdentifier, username, backuptype,
476476
Namespace: namespace,
477477
Username: username,
478478
Topic: topics,
479-
Timestamp: events.GetTimestamp(),
479+
Timestamp: time.Now(),
480480
EventType: events.EventCreateBackupCompleted,
481481
},
482482
Clustername: clusterName,
@@ -500,7 +500,7 @@ func publishRestoreComplete(clusterName, identifier, username, namespace string)
500500
Namespace: namespace,
501501
Username: username,
502502
Topic: topics,
503-
Timestamp: events.GetTimestamp(),
503+
Timestamp: time.Now(),
504504
EventType: events.EventRestoreClusterCompleted,
505505
},
506506
Clustername: clusterName,

controller/podcontroller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818
import (
1919
"context"
2020
"sync"
21+
"time"
2122

2223
crv1 "github.com/crunchydata/postgres-operator/apis/cr/v1"
2324
"github.com/crunchydata/postgres-operator/config"
@@ -328,7 +329,7 @@ func publishClusterComplete(clusterName, namespace string, cluster *crv1.Pgclust
328329
Namespace: namespace,
329330
Username: cluster.Spec.UserLabels[config.LABEL_PGOUSER],
330331
Topic: topics,
331-
Timestamp: events.GetTimestamp(),
332+
Timestamp: time.Now(),
332333
EventType: events.EventCreateClusterCompleted,
333334
},
334335
Clustername: clusterName,
@@ -392,7 +393,7 @@ func publishPrimaryNotReady(clusterName, identifier, username, namespace string)
392393
Namespace: namespace,
393394
Username: username,
394395
Topic: topics,
395-
Timestamp: events.GetTimestamp(),
396+
Timestamp: time.Now(),
396397
EventType: events.EventPrimaryNotReady,
397398
},
398399
Clustername: clusterName,

controller/policycontroller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818
import (
1919
"context"
2020
"sync"
21+
"time"
2122

2223
"github.com/crunchydata/postgres-operator/config"
2324
"github.com/crunchydata/postgres-operator/kubeapi"
@@ -104,7 +105,7 @@ func (c *PgpolicyController) onAdd(obj interface{}) {
104105
Namespace: policy.ObjectMeta.Namespace,
105106
Username: policy.ObjectMeta.Labels[config.LABEL_PGOUSER],
106107
Topic: topics,
107-
Timestamp: events.GetTimestamp(),
108+
Timestamp: time.Now(),
108109
EventType: events.EventCreatePolicy,
109110
},
110111
Policyname: policy.ObjectMeta.Name,
@@ -137,7 +138,7 @@ func (c *PgpolicyController) onDelete(obj interface{}) {
137138
Namespace: policy.ObjectMeta.Namespace,
138139
Username: policy.ObjectMeta.Labels[config.LABEL_PGOUSER],
139140
Topic: topics,
140-
Timestamp: events.GetTimestamp(),
141+
Timestamp: time.Now(),
141142
EventType: events.EventDeletePolicy,
142143
},
143144
Policyname: policy.ObjectMeta.Name,

0 commit comments

Comments
 (0)