Skip to content

Commit

Permalink
Merge pull request #1561 from andyzhangx/tpnil
Browse files Browse the repository at this point in the history
cleanup: remove unnecessary tp nil check
  • Loading branch information
andyzhangx authored Oct 27, 2022
2 parents 04efbc1 + 112084e commit 8d84e78
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/azureutils/azure_snapshot_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ func GenerateCSISnapshot(sourceVolumeID string, snapshot *compute.Snapshot) (*cs
return nil, fmt.Errorf("snapshot property is nil")
}

tp := timestamppb.New(snapshot.SnapshotProperties.TimeCreated.ToTime())
if tp == nil {
return nil, fmt.Errorf("failed to convert timestamp(%v)", snapshot.SnapshotProperties.TimeCreated.ToTime())
if snapshot.SnapshotProperties.TimeCreated == nil {
return nil, fmt.Errorf("TimeCreated of snapshot property is nil")
}
ready, _ := isCSISnapshotReady(*snapshot.SnapshotProperties.ProvisioningState)

if snapshot.SnapshotProperties.DiskSizeGB == nil {
return nil, fmt.Errorf("diskSizeGB of snapshot property is nil")
}

ready, _ := isCSISnapshotReady(*snapshot.SnapshotProperties.ProvisioningState)
if sourceVolumeID == "" {
sourceVolumeID = GetSourceVolumeID(snapshot)
}
Expand All @@ -52,7 +51,7 @@ func GenerateCSISnapshot(sourceVolumeID string, snapshot *compute.Snapshot) (*cs
SizeBytes: volumehelper.GiBToBytes(int64(*snapshot.SnapshotProperties.DiskSizeGB)),
SnapshotId: *snapshot.ID,
SourceVolumeId: sourceVolumeID,
CreationTime: tp,
CreationTime: timestamppb.New(snapshot.SnapshotProperties.TimeCreated.ToTime()),
ReadyToUse: ready,
}, nil
}
Expand Down

0 comments on commit 8d84e78

Please sign in to comment.