From e99611a3f25d3706a77b6ee8fd29c2e9308d76dd Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Fri, 14 Feb 2025 12:36:41 +0000 Subject: [PATCH 1/3] fix: silence exit status errors in plugins --- internal/plugin/plugin.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go index b59f360895..322c839757 100644 --- a/internal/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -152,7 +152,14 @@ func (p *Plugin) Run(cmd *cobra.Command, args []string) error { execCmd.Stdout = cmd.OutOrStdout() execCmd.Stderr = cmd.OutOrStderr() execCmd.Env = os.Environ() - return execCmd.Run() + if err := execCmd.Run(); err != nil { + if exitErr, ok := err.(*exec.ExitError); ok { + cmd.SilenceErrors = true + log.Debugf("Silenced error: %v", exitErr) + } + return err + } + return nil } func (p *Plugin) Uninstall() error { From bce3b849c97a4df505c91014d29ba62e883443c7 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Fri, 14 Feb 2025 12:37:07 +0000 Subject: [PATCH 2/3] fly by --- internal/cli/root/builder.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/cli/root/builder.go b/internal/cli/root/builder.go index a8b56b0648..500edd4a9b 100644 --- a/internal/cli/root/builder.go +++ b/internal/cli/root/builder.go @@ -173,6 +173,7 @@ Use the --help flag with any command for more info on that command.`, return nil }, + // PersistentPostRun only runs if the command is successful PersistentPostRun: func(cmd *cobra.Command, _ []string) { // we don't run the release alert feature on the completion command if strings.HasPrefix(cmd.CommandPath(), fmt.Sprintf("%s %s", atlas, "completion")) { From e6ee505fe59f4cd656f802db78aa72987bc892ed Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Fri, 14 Feb 2025 12:55:22 +0000 Subject: [PATCH 3/3] Lint --- internal/plugin/plugin.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go index 322c839757..d3889c2be6 100644 --- a/internal/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -153,9 +153,10 @@ func (p *Plugin) Run(cmd *cobra.Command, args []string) error { execCmd.Stderr = cmd.OutOrStderr() execCmd.Env = os.Environ() if err := execCmd.Run(); err != nil { - if exitErr, ok := err.(*exec.ExitError); ok { + var exitErr *exec.ExitError + if errors.As(err, &exitErr) { cmd.SilenceErrors = true - log.Debugf("Silenced error: %v", exitErr) + _, _ = log.Debugf("Silenced error: %v", exitErr) } return err }