@@ -930,7 +930,7 @@ func getVolSizeInBytes(capRange *csi.CapacityRange) (int64, error) {
930
930
func ConvertSnapshot (in * civogo.VolumeSnapshot ) (* csi.ListSnapshotsResponse_Entry , error ) {
931
931
snap , err := ToCSISnapshot (in )
932
932
if err != nil {
933
- return nil , fmt .Errorf ("filed to convert civo snapshot %s to csi snapshot: %v" , in .SnapshotID , err )
933
+ return nil , fmt .Errorf ("failed to convert civo snapshot %s to csi snapshot: %v" , in .SnapshotID , err )
934
934
}
935
935
936
936
return & csi.ListSnapshotsResponse_Entry {
@@ -940,11 +940,12 @@ func ConvertSnapshot(in *civogo.VolumeSnapshot) (*csi.ListSnapshotsResponse_Entr
940
940
941
941
// ParseTimeToProtoTimestamp parses a time string in RFC3339 format to *timestamppb.Timestamp.
942
942
func ParseTimeToProtoTimestamp (timeStr string ) (* timestamppb.Timestamp , error ) {
943
- t , err := time .Parse (time .RFC3339 , timeStr )
944
- if err != nil {
945
- return nil , err
946
- }
947
- return timestamppb .New (t ), nil
943
+ t , err := time .Parse (time .RFC3339 , timeStr )
944
+ // Only return an error if timeStr is not empty
945
+ if err != nil && timeStr != "" {
946
+ return nil , err
947
+ }
948
+ return timestamppb .New (t ), nil
948
949
}
949
950
950
951
// IsSnapshotReady determines if a snapshot is ready for use
@@ -961,13 +962,9 @@ func IsSnapshotReady(state string) bool {
961
962
962
963
963
964
func ToCSISnapshot (snap * civogo.VolumeSnapshot )(* csi.Snapshot , error ){
964
- var creationTime * timestamppb.Timestamp
965
- var err error
966
- if strings .TrimSpace (snap .CreationTime ) != "" {
967
- creationTime , err = ParseTimeToProtoTimestamp (snap .CreationTime )
968
- if err != nil {
969
- return nil , fmt .Errorf ("failed to parse creation time for snapshot %s: %w" , snap .SnapshotID , err )
970
- }
965
+ creationTime , err := ParseTimeToProtoTimestamp (snap .CreationTime )
966
+ if err != nil {
967
+ return nil , fmt .Errorf ("failed to parse creation time for snapshot %s: %w" , snap .SnapshotID , err )
971
968
}
972
969
973
970
// Explicitly define which state indicates the snapshot is ready for use
0 commit comments