Skip to content

Commit

Permalink
cli: Make explain's invocation fetching usable in workflows (#8217)
Browse files Browse the repository at this point in the history
Make the API target configurable.
  • Loading branch information
fmeum authored Feb 6, 2025
1 parent d7b5ea3 commit 66f1efa
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cli/explain/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var (
oldLog = explainCmd.String("old", "", "Path to a compact execution log or invocation ID of a build to consider as the baseline for the diff.")
newLog = explainCmd.String("new", "", "Path to a compact execution log or invocation ID of a build to compare against the baseline.")
verbose = explainCmd.Bool("verbose", false, "Print more detailed execution information.")
apiTarget = explainCmd.String("target", "", "The API target to use for fetching logs instead of the last --bes_backend.")

profilePaths = make(MapFlag)
)
Expand Down Expand Up @@ -191,10 +192,13 @@ func openLog(pathOrId string) (io.ReadCloser, error) {
return nil, err
}
ctx := metadata.AppendToOutgoingContext(context.Background(), "x-buildbuddy-api-key", apiKey)
backend, err := storage.GetLastBackend()
if err != nil {
log.Debugf("Failed to get last backend: %v", err)
backend = login.DefaultApiTarget
backend := *apiTarget
if backend == "" {
backend, err = storage.GetLastBackend()
if err != nil {
log.Debugf("Failed to get last backend: %v", err)
backend = login.DefaultApiTarget
}
}
conn, err := grpc_client.DialSimple(backend)
if err != nil {
Expand Down

0 comments on commit 66f1efa

Please sign in to comment.