Skip to content

feat(rover-ctl): support for get-info-many cmd#246

Open
ron96g wants to merge 2 commits intomainfrom
feat/rover-ctl-get-info-many
Open

feat(rover-ctl): support for get-info-many cmd#246
ron96g wants to merge 2 commits intomainfrom
feat/rover-ctl-get-info-many

Conversation

@ron96g
Copy link
Member

@ron96g ron96g commented Dec 10, 2025

No description provided.

Copilot AI review requested due to automatic review settings March 16, 2026 13:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ResourceHandler interface and generated mocks with a new InfoMany(ctx, names) method.
  • Implements InfoMany in the common BaseHandler and wires get-info to call it when neither --name nor --file is 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants