Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds client-side support in rover-ctl for retrieving “info” for multiple resources (including the no-args “get all” use case), alongside the underlying handler interface/API updates.
Changes:
- Extends the
ResourceHandlerinterface and generated mocks with a newInfoMany(ctx, names)method. - Implements
InfoManyin the commonBaseHandlerand wiresget-infoto call it when neither--namenor--fileis provided. - Adjusts pre-request patch hooks to be nil-tolerant for rover/apispec handlers.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rover-ctl/test/mocks/mock_ResourceHandler.go | Regenerated mock to include InfoMany and bump mockery version. |
| rover-ctl/test/mocks/mock_ResetSecretHandler.go | Regenerated mock to include InfoMany and bump mockery version. |
| rover-ctl/pkg/handlers/v0/rover.go | Makes PatchRoverRequest nil-safe (important with changed hook execution). |
| rover-ctl/pkg/handlers/v0/apispec.go | Makes PatchApiSpecificationRequest nil-safe (important with changed hook execution). |
| rover-ctl/pkg/handlers/interface.go | Adds InfoMany to the ResourceHandler contract. |
| rover-ctl/pkg/handlers/common/base_handler.go | Adds InfoMany, refactors info request execution, and changes hook execution behavior in SendRequest. |
| rover-ctl/pkg/commands/get-info/cmd.go | Allows running without --name/--file and calls InfoMany to fetch info for all resources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+321
to
+335
| func (h *BaseHandler) InfoMany(ctx context.Context, names []string) (any, error) { | ||
| if !h.SupportsInfo { | ||
| return nil, errors.Errorf("info operation is not supported for %s", h.Resource) | ||
| } | ||
| token := h.Setup(ctx) | ||
| reqUrl := h.GetRequestUrl(token.Group, token.Team, "", "info") | ||
| queryParams := "" | ||
| for _, name := range names { | ||
| if queryParams == "" { | ||
| queryParams = "?name=" + name | ||
| } else { | ||
| queryParams += "&name=" + name | ||
| } | ||
| } | ||
| reqUrl += queryParams |
Comment on lines
+78
to
+112
| if c.Name == "" && c.FilePath == "" { | ||
| return c.getInfoMany() | ||
| } | ||
|
|
||
| c.Logger().V(1).Info("Completed get-info command") | ||
| return nil | ||
| } | ||
|
|
||
| func (c *Command) getInfoMany() error { | ||
| roverHandler, err := handlers.GetHandler(kind, apiVersion) | ||
| if err != nil { | ||
| return errors.Wrap(err, "failed to get rover handler") | ||
| } | ||
|
|
||
| c.Logger().V(1).Info("Getting info for multiple resources") | ||
|
|
||
| infoList, err := roverHandler.InfoMany(c.Cmd.Context(), nil) | ||
| if err != nil { | ||
| return c.HandleError(err, "get info for Rovers") | ||
| } | ||
|
|
||
| prettyString, err := util.FormatOutput(infoList, viper.GetString("output.format")) | ||
| if err != nil { | ||
| return errors.Wrap(err, "failed to format output") | ||
| } | ||
|
|
||
| _, err = c.Cmd.OutOrStdout().Write([]byte(prettyString)) | ||
| if err != nil { | ||
| return errors.Wrap(err, "failed to write output") | ||
| } | ||
|
|
||
| c.Logger().V(1).Info("Successfully retrieved info for multiple resources") | ||
|
|
||
| return nil | ||
| } |
Comment on lines
384
to
388
| func (h *BaseHandler) SendRequest(ctx context.Context, obj types.Object, method, url string) (*http.Response, error) { | ||
|
|
||
| // Run pre-request hooks if object is provided | ||
| if obj != nil { | ||
| if err := h.RunHooks(PreRequestHook, ctx, obj); err != nil { | ||
| return nil, err | ||
| } | ||
| if err := h.RunHooks(PreRequestHook, ctx, obj); err != nil { | ||
| return nil, err | ||
| } |
julius-malcovsky
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.