diff --git a/cmd/DigitalOceanSnapshotter/main.go b/cmd/DigitalOceanSnapshotter/main.go index 7ddc09b..7ef5e71 100644 --- a/cmd/DigitalOceanSnapshotter/main.go +++ b/cmd/DigitalOceanSnapshotter/main.go @@ -92,7 +92,7 @@ func main() { return } - _, _, err = ctx.DoContext.CreateSnapshot(&godo.SnapshotCreateRequest{ + snapshot, _, err := ctx.DoContext.CreateSnapshot(&godo.SnapshotCreateRequest{ VolumeID: volume.ID, Name: time.Now().Format("2006-01-02T15:04:05"), }) @@ -101,6 +101,8 @@ func main() { return } + log.Info(fmt.Sprintf("Created Snapshot with Id %s from volume %s", snapshot.ID, volume.Name)) + snapshots, _, err := ctx.DoContext.ListSnapshots(volume.ID, nil) snapshotLength := len(snapshots) @@ -123,12 +125,14 @@ func main() { snapshotsToDelete := snapshotLength - snapshotCount for i := 0; i < snapshotsToDelete; i++ { - _, err := ctx.DoContext.DeleteSnapshot(snapshots[i].ID) - + snapshotToDeleteID := snapshots[i].ID + _, err := ctx.DoContext.DeleteSnapshot(snapshotToDeleteID) if err != nil { handleError(ctx, err, false) return } + + log.Info(fmt.Sprintf("Deleted Snapshot with Id %s", snapshotToDeleteID)) } } }