diff --git a/src/cmd/tools/crane.go b/src/cmd/tools/crane.go index 6d0919067d..c0a521c153 100644 --- a/src/cmd/tools/crane.go +++ b/src/cmd/tools/crane.go @@ -246,6 +246,9 @@ func pruneImages(_ *cobra.Command, _ []string) error { func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.DeployedPackage, registryEndpoint string) error { authOption := config.GetCraneAuthOption(zarfState.RegistryInfo.PushUsername, zarfState.RegistryInfo.PushPassword) + spinner := message.NewProgressSpinner(lang.CmdToolsRegistryPruneLookup) + defer spinner.Stop() + // Determine which image digests are currently used by Zarf packages pkgImages := map[string]bool{} for _, pkg := range zarfPackages { @@ -273,6 +276,8 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D } } + spinner.Updatef(lang.CmdToolsRegistryPruneCatalog) + // Find which images and tags are in the registry currently imageCatalog, err := crane.Catalog(registryEndpoint, authOption) if err != nil { @@ -295,6 +300,8 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D } } + spinner.Updatef(lang.CmdToolsRegistryPruneCalculate) + // Figure out which images are in the registry but not needed by packages imageDigestsToPrune := map[string]bool{} for digestRef, digest := range referenceToDigest { @@ -308,6 +315,8 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D } } + spinner.Success() + if len(imageDigestsToPrune) > 0 { message.Note(lang.CmdToolsRegistryPruneImageList) @@ -328,6 +337,9 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D } } if confirm { + spinner := message.NewProgressSpinner(lang.CmdToolsRegistryPruneDelete) + defer spinner.Stop() + // Delete the digest references that are to be pruned for digestRef := range imageDigestsToPrune { err = crane.Delete(digestRef, authOption) @@ -335,6 +347,8 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D return err } } + + spinner.Success() } } else { message.Note(lang.CmdToolsRegistryPruneNoImages) diff --git a/src/config/lang/english.go b/src/config/lang/english.go index 6a666474d7..14e3b19887 100644 --- a/src/config/lang/english.go +++ b/src/config/lang/english.go @@ -455,6 +455,10 @@ $ zarf tools registry digest reg.example.com/stefanprodan/podinfo:6.4.0 CmdToolsRegistryPruneFlagConfirm = "Confirm the image prune action to prevent accidental deletions" CmdToolsRegistryPruneImageList = "The following image digests will be pruned from the registry:" CmdToolsRegistryPruneNoImages = "There are no images to prune" + CmdToolsRegistryPruneLookup = "Looking up images within package definitions" + CmdToolsRegistryPruneCatalog = "Cataloging images in the registry" + CmdToolsRegistryPruneCalculate = "Calculating images to prune" + CmdToolsRegistryPruneDelete = "Deleting unused images" CmdToolsRegistryInvalidPlatformErr = "Invalid platform '%s': %s" CmdToolsRegistryFlagVerbose = "Enable debug logs"