use pointer types for metav1.Time fields (#1951)

* use pointer types for metav1.Time fields

Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com>

* simpler metav1.Time ptrs

Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com>

* remove test debug println

Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com>
This commit is contained in:
Adnan Abdulhussein
2019-10-14 09:20:28 -07:00
committed by Steve Kriss
parent 3fc4097231
commit e3d64d9dd9
29 changed files with 158 additions and 88 deletions

View File

@@ -198,7 +198,7 @@ func (c *backupController) processBackup(key string) error {
request.Status.Phase = velerov1api.BackupPhaseFailedValidation
} else {
request.Status.Phase = velerov1api.BackupPhaseInProgress
request.Status.StartTimestamp.Time = c.clock.Now()
request.Status.StartTimestamp = &metav1.Time{Time: c.clock.Now()}
}
// update status
@@ -289,7 +289,7 @@ func (c *backupController) prepareBackupRequest(backup *velerov1api.Backup) *pkg
}
// calculate expiration
request.Status.Expiration = metav1.NewTime(c.clock.Now().Add(request.Spec.TTL.Duration))
request.Status.Expiration = &metav1.Time{Time: c.clock.Now().Add(request.Spec.TTL.Duration)}
// default storage location if not specified
if request.Spec.StorageLocation == "" {
@@ -485,7 +485,7 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
exists, err := backupStore.BackupExists(backup.StorageLocation.Spec.StorageType.ObjectStorage.Bucket, backup.Name)
if exists || err != nil {
backup.Status.Phase = velerov1api.BackupPhaseFailed
backup.Status.CompletionTimestamp.Time = c.clock.Now()
backup.Status.CompletionTimestamp = &metav1.Time{Time: c.clock.Now()}
if err != nil {
return errors.Wrapf(err, "error checking if backup already exists in object storage")
}
@@ -499,7 +499,7 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
// Mark completion timestamp before serializing and uploading.
// Otherwise, the JSON file in object storage has a CompletionTimestamp of 'null'.
backup.Status.CompletionTimestamp.Time = c.clock.Now()
backup.Status.CompletionTimestamp = &metav1.Time{Time: c.clock.Now()}
backup.Status.VolumeSnapshotsAttempted = len(backup.VolumeSnapshots)
for _, snap := range backup.VolumeSnapshots {