Skip to content

Commit

Permalink
(fix) tf plan, display error from result stream
Browse files Browse the repository at this point in the history
  • Loading branch information
tphoney committed Oct 3, 2024
1 parent 8b7acf3 commit 401211a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
9 changes: 3 additions & 6 deletions cmd/explore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion cmd/pterm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 1 addition & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cmd/terraform_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 401211a

Please sign in to comment.