Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 committed Dec 11, 2024
1 parent d0afa6d commit f9dcc21
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions pkg/driver/controller_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,22 +758,22 @@ func (d *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsReques
// Todo: Un-comment post client implementation
// snapshot, err := d.CivoClient.GetSnapshot(snapshotID)
// if err != nil {
// Todo: DatabaseSnapshotNotFoundError & DiskSnapshotNotFoundError are placeholders, it's still not clear what error will be returned by API (awaiting implementation - WIP)
// if strings.Contains(err.Error(), "DatabaseSnapshotNotFoundError") ||
// strings.Contains(err.Error(), "DiskSnapshotNotFoundError") {
// log.Info().
// Str("snapshot_id", snapshotID).
// Msg("ListSnapshots: no snapshot found, returning with success")
// return &csi.ListSnapshotsResponse{}, nil
// }
// // Todo: DatabaseSnapshotNotFoundError & DiskSnapshotNotFoundError are placeholders, it's still not clear what error will be returned by API (awaiting implementation - WIP)
// if strings.Contains(err.Error(), "DatabaseSnapshotNotFoundError") ||
// strings.Contains(err.Error(), "DiskSnapshotNotFoundError") {
// log.Info().
// Str("snapshot_id", snapshotID).
// Msg("ListSnapshots: no snapshot found, returning with success")
// return &csi.ListSnapshotsResponse{}, nil
// }
// log.Error().
// Err(err).
// Str("snapshot_id", snapshotID).
// Msg("Failed to list snapshot from Civo API")
// return nil, status.Errorf(codes.Internal, "failed to list snapshot %q: %v", snapshotID, err)
// }
// return &csi.ListSnapshotsResponse{
// Entries: []*csi.ListSnapshotsResponse_Entry{convertSnapshot(snapshot)},
// Entries: []*csi.ListSnapshotsResponse_Entry{convertSnapshot(snapshot)},
// }, nil
}

Expand All @@ -784,52 +784,52 @@ func (d *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsReques
Str("source_volume_id", sourceVolumeID).
Msg("Fetching volume snapshots")

// snapshots, err := d.CivoClient.ListSnapshots() // Todo: ListSnapshots to be implemented in civogo
// if err != nil{
// snapshots, err := d.CivoClient.ListSnapshots() // Todo: ListSnapshots to be implemented in civogo
// if err != nil {
// log.Error().
// Err(err).
// Str("source_volume_id", sourceVolumeID).
// Msg("Failed to list snapshots for volume")
// return nil, status.Errorf(codes.Internal, "failed to list snapshots for volume %q: %v", sourceVolumeID, err)
// return nil, status.Errorf(codes.Internal, "failed to list snapshots for volume %q: %v", sourceVolumeID, err)
// }

//
// entries := []*csi.ListSnapshotsResponse_Entry{}
// for _, snapshot := range snapshots {
// if snapshot.VolID == sourceVolumeID {
// entries = append(entries, convertSnapshot(snapshot))
// }
// if snapshot.VolID == sourceVolumeID {
// entries = append(entries, convertSnapshot(snapshot))
// }
// }

//
// return &csi.ListSnapshotsResponse{
// Entries: entries,
// Entries: entries,
// }, nil
}

log.Debug().Msg("Fetching all snapshots")

// case 3: Retrieve all snapshots if no filters are provided
// Todo: un-comment post client(civogo) implementation
// snapshots, err := d.CivoClient.ListSnapshots() // Todo: ListSnapshots to be implemented in civogo
// if err != nil{
// log.Error().Err(err).Msg("Failed to list snapshots from Civo API")
// return nil, status.Errorf(codes.Internal, "failed to list snapshots from Civo API: %v", err)
// snapshots, err := d.CivoClient.ListSnapshots() // Todo: ListSnapshots to be implemented in civogo
// if err != nil {
// log.Error().Err(err).Msg("Failed to list snapshots from Civo API")
// return nil, status.Errorf(codes.Internal, "failed to list snapshots from Civo API: %v", err)
// }

//
// sort.Slice(snapshots, func(i, j int) bool {
// return snapshots[i].Id < snapshots[j].Id
// return snapshots[i].Id < snapshots[j].Id
// })

//
// entries := []*csi.ListSnapshotsResponse_Entry{}
// for _, snap := range snapshots {
// entries = append(entries, convertSnapshot(snap))
// entries = append(entries, convertSnapshot(snap))
// }

//
// log.Info().
// Int("total_snapshots", len(entries)).
// Msg("Snapshots listed successfully")

//
// return &csi.ListSnapshotsResponse{
// Entries: entries,
// Entries: entries,
// }, nil
return nil, status.Error(codes.Unimplemented, "")
}
Expand All @@ -852,13 +852,13 @@ func getVolSizeInBytes(capRange *csi.CapacityRange) (int64, error) {
// Todo: Snapshot to be defined in civogo
// convertSnapshot function converts a civogo.Snapshot object(API response) into a CSI ListSnapshotsResponse_Entry
// func convertSnapshot(snap *civogo.Snapshot) *csi.ListSnapshotsResponse_Entry {
// return &csi.ListSnapshotsResponse_Entry{
// Snapshot: &csi.Snapshot{
// SnapshotId: snap.Id,
// SourceVolumeId: snap.VolID,
// CreationTime: snap.CreationTime,
// SizeBytes: snap.SizeBytes,
// ReadyToUse: snap.ReadyToUse,
// },
// }
// return &csi.ListSnapshotsResponse_Entry{
// Snapshot: &csi.Snapshot{
// SnapshotId: snap.Id,
// SourceVolumeId: snap.VolID,
// CreationTime: snap.CreationTime,
// SizeBytes: snap.SizeBytes,
// ReadyToUse: snap.ReadyToUse,
// },
// }
// }

0 comments on commit f9dcc21

Please sign in to comment.