diff --git a/src/cmd/common/setup.go b/src/cmd/common/setup.go index ac47d0c95d..34d2c36ce5 100644 --- a/src/cmd/common/setup.go +++ b/src/cmd/common/setup.go @@ -42,7 +42,6 @@ func SetupCLI(logLevel string, skipLogFile, noColor bool) error { // Disable progress bars for CI envs if os.Getenv("CI") == "true" { message.Debug("CI environment detected, disabling progress bars") - message.NoProgress = true } if !skipLogFile { diff --git a/src/cmd/connect.go b/src/cmd/connect.go index 8600d703a3..3f005388f8 100644 --- a/src/cmd/connect.go +++ b/src/cmd/connect.go @@ -30,9 +30,6 @@ var connectCmd = &cobra.Command{ target = args[0] } - spinner := message.NewProgressSpinner(lang.CmdConnectPreparingTunnel, target) - defer spinner.Stop() - c, err := cluster.NewCluster() if err != nil { return err @@ -63,21 +60,13 @@ var connectCmd = &cobra.Command{ // Dump the tunnel URL to the console for other tools to use. fmt.Print(tunnel.FullURL()) - - if cliOnly { - spinner.Updatef(lang.CmdConnectEstablishedCLI, tunnel.FullURL()) - } else { - spinner.Updatef(lang.CmdConnectEstablishedWeb, tunnel.FullURL()) - - if err := exec.LaunchURL(tunnel.FullURL()); err != nil { - return err - } + if err := exec.LaunchURL(tunnel.FullURL()); err != nil { + return err } // Wait for the interrupt signal or an error. select { case <-ctx.Done(): - spinner.Successf(lang.CmdConnectTunnelClosed, tunnel.FullURL()) return nil case err = <-tunnel.ErrChan(): return fmt.Errorf("lost connection to the service: %w", err) diff --git a/src/cmd/root.go b/src/cmd/root.go index bf695e3760..cc506acab9 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -125,7 +125,6 @@ func init() { rootCmd.PersistentFlags().StringVarP(&LogLevelCLI, "log-level", "l", v.GetString(common.VLogLevel), lang.RootCmdFlagLogLevel) rootCmd.PersistentFlags().StringVarP(&config.CLIArch, "architecture", "a", v.GetString(common.VArchitecture), lang.RootCmdFlagArch) rootCmd.PersistentFlags().BoolVar(&SkipLogFile, "no-log-file", v.GetBool(common.VNoLogFile), lang.RootCmdFlagSkipLogFile) - rootCmd.PersistentFlags().BoolVar(&message.NoProgress, "no-progress", v.GetBool(common.VNoProgress), lang.RootCmdFlagNoProgress) rootCmd.PersistentFlags().BoolVar(&NoColor, "no-color", v.GetBool(common.VNoColor), lang.RootCmdFlagNoColor) rootCmd.PersistentFlags().StringVar(&config.CommonOptions.CachePath, "zarf-cache", v.GetString(common.VZarfCache), lang.RootCmdFlagCachePath) rootCmd.PersistentFlags().StringVar(&config.CommonOptions.TempDirectory, "tmpdir", v.GetString(common.VTmpDir), lang.RootCmdFlagTempDir) diff --git a/src/cmd/tools/crane.go b/src/cmd/tools/crane.go index dd76955339..fdb9acdd4b 100644 --- a/src/cmd/tools/crane.go +++ b/src/cmd/tools/crane.go @@ -247,10 +247,6 @@ func pruneImages(cmd *cobra.Command, _ []string) error { func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.DeployedPackage, registryEndpoint string) error { authOption := images.WithPushAuth(zarfState.RegistryInfo) - - 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 { @@ -277,9 +273,6 @@ 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 { @@ -302,8 +295,6 @@ 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 { @@ -316,9 +307,6 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D imageDigestsToPrune[digestRef] = true } } - - spinner.Success() - if len(imageDigestsToPrune) > 0 { message.Note(lang.CmdToolsRegistryPruneImageList) @@ -339,9 +327,6 @@ 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) @@ -349,8 +334,6 @@ func doPruneImagesForPackages(zarfState *types.ZarfState, zarfPackages []types.D return err } } - - spinner.Success() } } else { message.Note(lang.CmdToolsRegistryPruneNoImages) diff --git a/src/cmd/tools/wait.go b/src/cmd/tools/wait.go index fda0344fbc..a3b4bd472a 100644 --- a/src/cmd/tools/wait.go +++ b/src/cmd/tools/wait.go @@ -10,7 +10,6 @@ import ( "github.com/spf13/cobra" "github.com/zarf-dev/zarf/src/config/lang" - "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/pkg/utils" // Import to initialize client auth plugins. @@ -62,5 +61,4 @@ func init() { toolsCmd.AddCommand(waitForCmd) waitForCmd.Flags().StringVar(&waitTimeout, "timeout", "5m", lang.CmdToolsWaitForFlagTimeout) waitForCmd.Flags().StringVarP(&waitNamespace, "namespace", "n", "", lang.CmdToolsWaitForFlagNamespace) - waitForCmd.Flags().BoolVar(&message.NoProgress, "no-progress", false, lang.RootCmdFlagNoProgress) } diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index e1a8dc6c5a..3bb3b1df78 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -35,11 +35,6 @@ func (h *Helm) InstallOrUpgradeChart(ctx context.Context) (types.ConnectStrings, if fromMessage == "" { fromMessage = "Zarf-generated helm chart" } - spinner := message.NewProgressSpinner("Processing helm chart %s:%s from %s", - h.chart.Name, - h.chart.Version, - fromMessage) - defer spinner.Stop() // If no release name is specified, use the chart name. if h.chart.ReleaseName == "" { @@ -47,7 +42,7 @@ func (h *Helm) InstallOrUpgradeChart(ctx context.Context) (types.ConnectStrings, } // Setup K8s connection. - err := h.createActionConfig(h.chart.Namespace, spinner) + err := h.createActionConfig(h.chart.Namespace) if err != nil { return nil, "", fmt.Errorf("unable to initialize the K8s client: %w", err) } @@ -63,31 +58,19 @@ func (h *Helm) InstallOrUpgradeChart(ctx context.Context) (types.ConnectStrings, var err error releases, histErr := histClient.Run(h.chart.ReleaseName) - - spinner.Updatef("Checking for existing helm deployment") - if errors.Is(histErr, driver.ErrReleaseNotFound) { - // No prior release, try to install it. - spinner.Updatef("Attempting chart installation") - _, err = h.installChart(ctx, postRender) } else if histErr == nil && len(releases) > 0 { - // Otherwise, there is a prior release so upgrade it. - spinner.Updatef("Attempting chart upgrade") - lastRelease := releases[len(releases)-1] _, err = h.upgradeChart(ctx, lastRelease, postRender) } else { - // 😭 things aren't working return fmt.Errorf("unable to verify the chart installation status: %w", histErr) } if err != nil { return err } - - spinner.Success() return nil }, retry.Context(ctx), retry.Attempts(uint(h.retries)), retry.Delay(500*time.Millisecond)) if err != nil { @@ -110,7 +93,6 @@ func (h *Helm) InstallOrUpgradeChart(ctx context.Context) (types.ConnectStrings, } // Attempt to rollback on a failed upgrade. - spinner.Updatef("Performing chart rollback") err = h.rollbackChart(h.chart.ReleaseName, previouslyDeployedVersion) if err != nil { return nil, "", fmt.Errorf("%w: unable to rollback: %w", installErr, err) @@ -124,10 +106,7 @@ func (h *Helm) InstallOrUpgradeChart(ctx context.Context) (types.ConnectStrings, // TemplateChart generates a helm template from a given chart. func (h *Helm) TemplateChart(ctx context.Context) (manifest string, chartValues chartutil.Values, err error) { - spinner := message.NewProgressSpinner("Templating helm chart %s", h.chart.Name) - defer spinner.Stop() - - err = h.createActionConfig(h.chart.Namespace, spinner) + err = h.createActionConfig(h.chart.Namespace) // Setup K8s connection. if err != nil { @@ -182,16 +161,13 @@ func (h *Helm) TemplateChart(ctx context.Context) (manifest string, chartValues for _, hook := range templatedChart.Hooks { manifest += fmt.Sprintf("\n---\n%s", hook.Manifest) } - - spinner.Success() - return manifest, chartValues, nil } // RemoveChart removes a chart from the cluster. -func (h *Helm) RemoveChart(namespace string, name string, spinner *message.Spinner) error { +func (h *Helm) RemoveChart(namespace string, name string) error { // Establish a new actionConfig for the namespace. - _ = h.createActionConfig(namespace, spinner) + _ = h.createActionConfig(namespace) // Perform the uninstall. response, err := h.uninstallChart(name) message.Debug(response) @@ -201,10 +177,7 @@ func (h *Helm) RemoveChart(namespace string, name string, spinner *message.Spinn // UpdateReleaseValues updates values for a given chart release // (note: this only works on single-deep charts, charts with dependencies (like loki-stack) will not work) func (h *Helm) UpdateReleaseValues(ctx context.Context, updatedValues map[string]interface{}) error { - spinner := message.NewProgressSpinner("Updating values for helm release %s", h.chart.ReleaseName) - defer spinner.Stop() - - err := h.createActionConfig(h.chart.Namespace, spinner) + err := h.createActionConfig(h.chart.Namespace) if err != nil { return fmt.Errorf("unable to initialize the K8s client: %w", err) } @@ -245,9 +218,6 @@ func (h *Helm) UpdateReleaseValues(ctx context.Context, updatedValues map[string if err != nil { return err } - - spinner.Success() - return nil } diff --git a/src/internal/packager/helm/common.go b/src/internal/packager/helm/common.go index 8d20e84483..fd0550bcb4 100644 --- a/src/internal/packager/helm/common.go +++ b/src/internal/packager/helm/common.go @@ -17,7 +17,6 @@ import ( "github.com/zarf-dev/zarf/src/api/v1alpha1" "github.com/zarf-dev/zarf/src/config" "github.com/zarf-dev/zarf/src/pkg/cluster" - "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/pkg/variables" "github.com/zarf-dev/zarf/src/types" "helm.sh/helm/v3/pkg/action" @@ -80,9 +79,6 @@ func NewClusterOnly(cfg *types.PackagerConfig, variableConfig *variables.Variabl // NewFromZarfManifest generates a helm chart and config from a given Zarf manifest. func NewFromZarfManifest(manifest v1alpha1.ZarfManifest, manifestPath, packageName, componentName string, mods ...Modifier) (h *Helm, err error) { - spinner := message.NewProgressSpinner("Starting helm chart generation %s", manifest.Name) - defer spinner.Stop() - // Generate a new chart. tmpChart := new(chart.Chart) tmpChart.Metadata = new(chart.Metadata) @@ -100,7 +96,6 @@ func NewFromZarfManifest(manifest v1alpha1.ZarfManifest, manifestPath, packageNa // Add the manifest files so helm does its thing. for _, file := range manifest.Files { - spinner.Updatef("Processing %s", file) manifest := path.Join(manifestPath, file) data, err := os.ReadFile(manifest) if err != nil { @@ -131,9 +126,6 @@ func NewFromZarfManifest(manifest v1alpha1.ZarfManifest, manifestPath, packageNa for _, mod := range mods { mod(h) } - - spinner.Success() - return h, nil } diff --git a/src/internal/packager/helm/destroy.go b/src/internal/packager/helm/destroy.go index 44c519a00a..a11db1bec5 100644 --- a/src/internal/packager/helm/destroy.go +++ b/src/internal/packager/helm/destroy.go @@ -5,6 +5,7 @@ package helm import ( + "fmt" "regexp" "github.com/zarf-dev/zarf/src/pkg/cluster" @@ -14,17 +15,13 @@ import ( // Destroy removes ZarfInitPackage charts from the cluster and optionally all Zarf-installed charts. func Destroy(purgeAllZarfInstallations bool) { - spinner := message.NewProgressSpinner("Removing Zarf-installed charts") - defer spinner.Stop() - h := Helm{} // Initially load the actionConfig without a namespace - err := h.createActionConfig("", spinner) + err := h.createActionConfig("") if err != nil { // Don't fatal since this is a removal action - spinner.Errorf(err, "Unable to initialize the K8s client") - return + message.Warn(fmt.Sprintf("could not load the action config: %w", err)) } // Match a name that begins with "zarf-" @@ -41,7 +38,7 @@ func Destroy(purgeAllZarfInstallations bool) { releases, err := list.Run() if err != nil { // Don't fatal since this is a removal action - spinner.Errorf(err, "Unable to get the list of installed charts") + message.Warn(fmt.Sprint("unable to get the list of installed charts: %w", err)) } // Iterate over all releases @@ -52,13 +49,10 @@ func Destroy(purgeAllZarfInstallations bool) { } // Filter on zarf releases if zarfPrefix.MatchString(release.Name) { - spinner.Updatef("Uninstalling helm chart %s/%s", release.Namespace, release.Name) - if err = h.RemoveChart(release.Namespace, release.Name, spinner); err != nil { + if err = h.RemoveChart(release.Namespace, release.Name); err != nil { // Don't fatal since this is a removal action - spinner.Errorf(err, "Unable to uninstall the chart") + message.Warn(fmt.Sprintf("unable to uninstall the chart: %w", err)) } } } - - spinner.Success() } diff --git a/src/internal/packager/helm/repo.go b/src/internal/packager/helm/repo.go index 249f19f0f2..565e78e878 100644 --- a/src/internal/packager/helm/repo.go +++ b/src/internal/packager/helm/repo.go @@ -68,9 +68,6 @@ func (h *Helm) PackageChart(ctx context.Context, cosignKeyPath string) error { // PackageChartFromLocalFiles creates a chart archive from a path to a chart on the host os. func (h *Helm) PackageChartFromLocalFiles(ctx context.Context, cosignKeyPath string) error { - spinner := message.NewProgressSpinner("Processing helm chart %s:%s from %s", h.chart.Name, h.chart.Version, h.chart.LocalPath) - defer spinner.Stop() - // Load and validate the chart cl, _, err := h.loadAndValidateChart(h.chart.LocalPath) if err != nil { @@ -105,17 +102,11 @@ func (h *Helm) PackageChartFromLocalFiles(ctx context.Context, cosignKeyPath str if err != nil { return err } - - spinner.Success() - return nil } // PackageChartFromGit is a special implementation of chart archiving that supports the https://p1.dso.mil/#/products/big-bang/ model. func (h *Helm) PackageChartFromGit(ctx context.Context, cosignKeyPath string) error { - spinner := message.NewProgressSpinner("Processing helm chart %s", h.chart.Name) - defer spinner.Stop() - // Retrieve the repo containing the chart gitPath, err := DownloadChartFromGitToTemp(ctx, h.chart.URL) if err != nil { @@ -130,9 +121,6 @@ func (h *Helm) PackageChartFromGit(ctx context.Context, cosignKeyPath string) er // DownloadPublishedChart loads a specific chart version from a remote repo. func (h *Helm) DownloadPublishedChart(ctx context.Context, cosignKeyPath string) error { - spinner := message.NewProgressSpinner("Processing helm chart %s:%s from repo %s", h.chart.Name, h.chart.Version, h.chart.URL) - defer spinner.Stop() - // Set up the helm pull config pull := action.NewPull() pull.Settings = cli.New() @@ -186,7 +174,6 @@ func (h *Helm) DownloadPublishedChart(ctx context.Context, cosignKeyPath string) // Set up the chart chartDownloader chartDownloader := downloader.ChartDownloader{ - Out: spinner, RegistryClient: regClient, // TODO: Further research this with regular/OCI charts Verify: downloader.VerifyNever, @@ -221,8 +208,6 @@ func (h *Helm) DownloadPublishedChart(ctx context.Context, cosignKeyPath string) return err } - spinner.Success() - return nil } diff --git a/src/internal/packager/helm/utils.go b/src/internal/packager/helm/utils.go index 8d3d5f3202..3fa652d358 100644 --- a/src/internal/packager/helm/utils.go +++ b/src/internal/packager/helm/utils.go @@ -8,7 +8,6 @@ import ( "fmt" "github.com/defenseunicorns/pkg/helpers/v2" - "github.com/zarf-dev/zarf/src/pkg/message" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chartutil" @@ -60,7 +59,7 @@ func (h *Helm) parseChartValues() (chartutil.Values, error) { return helpers.MergeMapRecursive(chartValues, h.valuesOverrides), nil } -func (h *Helm) createActionConfig(namespace string, spinner *message.Spinner) error { +func (h *Helm) createActionConfig(namespace string) error { // Initialize helm SDK actionConfig := new(action.Configuration) // Set the settings for the helm SDK @@ -70,7 +69,7 @@ func (h *Helm) createActionConfig(namespace string, spinner *message.Spinner) er h.settings.SetNamespace(namespace) // Setup K8s connection - err := actionConfig.Init(h.settings.RESTClientGetter(), namespace, "", spinner.Updatef) + err := actionConfig.Init(h.settings.RESTClientGetter(), namespace, "", func(string, ...interface{}) {}) // Set the actionConfig is the received Helm pointer h.actionConfig = actionConfig diff --git a/src/internal/packager/helm/zarf.go b/src/internal/packager/helm/zarf.go index 03e4db2ed0..494210064b 100644 --- a/src/internal/packager/helm/zarf.go +++ b/src/internal/packager/helm/zarf.go @@ -20,7 +20,6 @@ import ( "github.com/zarf-dev/zarf/src/api/v1alpha1" "github.com/zarf-dev/zarf/src/internal/packager/template" "github.com/zarf-dev/zarf/src/pkg/cluster" - "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/pkg/transform" "github.com/zarf-dev/zarf/src/pkg/utils" ) @@ -70,9 +69,6 @@ func (h *Helm) UpdateZarfRegistryValues(ctx context.Context) error { // UpdateZarfAgentValues updates the Zarf agent deployment with the new state values func (h *Helm) UpdateZarfAgentValues(ctx context.Context) error { - spinner := message.NewProgressSpinner("Gathering information to update Zarf Agent TLS") - defer spinner.Stop() - deployment, err := h.cluster.Clientset.AppsV1().Deployments(cluster.ZarfNamespaceName).Get(ctx, "agent-hook", metav1.GetOptions{}) if err != nil { return err @@ -82,7 +78,7 @@ func (h *Helm) UpdateZarfAgentValues(ctx context.Context) error { return err } - err = h.createActionConfig(cluster.ZarfNamespaceName, spinner) + err = h.createActionConfig(cluster.ZarfNamespaceName) if err != nil { return err } @@ -93,8 +89,6 @@ func (h *Helm) UpdateZarfAgentValues(ctx context.Context) error { if err != nil { return fmt.Errorf("unable to list helm releases: %w", err) } - spinner.Success() - for _, release := range releases { // Update the Zarf Agent release with the new values if release.Chart.Name() == "raw-init-zarf-agent-zarf-agent" { @@ -127,8 +121,6 @@ func (h *Helm) UpdateZarfAgentValues(ctx context.Context) error { // Trigger a rolling update for the TLS secret update to take effect. // https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment - spinner = message.NewProgressSpinner("Performing a rolling update for the Zarf Agent deployment") - defer spinner.Stop() // Re-fetch the agent deployment before we update since the resourceVersion has changed after updating the Helm release values. // Avoids this error: https://github.com/kubernetes/kubernetes/issues/28149 @@ -161,7 +153,5 @@ func (h *Helm) UpdateZarfAgentValues(ctx context.Context) error { if err != nil { return err } - - spinner.Success() return nil } diff --git a/src/internal/packager/images/pull.go b/src/internal/packager/images/pull.go index a11b6097d7..36278b2261 100644 --- a/src/internal/packager/images/pull.go +++ b/src/internal/packager/images/pull.go @@ -62,14 +62,7 @@ func checkForIndex(refInfo transform.Image, desc *remote.Descriptor) error { // Pull pulls all of the images from the given config. func Pull(ctx context.Context, cfg PullConfig) (map[transform.Image]v1.Image, error) { - var longer string imageCount := len(cfg.ImageList) - // Give some additional user feedback on larger image sets - if imageCount > 15 { - longer = "This step may take a couple of minutes to complete." - } else if imageCount > 5 { - longer = "This step may take several seconds to complete." - } if err := helpers.CreateDirectory(cfg.DestinationDirectory, helpers.ReadExecuteAllWriteUser); err != nil { return nil, fmt.Errorf("failed to create image path %s: %w", cfg.DestinationDirectory, err) @@ -79,10 +72,6 @@ func Pull(ctx context.Context, cfg PullConfig) (map[transform.Image]v1.Image, er if err != nil { return nil, err } - - spinner := message.NewProgressSpinner("Fetching info for %d images. %s", imageCount, longer) - defer spinner.Stop() - logs.Warn.SetOutput(&message.DebugWriter{}) logs.Progress.SetOutput(&message.DebugWriter{}) @@ -95,14 +84,11 @@ func Pull(ctx context.Context, cfg PullConfig) (map[transform.Image]v1.Image, er fetched := map[transform.Image]v1.Image{} - var counter, totalBytes atomic.Int64 + var totalBytes atomic.Int64 for _, refInfo := range cfg.ImageList { refInfo := refInfo eg.Go(func() error { - idx := counter.Add(1) - spinner.Updatef("Fetching image info (%d of %d)", idx, imageCount) - ref := refInfo.Reference for k, v := range cfg.RegistryOverrides { if strings.HasPrefix(refInfo.Reference, k) { @@ -220,9 +206,6 @@ func Pull(ctx context.Context, cfg PullConfig) (map[transform.Image]v1.Image, er if err := eg.Wait(); err != nil { return nil, err } - - spinner.Successf("Fetched info for %d images", imageCount) - doneSaving := make(chan error) updateText := fmt.Sprintf("Pulling %d images", imageCount) go utils.RenderProgressBarForLocalDirWrite(cfg.DestinationDirectory, totalBytes.Load(), doneSaving, updateText, updateText) diff --git a/src/internal/packager/sbom/catalog.go b/src/internal/packager/sbom/catalog.go index 65c32c039b..8f22669f56 100755 --- a/src/internal/packager/sbom/catalog.go +++ b/src/internal/packager/sbom/catalog.go @@ -37,7 +37,6 @@ import ( // Builder is the main struct used to build SBOM artifacts. type Builder struct { - spinner *message.Spinner cachePath string imagesPath string outputDir string @@ -52,19 +51,15 @@ var componentPrefix = "zarf-component-" // Catalog catalogs the given components and images to create an SBOM. func Catalog(ctx context.Context, componentSBOMs map[string]*layout.ComponentSBOM, imageList []transform.Image, paths *layout.PackagePaths) error { - imageCount := len(imageList) - componentCount := len(componentSBOMs) cachePath, err := config.GetAbsCachePath() if err != nil { return err } builder := Builder{ - spinner: message.NewProgressSpinner("Creating SBOMs for %d images and %d components with files.", imageCount, componentCount), cachePath: cachePath, imagesPath: paths.Images.Base, outputDir: paths.SBOMs.Path, } - defer builder.spinner.Stop() // Ensure the sbom directory exists _ = helpers.CreateDirectory(builder.outputDir, helpers.ReadWriteExecuteUser) @@ -72,7 +67,6 @@ func Catalog(ctx context.Context, componentSBOMs map[string]*layout.ComponentSBO // Generate a list of images and files for the sbom viewer json, err := builder.generateJSONList(componentSBOMs, imageList) if err != nil { - builder.spinner.Errorf(err, "Unable to generate the SBOM image list") return err } builder.jsonList = json @@ -80,23 +74,19 @@ func Catalog(ctx context.Context, componentSBOMs map[string]*layout.ComponentSBO // Generate SBOM for each image currImage := 1 for _, refInfo := range imageList { - builder.spinner.Updatef("Creating image SBOMs (%d of %d): %s", currImage, imageCount, refInfo.Reference) // Get the image that we are creating an SBOM for img, err := utils.LoadOCIImage(paths.Images.Base, refInfo) if err != nil { - builder.spinner.Errorf(err, "Unable to load the image to generate an SBOM") return err } jsonData, err := builder.createImageSBOM(ctx, img, refInfo.Reference) if err != nil { - builder.spinner.Errorf(err, "Unable to create SBOM for image %s", refInfo.Reference) return err } if err = builder.createSBOMViewerAsset(refInfo.Reference, jsonData); err != nil { - builder.spinner.Errorf(err, "Unable to create SBOM viewer for image %s", refInfo.Reference) return err } @@ -107,7 +97,6 @@ func Catalog(ctx context.Context, componentSBOMs map[string]*layout.ComponentSBO // Generate SBOM for each component for component := range componentSBOMs { - builder.spinner.Updatef("Creating component file SBOMs (%d of %d): %s", currComponent, componentCount, component) if componentSBOMs[component] == nil { message.Debugf("Component %s has invalid SBOM, skipping", component) @@ -116,12 +105,10 @@ func Catalog(ctx context.Context, componentSBOMs map[string]*layout.ComponentSBO jsonData, err := builder.createFileSBOM(ctx, *componentSBOMs[component], component) if err != nil { - builder.spinner.Errorf(err, "Unable to create SBOM for component %s", component) return err } if err = builder.createSBOMViewerAsset(fmt.Sprintf("%s%s", componentPrefix, component), jsonData); err != nil { - builder.spinner.Errorf(err, "Unable to create SBOM viewer for component %s", component) return err } @@ -131,18 +118,14 @@ func Catalog(ctx context.Context, componentSBOMs map[string]*layout.ComponentSBO // Include the compare tool if there are any image SBOMs OR component SBOMs if len(componentSBOMs) > 0 || len(imageList) > 0 { if err := builder.createSBOMCompareAsset(); err != nil { - builder.spinner.Errorf(err, "Unable to create SBOM compare tool") return err } } if err := paths.SBOMs.Archive(); err != nil { - builder.spinner.Errorf(err, "Unable to archive SBOMs") return err } - builder.spinner.Success() - return nil } diff --git a/src/pkg/cluster/cluster.go b/src/pkg/cluster/cluster.go index 5db77e0c9c..5366f6e023 100644 --- a/src/pkg/cluster/cluster.go +++ b/src/pkg/cluster/cluster.go @@ -18,8 +18,6 @@ import ( "github.com/avast/retry-go/v4" pkgkubernetes "github.com/defenseunicorns/pkg/kubernetes" - - "github.com/zarf-dev/zarf/src/pkg/message" ) const ( @@ -38,9 +36,6 @@ type Cluster struct { // NewClusterWithWait creates a new Cluster instance and waits for the given timeout for the cluster to be ready. func NewClusterWithWait(ctx context.Context) (*Cluster, error) { - spinner := message.NewProgressSpinner("Waiting for cluster connection") - defer spinner.Stop() - c, err := NewCluster() if err != nil { return nil, err @@ -67,9 +62,6 @@ func NewClusterWithWait(ctx context.Context) (*Cluster, error) { if err != nil { return nil, err } - - spinner.Success() - return c, nil } diff --git a/src/pkg/cluster/injector.go b/src/pkg/cluster/injector.go index 48552ac5e1..089e0d8d70 100644 --- a/src/pkg/cluster/injector.go +++ b/src/pkg/cluster/injector.go @@ -27,7 +27,6 @@ import ( pkgkubernetes "github.com/defenseunicorns/pkg/kubernetes" "github.com/zarf-dev/zarf/src/config" - "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/pkg/transform" "github.com/zarf-dev/zarf/src/pkg/utils" ) @@ -39,10 +38,6 @@ func (c *Cluster) StartInjection(ctx context.Context, tmpDir, imagesDir string, if err != nil { return err } - - spinner := message.NewProgressSpinner("Attempting to bootstrap the seed image into the cluster") - defer spinner.Stop() - resReq := corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse(".5"), @@ -58,7 +53,7 @@ func (c *Cluster) StartInjection(ctx context.Context, tmpDir, imagesDir string, return err } - payloadCmNames, shasum, err := c.createPayloadConfigMaps(ctx, spinner, tmpDir, imagesDir, injectorSeedSrcs) + payloadCmNames, shasum, err := c.createPayloadConfigMaps(ctx, tmpDir, imagesDir, injectorSeedSrcs) if err != nil { return fmt.Errorf("unable to generate the injector payload configmaps: %w", err) } @@ -121,8 +116,6 @@ func (c *Cluster) StartInjection(ctx context.Context, tmpDir, imagesDir string, if err != nil { return err } - - spinner.Success() return nil } @@ -186,7 +179,7 @@ func (c *Cluster) StopInjection(ctx context.Context) error { return nil } -func (c *Cluster) createPayloadConfigMaps(ctx context.Context, spinner *message.Spinner, tmpDir, imagesDir string, injectorSeedSrcs []string) ([]string, string, error) { +func (c *Cluster) createPayloadConfigMaps(ctx context.Context, tmpDir, imagesDir string, injectorSeedSrcs []string) ([]string, string, error) { tarPath := filepath.Join(tmpDir, "payload.tar.gz") seedImagesDir := filepath.Join(tmpDir, "seed-images") if err := helpers.CreateDirectory(seedImagesDir, helpers.ReadWriteExecuteUser); err != nil { @@ -233,9 +226,6 @@ func (c *Cluster) createPayloadConfigMaps(ctx context.Context, spinner *message. cmNames := []string{} for i, data := range chunks { fileName := fmt.Sprintf("zarf-payload-%03d", i) - - spinner.Updatef("Adding archive binary configmap %d of %d to the cluster", i+1, len(chunks)) - cm := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Namespace: ZarfNamespaceName, diff --git a/src/pkg/cluster/namespace.go b/src/pkg/cluster/namespace.go index 99d50a5f5e..1ce1bf9176 100644 --- a/src/pkg/cluster/namespace.go +++ b/src/pkg/cluster/namespace.go @@ -13,15 +13,10 @@ import ( corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/zarf-dev/zarf/src/pkg/message" ) // DeleteZarfNamespace deletes the Zarf namespace from the connected cluster. func (c *Cluster) DeleteZarfNamespace(ctx context.Context) error { - spinner := message.NewProgressSpinner("Deleting the zarf namespace from this cluster") - defer spinner.Stop() - err := c.Clientset.CoreV1().Namespaces().Delete(ctx, ZarfNamespaceName, metav1.DeleteOptions{}) if kerrors.IsNotFound(err) { return nil diff --git a/src/pkg/cluster/secrets.go b/src/pkg/cluster/secrets.go index aa693c6a44..26cdaa4d63 100644 --- a/src/pkg/cluster/secrets.go +++ b/src/pkg/cluster/secrets.go @@ -114,9 +114,6 @@ func (c *Cluster) GenerateGitPullCreds(namespace, name string, gitServerInfo typ // UpdateZarfManagedImageSecrets updates all Zarf-managed image secrets in all namespaces based on state func (c *Cluster) UpdateZarfManagedImageSecrets(ctx context.Context, state *types.ZarfState) error { - spinner := message.NewProgressSpinner("Updating existing Zarf-managed image secrets") - defer spinner.Stop() - namespaceList, err := c.Clientset.CoreV1().Namespaces().List(ctx, metav1.ListOptions{}) if err != nil { return err @@ -141,22 +138,16 @@ func (c *Cluster) UpdateZarfManagedImageSecrets(ctx context.Context, state *type if maps.EqualFunc(currentRegistrySecret.Data, newRegistrySecret.Data, func(v1, v2 []byte) bool { return bytes.Equal(v1, v2) }) { continue } - spinner.Updatef("Updating existing Zarf-managed image secret for namespace: '%s'", namespace.Name) _, err = c.Clientset.CoreV1().Secrets(newRegistrySecret.Namespace).Update(ctx, newRegistrySecret, metav1.UpdateOptions{}) if err != nil { return err } } - - spinner.Success() return nil } // UpdateZarfManagedGitSecrets updates all Zarf-managed git secrets in all namespaces based on state func (c *Cluster) UpdateZarfManagedGitSecrets(ctx context.Context, state *types.ZarfState) error { - spinner := message.NewProgressSpinner("Updating existing Zarf-managed git secrets") - defer spinner.Stop() - namespaceList, err := c.Clientset.CoreV1().Namespaces().List(ctx, metav1.ListOptions{}) if err != nil { return err @@ -177,14 +168,11 @@ func (c *Cluster) UpdateZarfManagedGitSecrets(ctx context.Context, state *types. if maps.Equal(currentGitSecret.StringData, newGitSecret.StringData) { continue } - spinner.Updatef("Updating existing Zarf-managed git secret for namespace: %s", namespace.Name) _, err = c.Clientset.CoreV1().Secrets(newGitSecret.Namespace).Update(ctx, newGitSecret, metav1.UpdateOptions{}) if err != nil { return err } } - - spinner.Success() return nil } diff --git a/src/pkg/cluster/state.go b/src/pkg/cluster/state.go index f2279b0221..97c9459fa2 100644 --- a/src/pkg/cluster/state.go +++ b/src/pkg/cluster/state.go @@ -36,12 +36,9 @@ const ( // InitZarfState initializes the Zarf state with the given temporary directory and init configs. func (c *Cluster) InitZarfState(ctx context.Context, initOptions types.ZarfInitOptions) error { - spinner := message.NewProgressSpinner("Gathering cluster state information") - defer spinner.Stop() // Attempt to load an existing state prior to init. // NOTE: We are ignoring the error here because we don't really expect a state to exist yet. - spinner.Updatef("Checking cluster for existing Zarf deployment") state, err := c.LoadZarfState(ctx) if err != nil && !kerrors.IsNotFound(err) { return fmt.Errorf("failed to check for existing state: %w", err) @@ -50,8 +47,6 @@ func (c *Cluster) InitZarfState(ctx context.Context, initOptions types.ZarfInitO // If state is nil, this is a new cluster. if state == nil { state = &types.ZarfState{} - spinner.Updatef("New cluster, no prior Zarf deployments found") - if initOptions.ApplianceMode { // If the K3s component is being deployed, skip distro detection. state.Distro = DistroIsK3s @@ -72,10 +67,6 @@ func (c *Cluster) InitZarfState(ctx context.Context, initOptions types.ZarfInitO state.Distro = detectDistro(nodeList.Items[0], namespaceList.Items) } - if state.Distro != DistroIsUnknown { - spinner.Updatef("Detected K8s distro %s", state.Distro) - } - // Setup zarf agent PKI agentTLS, err := pki.GeneratePKI(config.ZarfAgentHost) if err != nil { @@ -89,7 +80,6 @@ func (c *Cluster) InitZarfState(ctx context.Context, initOptions types.ZarfInitO } // Mark existing namespaces as ignored for the zarf agent to prevent mutating resources we don't own. for _, namespace := range namespaceList.Items { - spinner.Updatef("Marking existing namespace %s as ignored by Zarf Agent", namespace.Name) if namespace.Labels == nil { // Ensure label map exists to avoid nil panic namespace.Labels = make(map[string]string) @@ -104,7 +94,6 @@ func (c *Cluster) InitZarfState(ctx context.Context, initOptions types.ZarfInitO } // Try to create the zarf namespace. - spinner.Updatef("Creating the Zarf namespace") zarfNamespace := NewZarfManagedNamespace(ZarfNamespaceName) err = func() error { _, err := c.Clientset.CoreV1().Namespaces().Create(ctx, zarfNamespace, metav1.CreateOptions{}) @@ -181,9 +170,6 @@ func (c *Cluster) InitZarfState(ctx context.Context, initOptions types.ZarfInitO if initOptions.StorageClass != "" { state.StorageClass = initOptions.StorageClass } - - spinner.Success() - // Save the state back to K8s if err := c.SaveZarfState(ctx, state); err != nil { return fmt.Errorf("unable to save the Zarf state: %w", err) diff --git a/src/pkg/cluster/zarf.go b/src/pkg/cluster/zarf.go index b990b3de81..5997c03319 100644 --- a/src/pkg/cluster/zarf.go +++ b/src/pkg/cluster/zarf.go @@ -134,10 +134,7 @@ func (c *Cluster) DeleteDeployedPackage(ctx context.Context, packageName string) } // StripZarfLabelsAndSecretsFromNamespaces removes metadata and secrets from existing namespaces no longer manged by Zarf. -func (c *Cluster) StripZarfLabelsAndSecretsFromNamespaces(ctx context.Context) { - spinner := message.NewProgressSpinner("Removing zarf metadata & secrets from existing namespaces not managed by Zarf") - defer spinner.Stop() - +func (c *Cluster) StripZarfLabelsAndSecretsFromNamespaces(ctx context.Context) error { deleteOptions := metav1.DeleteOptions{} listOptions := metav1.ListOptions{ LabelSelector: ZarfManagedByLabel + "=zarf", @@ -145,31 +142,27 @@ func (c *Cluster) StripZarfLabelsAndSecretsFromNamespaces(ctx context.Context) { namespaceList, err := c.Clientset.CoreV1().Namespaces().List(ctx, metav1.ListOptions{}) if err != nil { - spinner.Errorf(err, "Unable to get k8s namespaces") + fmt.Errorf("unable to get k8s namespaces: %w", err) } else { for _, namespace := range namespaceList.Items { if _, ok := namespace.Labels[AgentLabel]; ok { - spinner.Updatef("Removing Zarf Agent label for namespace %s", namespace.Name) delete(namespace.Labels, AgentLabel) namespaceCopy := namespace _, err := c.Clientset.CoreV1().Namespaces().Update(ctx, &namespaceCopy, metav1.UpdateOptions{}) if err != nil { // This is not a hard failure, but we should log it - spinner.Errorf(err, "Unable to update the namespace labels for %s", namespace.Name) + message.Debugf("unable to update the namespace labels for %s", namespace.Name) } } - - spinner.Updatef("Removing Zarf secrets for namespace %s", namespace.Name) err := c.Clientset.CoreV1(). Secrets(namespace.Name). DeleteCollection(ctx, deleteOptions, listOptions) if err != nil { - spinner.Errorf(err, "Unable to delete secrets from namespace %s", namespace.Name) + return fmt.Errorf("unable to delete secrets from namespace %s", namespace.Name) } } } - - spinner.Success() + return nil } // PackageSecretNeedsWait checks if a package component has a running webhook that needs to be waited on. @@ -203,15 +196,12 @@ func (c *Cluster) RecordPackageDeploymentAndWait(ctx context.Context, pkg v1alph return nil, err } - packageNeedsWait, waitSeconds, hookName := c.PackageSecretNeedsWait(deployedPackage, component, skipWebhooks) + packageNeedsWait, waitSeconds, _ := c.PackageSecretNeedsWait(deployedPackage, component, skipWebhooks) // If no webhooks need to complete, we can return immediately. if !packageNeedsWait { return deployedPackage, nil } - spinner := message.NewProgressSpinner("Waiting for webhook %q to complete for component %q", hookName, component.Name) - defer spinner.Stop() - waitDuration := types.DefaultWebhookWaitDuration if waitSeconds > 0 { waitDuration = time.Duration(waitSeconds) * time.Second @@ -232,7 +222,6 @@ func (c *Cluster) RecordPackageDeploymentAndWait(ctx context.Context, pkg v1alph if err != nil { return nil, err } - spinner.Success() return deployedPackage, nil } diff --git a/src/pkg/layout/package.go b/src/pkg/layout/package.go index 7824d34ba9..111bc51a60 100644 --- a/src/pkg/layout/package.go +++ b/src/pkg/layout/package.go @@ -226,21 +226,16 @@ func (pp *PackagePaths) GenerateChecksums() (string, error) { // ArchivePackage creates an archive for a Zarf package. func (pp *PackagePaths) ArchivePackage(destinationTarball string, maxPackageSizeMB int) error { - spinner := message.NewProgressSpinner("Writing %s to %s", pp.Base, destinationTarball) - defer spinner.Stop() - // Make the archive archiveSrc := []string{pp.Base + string(os.PathSeparator)} if err := archiver.Archive(archiveSrc, destinationTarball); err != nil { return fmt.Errorf("unable to create package: %w", err) } - spinner.Updatef("Wrote %s to %s", pp.Base, destinationTarball) fi, err := os.Stat(destinationTarball) if err != nil { return fmt.Errorf("unable to read the package archive: %w", err) } - spinner.Successf("Package saved to %q", destinationTarball) // Convert Megabytes to bytes. chunkSize := maxPackageSizeMB * 1000 * 1000 diff --git a/src/pkg/message/logo.go b/src/pkg/message/logo.go index 368f7e341f..fbd5cfd9bc 100644 --- a/src/pkg/message/logo.go +++ b/src/pkg/message/logo.go @@ -4,11 +4,8 @@ // Package message provides a rich set of functions for displaying messages to the user. package message -// GetLogo returns the awesome menu ascii logo. +// GetLogo returns the menu ascii logo. func GetLogo() string { - if NoProgress { - return "" - } var logo = `          *,                                                                               diff --git a/src/pkg/message/message.go b/src/pkg/message/message.go index 0eea8b326c..e00255e104 100644 --- a/src/pkg/message/message.go +++ b/src/pkg/message/message.go @@ -33,9 +33,6 @@ const ( TermWidth = 100 ) -// NoProgress tracks whether spinner/progress bars show updates. -var NoProgress bool - // RuleLine creates a line of ━ as wide as the terminal var RuleLine = strings.Repeat("━", TermWidth) diff --git a/src/pkg/message/progress.go b/src/pkg/message/progress.go index e756ae0715..ecb538c956 100644 --- a/src/pkg/message/progress.go +++ b/src/pkg/message/progress.go @@ -23,20 +23,16 @@ type ProgressBar struct { func NewProgressBar(total int64, text string) *ProgressBar { var progress *pterm.ProgressbarPrinter var err error - if NoProgress { - Info(text) - } else { - progress, err = pterm.DefaultProgressbar. - WithTotal(int(total)). - WithShowCount(false). - WithTitle(padding + text). - WithRemoveWhenDone(true). - WithMaxWidth(TermWidth). - WithWriter(os.Stderr). - Start() - if err != nil { - WarnErr(err, "Unable to create default progressbar") - } + progress, err = pterm.DefaultProgressbar. + WithTotal(int(total)). + WithShowCount(false). + WithTitle(padding + text). + WithRemoveWhenDone(true). + WithMaxWidth(TermWidth). + WithWriter(os.Stderr). + Start() + if err != nil { + WarnErr(err, "Unable to create default progressbar") } return &ProgressBar{ @@ -48,10 +44,6 @@ func NewProgressBar(total int64, text string) *ProgressBar { // Updatef updates the ProgressBar with new text. func (p *ProgressBar) Updatef(format string, a ...any) { msg := fmt.Sprintf(format, a...) - if NoProgress { - debugPrinter(2, msg) - return - } p.progress.UpdateTitle(padding + msg) } @@ -78,10 +70,6 @@ func (p *ProgressBar) Close() error { // Update updates the ProgressBar with completed progress and new text. func (p *ProgressBar) Update(complete int64, text string) { - if NoProgress { - debugPrinter(2, text) - return - } p.progress.UpdateTitle(padding + text) chunk := int(complete) - p.progress.Current p.Add(chunk) diff --git a/src/pkg/message/spinner.go b/src/pkg/message/spinner.go deleted file mode 100644 index 76d2d81bb5..0000000000 --- a/src/pkg/message/spinner.go +++ /dev/null @@ -1,144 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2021-Present The Zarf Authors - -// Package message provides a rich set of functions for displaying messages to the user. -package message - -import ( - "bufio" - "bytes" - "fmt" - "log/slog" - "strings" - - "github.com/pterm/pterm" -) - -var activeSpinner *Spinner - -var sequence = []string{` ⠋ `, ` ⠙ `, ` ⠹ `, ` ⠸ `, ` ⠼ `, ` ⠴ `, ` ⠦ `, ` ⠧ `, ` ⠇ `, ` ⠏ `} - -// Spinner is a wrapper around pterm.SpinnerPrinter. -type Spinner struct { - spinner *pterm.SpinnerPrinter - startText string - termWidth int - preserveWrites bool -} - -// NewProgressSpinner creates a new progress spinner. -func NewProgressSpinner(format string, a ...any) *Spinner { - if activeSpinner != nil { - activeSpinner.Updatef(format, a...) - debugPrinter(2, "Active spinner already exists") - return activeSpinner - } - - var spinner *pterm.SpinnerPrinter - var err error - text := pterm.Sprintf(format, a...) - if NoProgress { - Info(text) - } else { - spinner, err = pterm.DefaultSpinner. - WithRemoveWhenDone(false). - // Src: https://github.com/gernest/wow/blob/master/spin/spinners.go#L335 - WithSequence(sequence...). - Start(text) - if err != nil { - slog.Debug("unable to create default spinner", "error", err) - } - } - - activeSpinner = &Spinner{ - spinner: spinner, - startText: text, - termWidth: pterm.GetTerminalWidth(), - } - - return activeSpinner -} - -// EnablePreserveWrites enables preserving writes to the terminal. -func (p *Spinner) EnablePreserveWrites() { - p.preserveWrites = true -} - -// DisablePreserveWrites disables preserving writes to the terminal. -func (p *Spinner) DisablePreserveWrites() { - p.preserveWrites = false -} - -// Write the given text to the spinner. -func (p *Spinner) Write(raw []byte) (int, error) { - size := len(raw) - if NoProgress { - if p.preserveWrites { - pterm.Printfln(" %s", string(raw)) - } - - return size, nil - } - - // Split the text into lines and update the spinner for each line. - scanner := bufio.NewScanner(bytes.NewReader(raw)) - scanner.Split(bufio.ScanLines) - for scanner.Scan() { - // Only be fancy if preserve writes is enabled. - if p.preserveWrites { - text := pterm.Sprintf(" %s", scanner.Text()) - pterm.Fprinto(p.spinner.Writer, strings.Repeat(" ", pterm.GetTerminalWidth())) - pterm.Fprintln(p.spinner.Writer, text) - } else { - // Otherwise just update the spinner text. - p.spinner.UpdateText(scanner.Text()) - } - } - - return size, nil -} - -// Updatef updates the spinner text. -func (p *Spinner) Updatef(format string, a ...any) { - if NoProgress { - debugPrinter(2, fmt.Sprintf(format, a...)) - return - } - - pterm.Fprinto(p.spinner.Writer, strings.Repeat(" ", pterm.GetTerminalWidth())) - text := pterm.Sprintf(format, a...) - p.spinner.UpdateText(text) -} - -// Stop the spinner. -func (p *Spinner) Stop() { - if p.spinner != nil && p.spinner.IsActive { - err := p.spinner.Stop() - if err != nil { - slog.Debug("unable to stop spinner", "error", err) - } - } - activeSpinner = nil -} - -// Success prints a success message and stops the spinner. -func (p *Spinner) Success() { - p.Successf(p.startText) -} - -// Successf prints a success message with the spinner and stops it. -func (p *Spinner) Successf(format string, a ...any) { - text := pterm.Sprintf(format, a...) - if p.spinner != nil { - p.spinner.Success(text) - } else { - Info(text) - } - p.Stop() -} - -// Errorf prints an error message with the spinner. -func (p *Spinner) Errorf(err error, format string, a ...any) { - Warnf(format, a...) - debugPrinter(2, err) -} diff --git a/src/pkg/packager/actions/actions.go b/src/pkg/packager/actions/actions.go index dbef82b613..ea9eda2f91 100644 --- a/src/pkg/packager/actions/actions.go +++ b/src/pkg/packager/actions/actions.go @@ -78,15 +78,9 @@ func runAction(ctx context.Context, defaultCfg v1alpha1.ZarfComponentActionDefau } else { cmdEscaped = helpers.Truncate(cmd, 60, false) } - - spinner := message.NewProgressSpinner("Running \"%s\"", cmdEscaped) - // Persist the spinner output so it doesn't get overwritten by the command output. - spinner.EnablePreserveWrites() - actionDefaults := actionGetCfg(ctx, defaultCfg, action, variableConfig.GetAllTemplates()) if cmd, err = actionCmdMutation(ctx, cmd, actionDefaults.Shell); err != nil { - spinner.Errorf(err, "Error mutating command: %s", cmdEscaped) } duration := time.Duration(actionDefaults.MaxTotalSeconds) * time.Second @@ -99,7 +93,7 @@ retryCmd: // Perform the action run. tryCmd := func(ctx context.Context) error { // Try running the command and continue the retry loop if it fails. - if out, err = actionRun(ctx, actionDefaults, cmd, actionDefaults.Shell, spinner); err != nil { + if out, err = actionRun(ctx, actionDefaults, cmd, actionDefaults.Shell); err != nil { return err } @@ -113,20 +107,12 @@ retryCmd: } } - // If the action has a wait, change the spinner message to reflect that on success. - if action.Wait != nil { - spinner.Successf("Wait for \"%s\" succeeded", cmdEscaped) - } else { - spinner.Successf("Completed \"%s\"", cmdEscaped) - } - // If the command ran successfully, continue to the next action. return nil } // If no timeout is set, run the command and return or continue retrying. if actionDefaults.MaxTotalSeconds < 1 { - spinner.Updatef("Waiting for \"%s\" (no timeout)", cmdEscaped) //TODO (schristoff): Make it so tryCmd can take a normal ctx if err := tryCmd(context.Background()); err != nil { continue retryCmd @@ -136,7 +122,6 @@ retryCmd: } // Run the command on repeat until success or timeout. - spinner.Updatef("Waiting for \"%s\" (timeout: %ds)", cmdEscaped, actionDefaults.MaxTotalSeconds) select { // On timeout break the loop to abort. case <-timeout: @@ -275,7 +260,7 @@ func actionGetCfg(_ context.Context, cfg v1alpha1.ZarfComponentActionDefaults, a return cfg } -func actionRun(ctx context.Context, cfg v1alpha1.ZarfComponentActionDefaults, cmd string, shellPref v1alpha1.Shell, spinner *message.Spinner) (string, error) { +func actionRun(ctx context.Context, cfg v1alpha1.ZarfComponentActionDefaults, cmd string, shellPref v1alpha1.Shell) (string, error) { shell, shellArgs := exec.GetOSShell(shellPref) message.Debugf("Running command in %s: %s", shell, cmd) @@ -284,12 +269,6 @@ func actionRun(ctx context.Context, cfg v1alpha1.ZarfComponentActionDefaults, cm Env: cfg.Env, Dir: cfg.Dir, } - - if !cfg.Mute { - execCfg.Stdout = spinner - execCfg.Stderr = spinner - } - out, errOut, err := exec.CmdWithContext(ctx, execCfg, shell, append(shellArgs, cmd)...) // Dump final complete output (respect mute to prevent sensitive values from hitting the logs). if !cfg.Mute { diff --git a/src/pkg/packager/common.go b/src/pkg/packager/common.go index 1325a70b46..9d8ea8130a 100644 --- a/src/pkg/packager/common.go +++ b/src/pkg/packager/common.go @@ -151,9 +151,6 @@ func (p *Packager) isConnectedToCluster() bool { // attemptClusterChecks attempts to connect to the cluster and check for useful metadata and config mismatches. // NOTE: attemptClusterChecks should only return an error if there is a problem significant enough to halt a deployment, otherwise it should return nil and print a warning message. func (p *Packager) attemptClusterChecks(ctx context.Context) error { - spinner := message.NewProgressSpinner("Gathering additional cluster information (if available)") - defer spinner.Stop() - // Check the clusters architecture matches the package spec if err := p.validatePackageArchitecture(ctx); err != nil { if errors.Is(err, lang.ErrUnableToCheckArch) { @@ -171,9 +168,6 @@ func (p *Packager) attemptClusterChecks(ctx context.Context) error { return err } } - - spinner.Success() - return nil } diff --git a/src/pkg/packager/creator/normal.go b/src/pkg/packager/creator/normal.go index 099fda5e2b..aa74e7ca36 100644 --- a/src/pkg/packager/creator/normal.go +++ b/src/pkg/packager/creator/normal.go @@ -417,11 +417,7 @@ func (pc *PackageCreator) addComponent(ctx context.Context, component v1alpha1.Z } if len(component.DataInjections) > 0 { - spinner := message.NewProgressSpinner("Loading data injections") - defer spinner.Stop() - for dataIdx, data := range component.DataInjections { - spinner.Updatef("Copying data injection %s for %s", data.Target.Path, data.Target.Selector) rel := filepath.Join(layout.DataInjectionsDir, strconv.Itoa(dataIdx), filepath.Base(data.Target.Path)) dst := filepath.Join(componentPaths.Base, rel) @@ -436,7 +432,6 @@ func (pc *PackageCreator) addComponent(ctx context.Context, component v1alpha1.Z } } } - spinner.Success() } if len(component.Manifests) > 0 { @@ -447,10 +442,6 @@ func (pc *PackageCreator) addComponent(ctx context.Context, component v1alpha1.Z manifestCount += len(manifest.Files) manifestCount += len(manifest.Kustomizations) } - - spinner := message.NewProgressSpinner("Loading %d K8s manifests", manifestCount) - defer spinner.Stop() - // Iterate over all manifests. for _, manifest := range component.Manifests { for fileIdx, path := range manifest.Files { @@ -458,7 +449,6 @@ func (pc *PackageCreator) addComponent(ctx context.Context, component v1alpha1.Z dst := filepath.Join(componentPaths.Base, rel) // Copy manifests without any processing. - spinner.Updatef("Copying manifest %s", path) if helpers.IsURL(path) { if err := utils.DownloadToFile(ctx, path, dst, component.DeprecatedCosignKeyPath); err != nil { return fmt.Errorf(lang.ErrDownloading, path, err.Error()) @@ -472,8 +462,6 @@ func (pc *PackageCreator) addComponent(ctx context.Context, component v1alpha1.Z for kustomizeIdx, path := range manifest.Kustomizations { // Generate manifests from kustomizations and place in the package. - spinner.Updatef("Building kustomization for %s", path) - kname := fmt.Sprintf("kustomization-%s-%d.yaml", manifest.Name, kustomizeIdx) rel := filepath.Join(layout.ManifestsDir, kname) dst := filepath.Join(componentPaths.Base, rel) @@ -483,14 +471,10 @@ func (pc *PackageCreator) addComponent(ctx context.Context, component v1alpha1.Z } } } - spinner.Success() } // Load all specified git repos. if len(component.Repos) > 0 { - spinner := message.NewProgressSpinner("Loading %d git repos", len(component.Repos)) - defer spinner.Stop() - for _, url := range component.Repos { // Pull all the references if there is no `@` in the string. _, err := git.Clone(ctx, componentPaths.Repos, url, false) @@ -498,7 +482,6 @@ func (pc *PackageCreator) addComponent(ctx context.Context, component v1alpha1.Z return fmt.Errorf("unable to pull git repo %s: %w", url, err) } } - spinner.Success() } if err := actions.Run(ctx, onCreate.Defaults, onCreate.After, nil); err != nil { diff --git a/src/pkg/packager/creator/skeleton.go b/src/pkg/packager/creator/skeleton.go index 8d1acbdf34..e08881abbd 100644 --- a/src/pkg/packager/creator/skeleton.go +++ b/src/pkg/packager/creator/skeleton.go @@ -230,12 +230,7 @@ func (sc *SkeletonCreator) addComponent(component v1alpha1.ZarfComponent, dst *l } if len(component.DataInjections) > 0 { - spinner := message.NewProgressSpinner("Loading data injections") - defer spinner.Stop() - for dataIdx, data := range component.DataInjections { - spinner.Updatef("Copying data injection %s for %s", data.Target.Path, data.Target.Selector) - rel := filepath.Join(layout.DataInjectionsDir, strconv.Itoa(dataIdx), filepath.Base(data.Target.Path)) dst := filepath.Join(componentPaths.Base, rel) @@ -245,8 +240,6 @@ func (sc *SkeletonCreator) addComponent(component v1alpha1.ZarfComponent, dst *l updatedComponent.DataInjections[dataIdx].Source = rel } - - spinner.Success() } if len(component.Manifests) > 0 { @@ -257,10 +250,6 @@ func (sc *SkeletonCreator) addComponent(component v1alpha1.ZarfComponent, dst *l manifestCount += len(manifest.Files) manifestCount += len(manifest.Kustomizations) } - - spinner := message.NewProgressSpinner("Loading %d K8s manifests", manifestCount) - defer spinner.Stop() - // Iterate over all manifests. for manifestIdx, manifest := range component.Manifests { for fileIdx, path := range manifest.Files { @@ -268,8 +257,6 @@ func (sc *SkeletonCreator) addComponent(component v1alpha1.ZarfComponent, dst *l dst := filepath.Join(componentPaths.Base, rel) // Copy manifests without any processing. - spinner.Updatef("Copying manifest %s", path) - if err := helpers.CreatePathAndCopy(path, dst); err != nil { return nil, fmt.Errorf("unable to copy manifest %s: %w", path, err) } @@ -279,8 +266,6 @@ func (sc *SkeletonCreator) addComponent(component v1alpha1.ZarfComponent, dst *l for kustomizeIdx, path := range manifest.Kustomizations { // Generate manifests from kustomizations and place in the package. - spinner.Updatef("Building kustomization for %s", path) - kname := fmt.Sprintf("kustomization-%s-%d.yaml", manifest.Name, kustomizeIdx) rel := filepath.Join(layout.ManifestsDir, kname) dst := filepath.Join(componentPaths.Base, rel) @@ -293,8 +278,6 @@ func (sc *SkeletonCreator) addComponent(component v1alpha1.ZarfComponent, dst *l // remove kustomizations updatedComponent.Manifests[manifestIdx].Kustomizations = nil } - - spinner.Success() } return updatedComponent, nil diff --git a/src/pkg/packager/deploy.go b/src/pkg/packager/deploy.go index 54b74f9727..d6e2efeeb4 100644 --- a/src/pkg/packager/deploy.go +++ b/src/pkg/packager/deploy.go @@ -401,12 +401,9 @@ func (p *Packager) deployComponent(ctx context.Context, component v1alpha1.ZarfC if len(component.HealthChecks) > 0 { healthCheckContext, cancel := context.WithTimeout(ctx, p.cfg.DeployOpts.Timeout) defer cancel() - spinner := message.NewProgressSpinner("Running health checks") - defer spinner.Stop() if err = runHealthChecks(healthCheckContext, p.cluster.Watcher, component.HealthChecks); err != nil { return nil, fmt.Errorf("health checks failed: %w", err) } - spinner.Success() } err = g.Wait() @@ -418,12 +415,7 @@ func (p *Packager) deployComponent(ctx context.Context, component v1alpha1.ZarfC // Move files onto the host of the machine performing the deployment. func (p *Packager) processComponentFiles(component v1alpha1.ZarfComponent, pkgLocation string) error { - spinner := message.NewProgressSpinner("Copying %d files", len(component.Files)) - defer spinner.Stop() - for fileIdx, file := range component.Files { - spinner.Updatef("Loading %s", file.Target) - fileLocation := filepath.Join(pkgLocation, strconv.Itoa(fileIdx), filepath.Base(file.Target)) if helpers.InvalidPath(fileLocation) { fileLocation = filepath.Join(pkgLocation, strconv.Itoa(fileIdx)) @@ -431,7 +423,6 @@ func (p *Packager) processComponentFiles(component v1alpha1.ZarfComponent, pkgLo // If a shasum is specified check it again on deployment as well if file.Shasum != "" { - spinner.Updatef("Validating SHASUM for %s", file.Target) if err := helpers.SHAsMatch(fileLocation, file.Shasum); err != nil { return err } @@ -461,7 +452,6 @@ func (p *Packager) processComponentFiles(component v1alpha1.ZarfComponent, pkgLo // If the file is a text file, template it if isText { - spinner.Updatef("Templating %s", file.Target) if err := p.variableConfig.ReplaceTextTemplate(subFile); err != nil { return fmt.Errorf("unable to template file %s: %w", subFile, err) } @@ -469,7 +459,6 @@ func (p *Packager) processComponentFiles(component v1alpha1.ZarfComponent, pkgLo } // Copy the file to the destination - spinner.Updatef("Saving %s", file.Target) err = helpers.CreatePathAndCopy(fileLocation, file.Target) if err != nil { return fmt.Errorf("unable to copy file %s to %s: %w", fileLocation, file.Target, err) @@ -477,7 +466,6 @@ func (p *Packager) processComponentFiles(component v1alpha1.ZarfComponent, pkgLo // Loop over all symlinks and create them for _, link := range file.Symlinks { - spinner.Updatef("Adding symlink %s->%s", link, file.Target) // Try to remove the filepath if it exists _ = os.RemoveAll(link) // Make sure the parent directory exists @@ -492,18 +480,12 @@ func (p *Packager) processComponentFiles(component v1alpha1.ZarfComponent, pkgLo // Cleanup now to reduce disk pressure _ = os.RemoveAll(fileLocation) } - - spinner.Success() - return nil } // setupState fetches the current ZarfState from the k8s cluster and sets the packager to use it func (p *Packager) setupState(ctx context.Context) error { // If we are touching K8s, make sure we can talk to it once per deployment - spinner := message.NewProgressSpinner("Loading the Zarf State from the Kubernetes cluster") - defer spinner.Stop() - state, err := p.cluster.LoadZarfState(ctx) // We ignore the error if in YOLO mode because Zarf should not be initiated. if err != nil && !p.cfg.Pkg.Metadata.YOLO { @@ -519,7 +501,6 @@ func (p *Packager) setupState(ctx context.Context) error { state.Distro = "YOLO" // Try to create the zarf namespace - spinner.Updatef("Creating the Zarf namespace") zarfNamespace := cluster.NewZarfManagedNamespace(cluster.ZarfNamespaceName) err := func() error { _, err := p.cluster.Clientset.CoreV1().Namespaces().Create(ctx, zarfNamespace, metav1.CreateOptions{}) @@ -547,8 +528,6 @@ func (p *Packager) setupState(ctx context.Context) error { } p.state = state - - spinner.Success() return nil } diff --git a/src/pkg/packager/generate.go b/src/pkg/packager/generate.go index 5d92d56b8d..759979e6f6 100644 --- a/src/pkg/packager/generate.go +++ b/src/pkg/packager/generate.go @@ -23,8 +23,6 @@ import ( // Generate generates a Zarf package definition. func (p *Packager) Generate(ctx context.Context) error { generatedZarfYAMLPath := filepath.Join(p.cfg.GenerateOpts.Output, layout.ZarfYAML) - spinner := message.NewProgressSpinner("Generating package for %q at %s", p.cfg.GenerateOpts.Name, generatedZarfYAMLPath) - if !helpers.InvalidPath(generatedZarfYAMLPath) { prefixed := filepath.Join(p.cfg.GenerateOpts.Output, fmt.Sprintf("%s-%s", p.cfg.GenerateOpts.Name, layout.ZarfYAML)) @@ -94,8 +92,5 @@ func (p *Packager) Generate(ctx context.Context) error { content = strings.Replace(content, "kind:\n", "\nkind:\n", 1) content = strings.Replace(content, "metadata:\n", "\nmetadata:\n", 1) content = strings.Replace(content, "components:\n", "\ncomponents:\n", 1) - - spinner.Successf("Generated package for %q at %s", p.cfg.GenerateOpts.Name, generatedZarfYAMLPath) - return os.WriteFile(generatedZarfYAMLPath, []byte(content), helpers.ReadAllWriteUser) } diff --git a/src/pkg/packager/prepare.go b/src/pkg/packager/prepare.go index 1e43335898..77a295be0d 100644 --- a/src/pkg/packager/prepare.go +++ b/src/pkg/packager/prepare.go @@ -259,10 +259,6 @@ func (p *Packager) findImages(ctx context.Context) (map[string][]string, error) } } } - - spinner := message.NewProgressSpinner("Looking for images in component %q across %d resources", component.Name, len(resources)) - defer spinner.Stop() - for _, resource := range resources { if matchedImages, maybeImages, err = processUnstructuredImages(resource, matchedImages, maybeImages); err != nil { return nil, fmt.Errorf("could not process the Kubernetes resource %s: %w", resource.GetName(), err) @@ -303,27 +299,18 @@ func (p *Packager) findImages(ctx context.Context) (map[string][]string, error) } } } - - spinner.Success() - if !p.cfg.FindImagesOpts.SkipCosign { // Handle cosign artifact lookups if len(imagesMap[component.Name]) > 0 { var cosignArtifactList []string - spinner := message.NewProgressSpinner("Looking up cosign artifacts for discovered images (0/%d)", len(imagesMap[component.Name])) - defer spinner.Stop() - for idx, image := range imagesMap[component.Name] { - spinner.Updatef("Looking up cosign artifacts for discovered images (%d/%d)", idx+1, len(imagesMap[component.Name])) + for _, image := range imagesMap[component.Name] { cosignArtifacts, err := utils.GetCosignArtifacts(image) if err != nil { return nil, fmt.Errorf("could not lookup the cosing artifacts for image %s: %w", image, err) } cosignArtifactList = append(cosignArtifactList, cosignArtifacts...) } - - spinner.Success() - if len(cosignArtifactList) > 0 { imagesMap[component.Name] = append(imagesMap[component.Name], cosignArtifactList...) componentDefinition += fmt.Sprintf(" # Cosign artifacts for images - %s - %s\n", p.cfg.Pkg.Metadata.Name, component.Name) diff --git a/src/pkg/packager/remove.go b/src/pkg/packager/remove.go index 322db5570f..191b2fe830 100644 --- a/src/pkg/packager/remove.go +++ b/src/pkg/packager/remove.go @@ -35,9 +35,6 @@ func (p *Packager) Remove(ctx context.Context) error { if isClusterSource { p.cluster = p.source.(*sources.ClusterSource).Cluster } - spinner := message.NewProgressSpinner("Removing Zarf package %s", p.cfg.PkgOpts.PackageSource) - defer spinner.Stop() - // we do not want to allow removal of signed packages without a signature if there are remove actions // as this is arbitrary code execution from an untrusted source pkg, _, err := p.source.LoadPackageMetadata(ctx, p.layout, false, false) @@ -98,7 +95,7 @@ func (p *Packager) Remove(ctx context.Context) error { continue } - if deployedPackage, err = p.removeComponent(ctx, deployedPackage, dc, spinner); err != nil { + if deployedPackage, err = p.removeComponent(ctx, deployedPackage, dc); err != nil { return fmt.Errorf("unable to remove the component '%s': %w", dc.Name, err) } } @@ -162,7 +159,7 @@ func (p *Packager) updatePackageSecret(ctx context.Context, deployedPackage type return nil } -func (p *Packager) removeComponent(ctx context.Context, deployedPackage *types.DeployedPackage, deployedComponent types.DeployedComponent, spinner *message.Spinner) (*types.DeployedPackage, error) { +func (p *Packager) removeComponent(ctx context.Context, deployedPackage *types.DeployedPackage, deployedComponent types.DeployedComponent) (*types.DeployedPackage, error) { components := deployedPackage.Data.Components c := helpers.Find(components, func(t v1alpha1.ZarfComponent) bool { @@ -182,10 +179,8 @@ func (p *Packager) removeComponent(ctx context.Context, deployedPackage *types.D } for _, chart := range helpers.Reverse(deployedComponent.InstalledCharts) { - spinner.Updatef("Uninstalling chart '%s' from the '%s' component", chart.ChartName, deployedComponent.Name) - helmCfg := helm.NewClusterOnly(p.cfg, p.variableConfig, p.state, p.cluster) - if err := helmCfg.RemoveChart(chart.Namespace, chart.ChartName, spinner); err != nil { + if err := helmCfg.RemoveChart(chart.Namespace, chart.ChartName); err != nil { if !errors.Is(err, driver.ErrReleaseNotFound) { onFailure() return deployedPackage, fmt.Errorf("unable to uninstall the helm chart %s in the namespace %s: %w", diff --git a/src/pkg/packager/sources/oci.go b/src/pkg/packager/sources/oci.go index b86d3797d3..8992e97b8f 100644 --- a/src/pkg/packager/sources/oci.go +++ b/src/pkg/packager/sources/oci.go @@ -70,15 +70,10 @@ func (s *OCISource) LoadPackage(ctx context.Context, dst *layout.PackagePaths, f } if !dst.IsLegacyLayout() { - spinner := message.NewProgressSpinner("Validating pulled layer checksums") - defer spinner.Stop() - if err := ValidatePackageIntegrity(dst, pkg.Metadata.AggregateChecksum, isPartial); err != nil { return pkg, nil, err } - spinner.Success() - if !s.SkipSignatureValidation { if err := ValidatePackageSignature(ctx, dst, s.PublicKeyPath); err != nil { return pkg, nil, err @@ -133,14 +128,9 @@ func (s *OCISource) LoadPackageMetadata(ctx context.Context, dst *layout.Package if !dst.IsLegacyLayout() { if wantSBOM { - spinner := message.NewProgressSpinner("Validating SBOM checksums") - defer spinner.Stop() - if err := ValidatePackageIntegrity(dst, pkg.Metadata.AggregateChecksum, true); err != nil { return pkg, nil, err } - - spinner.Success() } if !s.SkipSignatureValidation { @@ -184,16 +174,10 @@ func (s *OCISource) Collect(ctx context.Context, dir string) (string, error) { if err := utils.ReadYaml(loaded.ZarfYAML, &pkg); err != nil { return "", err } - - spinner := message.NewProgressSpinner("Validating full package checksums") - defer spinner.Stop() - if err := ValidatePackageIntegrity(loaded, pkg.Metadata.AggregateChecksum, false); err != nil { return "", err } - spinner.Success() - // TODO (@Noxsios) remove the suffix check at v1.0.0 isSkeleton := pkg.Build.Architecture == zoci.SkeletonArch || strings.HasSuffix(s.Repo().Reference.Reference, zoci.SkeletonArch) name := fmt.Sprintf("%s%s", NameFromMetadata(&pkg, isSkeleton), PkgSuffix(pkg.Metadata.Uncompressed)) diff --git a/src/pkg/packager/sources/tarball.go b/src/pkg/packager/sources/tarball.go index 5b556f78e1..e699169dd5 100644 --- a/src/pkg/packager/sources/tarball.go +++ b/src/pkg/packager/sources/tarball.go @@ -35,9 +35,6 @@ type TarballSource struct { // LoadPackage loads a package from a tarball. func (s *TarballSource) LoadPackage(ctx context.Context, dst *layout.PackagePaths, filter filters.ComponentFilterStrategy, unarchiveAll bool) (pkg v1alpha1.ZarfPackage, warnings []string, err error) { - spinner := message.NewProgressSpinner("Loading package from %q", s.PackageSource) - defer spinner.Stop() - if s.Shasum != "" { if err := helpers.SHAsMatch(s.PackageSource, s.Shasum); err != nil { return pkg, nil, err @@ -98,15 +95,9 @@ func (s *TarballSource) LoadPackage(ctx context.Context, dst *layout.PackagePath } if !dst.IsLegacyLayout() { - spinner := message.NewProgressSpinner("Validating full package checksums") - defer spinner.Stop() - if err := ValidatePackageIntegrity(dst, pkg.Metadata.AggregateChecksum, false); err != nil { return pkg, nil, err } - - spinner.Success() - if !s.SkipSignatureValidation { if err := ValidatePackageSignature(ctx, dst, s.PublicKeyPath); err != nil { return pkg, nil, err @@ -134,9 +125,6 @@ func (s *TarballSource) LoadPackage(ctx context.Context, dst *layout.PackagePath } } } - - spinner.Success() - return pkg, warnings, nil } @@ -177,14 +165,9 @@ func (s *TarballSource) LoadPackageMetadata(ctx context.Context, dst *layout.Pac if !dst.IsLegacyLayout() { if wantSBOM { - spinner := message.NewProgressSpinner("Validating SBOM checksums") - defer spinner.Stop() - if err := ValidatePackageIntegrity(dst, pkg.Metadata.AggregateChecksum, true); err != nil { return pkg, nil, err } - - spinner.Success() } if !s.SkipSignatureValidation { diff --git a/src/pkg/utils/cosign.go b/src/pkg/utils/cosign.go index fe6ac9279a..bae46adb89 100644 --- a/src/pkg/utils/cosign.go +++ b/src/pkg/utils/cosign.go @@ -48,9 +48,6 @@ func Sget(ctx context.Context, image, key string, out io.Writer) error { // Remove the custom protocol header from the url image = strings.TrimPrefix(image, helpers.SGETURLPrefix) - spinner := message.NewProgressSpinner("Loading signed file %s", image) - defer spinner.Stop() - ref, err := name.ParseReference(image) if err != nil { return err @@ -91,8 +88,6 @@ func Sget(ctx context.Context, image, key string, out io.Writer) error { // 2. We're going to find an x509 certificate on the signature and verify against Fulcio root trust // TODO(nsmith5): Refactor this verification logic to pass back _how_ verification // was performed so we don't need to use this fragile logic here. - fulcioVerified := co.SigVerifier == nil - co.RootCerts, err = fulcio.GetRoots() if err != nil { return fmt.Errorf("getting Fulcio roots: %w", err) @@ -131,10 +126,6 @@ func Sget(ctx context.Context, image, key string, out io.Writer) error { verifyMsg += "PUBLIC KEY. " } - if fulcioVerified { - spinner.Updatef("KEYLESS (OIDC). ") - } - for _, sig := range sp { if cert, err := sig.Cert(); err == nil && cert != nil { message.Debugf("Certificate subject: %s", cert.Subject) @@ -147,8 +138,7 @@ func Sget(ctx context.Context, image, key string, out io.Writer) error { p, err := sig.Payload() if err != nil { - spinner.Errorf(err, "Error getting payload") - return err + return fmt.Errorf("error getting payload: %w", err) } message.Debug(string(p)) } @@ -171,8 +161,6 @@ func Sget(ctx context.Context, image, key string, out io.Writer) error { } _, err = io.Copy(out, rc) - spinner.Successf(verifyMsg) - return err } diff --git a/src/pkg/utils/wait.go b/src/pkg/utils/wait.go index 8fecaf8e10..74ce125be2 100644 --- a/src/pkg/utils/wait.go +++ b/src/pkg/utils/wait.go @@ -9,7 +9,6 @@ import ( "fmt" "net" "net/http" - "path" "strconv" "strings" "time" @@ -53,11 +52,8 @@ func ExecuteWait(waitTimeout, waitNamespace, condition, kind, identifier string, return fmt.Errorf("could not locate the current Zarf binary path: %w", err) } - identifierMsg := identifier - // If the identifier contains an equals sign, convert to a label selector. if strings.ContainsRune(identifier, '=') { - identifierMsg = fmt.Sprintf(" with label `%s`", identifier) identifier = fmt.Sprintf("-l %s", identifier) } @@ -65,23 +61,14 @@ func ExecuteWait(waitTimeout, waitNamespace, condition, kind, identifier string, expired := time.After(timeout) // Set the custom message for optional namespace. - namespaceMsg := "" namespaceFlag := "" if waitNamespace != "" { namespaceFlag = fmt.Sprintf("-n %s", waitNamespace) - namespaceMsg = fmt.Sprintf(" in namespace %s", waitNamespace) } - // Setup the spinner messages. - conditionMsg := fmt.Sprintf("Waiting for %s%s%s to be %s.", kind, identifierMsg, namespaceMsg, condition) - existMsg := fmt.Sprintf("Waiting for %s%s to exist.", path.Join(kind, identifierMsg), namespaceMsg) - spinner := message.NewProgressSpinner(existMsg) - // Get the OS shell to execute commands in shell, shellArgs := exec.GetOSShell(v1alpha1.Shell{Windows: "cmd"}) - defer spinner.Stop() - for { // Delay the check for 1 second time.Sleep(time.Second) @@ -91,7 +78,6 @@ func ExecuteWait(waitTimeout, waitNamespace, condition, kind, identifier string, return errors.New("wait timed out") default: - spinner.Updatef(existMsg) // Check if the resource exists. zarfKubectlGet := fmt.Sprintf("%s tools kubectl get %s %s %s", zarfCommand, namespaceFlag, kind, identifier) stdout, stderr, err := exec.Cmd(shell, append(shellArgs, zarfKubectlGet)...) @@ -109,11 +95,9 @@ func ExecuteWait(waitTimeout, waitNamespace, condition, kind, identifier string, // If only checking for existence, exit here. switch condition { case "", "exist", "exists": - spinner.Success() return nil } - spinner.Updatef(conditionMsg) // Wait for the resource to meet the given condition. zarfKubectlWait := fmt.Sprintf("%s tools kubectl wait %s %s %s --for %s%s --timeout=%s", zarfCommand, namespaceFlag, kind, identifier, waitType, condition, waitTimeout) @@ -125,7 +109,6 @@ func ExecuteWait(waitTimeout, waitNamespace, condition, kind, identifier string, } // And just like that, success! - spinner.Successf(conditionMsg) return nil } } @@ -136,13 +119,11 @@ func waitForNetworkEndpoint(resource, name, condition string, timeout time.Durat // Set the timeout for the wait-for command. expired := time.After(timeout) - // Setup the spinner messages. condition = strings.ToLower(condition) if condition == "" { condition = "success" } - spinner := message.NewProgressSpinner("Waiting for network endpoint %s://%s to respond %s.", resource, name, condition) - defer spinner.Stop() + message.Debug(fmt.Sprintf("Waiting for network endpoint %s://%s to respond %s.", resource, name, condition)) delay := 100 * time.Millisecond @@ -205,7 +186,6 @@ func waitForNetworkEndpoint(resource, name, condition string, timeout time.Durat } // Yay, we made it! - spinner.Success() return nil } } diff --git a/src/pkg/zoci/push.go b/src/pkg/zoci/push.go index 5727849ae2..a89c839a60 100644 --- a/src/pkg/zoci/push.go +++ b/src/pkg/zoci/push.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" - "github.com/defenseunicorns/pkg/helpers/v2" "github.com/defenseunicorns/pkg/oci" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/zarf-dev/zarf/src/api/v1alpha1" @@ -31,14 +30,10 @@ func (r *Remote) PublishPackage(ctx context.Context, pkg *v1alpha1.ZarfPackage, }(src) r.Log().Info(fmt.Sprintf("Publishing package to %s", r.Repo().Reference)) - spinner := message.NewProgressSpinner("") - defer spinner.Stop() // Get all of the layers in the package var descs []ocispec.Descriptor for name, path := range paths.Files() { - spinner.Updatef("Preparing layer %s", helpers.First30Last30(name)) - mediaType := ZarfLayerMediaTypeBlob desc, err := src.Add(ctx, name, mediaType, path) @@ -47,8 +42,6 @@ func (r *Remote) PublishPackage(ctx context.Context, pkg *v1alpha1.ZarfPackage, } descs = append(descs, desc) } - spinner.Successf("Prepared all layers") - copyOpts := r.GetDefaultCopyOpts() copyOpts.Concurrency = concurrency total := oci.SumDescsSize(descs)