From 401211a702fb3fb41ea9dac7df0722d8b02427b1 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Tue, 1 Oct 2024 18:49:57 +0100 Subject: [PATCH] (fix) tf plan, display error from result stream --- cmd/explore.go | 9 +++------ cmd/pterm.go | 2 +- cmd/root.go | 5 +---- cmd/terraform_plan.go | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/cmd/explore.go b/cmd/explore.go index 10a1dde2..e98525a3 100644 --- a/cmd/explore.go +++ b/cmd/explore.go @@ -48,7 +48,7 @@ func StartLocalSources(ctx context.Context, oi sdp.OvermindInstance, token *oaut }() stdlibSpinner, _ := pterm.DefaultSpinner.WithWriter(multi.NewWriter()).Start("Starting stdlib source engine") awsSpinner, _ := pterm.DefaultSpinner.WithWriter(multi.NewWriter()).Start("Starting AWS source engine") - statusArea := pterm.DefaultBasicText.WithStyle(pterm.NewStyle(pterm.FgLightCyan)).WithWriter(multi.NewWriter()) + statusArea := pterm.DefaultParagraph.WithWriter(multi.NewWriter()) natsOptions := natsOptions(ctx, oi, token) heartbeatOptions := heartbeatOptions(oi, token) @@ -174,7 +174,7 @@ func Explore(cmd *cobra.Command, args []string) error { defer func() { _, _ = multi.Stop() }() - ctx, oi, token, err := login(ctx, cmd, []string{"request:receive"}, multi.NewWriter()) + ctx, oi, token, err := login(ctx, cmd, []string{"request:receive", "api:read"}, multi.NewWriter()) _, _ = multi.Stop() if err != nil { return err @@ -187,10 +187,7 @@ func Explore(cmd *cobra.Command, args []string) error { defer cleanup() exploreURL := fmt.Sprintf("%v/explore", oi.FrontendUrl) - err = browser.OpenURL(exploreURL) - if err != nil { - pterm.Error.Printf("Unable to open browser: %v", err) - } + _ = browser.OpenURL(exploreURL) // ignore error, we can't do anything about it pterm.Println() pterm.Println(fmt.Sprintf("Explore your infrastructure graph at %s", exploreURL)) diff --git a/cmd/pterm.go b/cmd/pterm.go index 1435f55c..497280be 100644 --- a/cmd/pterm.go +++ b/cmd/pterm.go @@ -69,7 +69,7 @@ func StartSources(ctx context.Context, cmd *cobra.Command, args []string) (conte _, _ = multi.Stop() }() - ctx, oi, token, err := login(ctx, cmd, []string{"explore:read", "changes:write", "config:write", "request:receive"}, multi.NewWriter()) + ctx, oi, token, err := login(ctx, cmd, []string{"explore:read", "changes:write", "config:write", "request:receive", "api:read", "sources:read"}, multi.NewWriter()) if err != nil { return ctx, sdp.OvermindInstance{}, nil, nil, err } diff --git a/cmd/root.go b/cmd/root.go index 127c3147..caaae35d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -489,10 +489,7 @@ func getOauthToken(ctx context.Context, oi sdp.OvermindInstance, requiredScopes var token *oauth2.Token - err = browser.OpenURL(deviceCode.VerificationURI) - if err != nil { - pterm.Error.Printf("Unable to open browser: %v", err) - } + _ = browser.OpenURL(deviceCode.VerificationURI) // nolint:errcheck // we don't care if the browser fails to open pterm.Print( markdownToString(MAX_TERMINAL_WIDTH, fmt.Sprintf( beginAuthMessage, diff --git a/cmd/terraform_plan.go b/cmd/terraform_plan.go index fa522309..84c79cba 100644 --- a/cmd/terraform_plan.go +++ b/cmd/terraform_plan.go @@ -329,7 +329,7 @@ func TerraformPlanImpl(ctx context.Context, cmd *cobra.Command, oi sdp.OvermindI blastRadiusSpinner.UpdateText(fmt.Sprintf("Calculating Blast Radius: %v", snapshotDetail(stateLabel, blastRadiusItems, blastRadiusEdges))) } if resultStream.Err() != nil { - blastRadiusSpinner.Fail(fmt.Sprintf("Calculating Blast Radius: error streaming results: %v", err)) + blastRadiusSpinner.Fail(fmt.Sprintf("Calculating Blast Radius: error streaming results: %v", resultStream.Err())) return nil } blastRadiusSpinner.Success("Calculating Blast Radius: done")