cmd/plume: Only pretend to prune GCE images at the end
We were pretending to prune images even when --dry-run is set, which is
surprising and premature. Pretend to prune images only after successfully
uploading and publishing the new image and deprecating the old ones.
@@ -204,11 +204,6 @@ func doGCE(ctx context.Context, client *http.Client, src *storage.Bucket, spec *
return
}
- if spec.GCE.Limit > 0 && len(images) > spec.GCE.Limit {
- plog.Noticef("Pruning %d GCE images.", len(images)-spec.GCE.Limit)
- plog.Notice("NOPE! JUST KIDDING, TODO")
- }
-
obj := src.Object(src.Prefix() + spec.GCE.Image)
if obj == nil {
plog.Fatalf("GCE image not found %s%s", src.URL(), spec.GCE.Image)
@@ -274,6 +269,11 @@ func doGCE(ctx context.Context, client *http.Client, src *storage.Bucket, spec *
pendings = append(pendings, pending)
}
+ if spec.GCE.Limit > 0 && len(images) > spec.GCE.Limit {
+ plog.Noticef("Pruning %d GCE images.", len(images)-spec.GCE.Limit)
+ plog.Notice("NOPE! JUST KIDDING, TODO")
+ }
+
plog.Infof("Waiting on %d operations.", len(pendings))
for _, pending := range pendings {
err := pending.Wait()
