Skip to content

feat(api): add qovery api command for authenticated HTTP requests#617

Open
fabienfleureau wants to merge 3 commits intomainfrom
qovery-api
Open

feat(api): add qovery api command for authenticated HTTP requests#617
fabienfleureau wants to merge 3 commits intomainfrom
qovery-api

Conversation

@fabienfleureau
Copy link
Collaborator

Summary

  • Implements qovery api <endpoint> command with --method, --input - (stdin), --field, --header, and --include flags
  • Extracts validateAPIArgs() helper (full-URL rejection, stdin-only --input, --field+--input mutex, method/header/field format validation, duplicate field key detection) and writeResponse() helper for clean testable response routing
  • Fixes code review findings: removes file-path --input variant (H3), adds duplicate --field key detection (M4), restores conditional server config in GetQoveryClient (L4), rewrites pure-logic tests to call real helpers (M1/M2/M3), removes bytes.NewReader import hack (L1), adds stdout-empty assertion to TestAPIDelete (L2)

Implements the `qovery api <endpoint>` command with --method, --input,
--field, --header, and --include flags. Adds validateAPIArgs() and
writeResponse() helpers for testable pure-logic validation and response
routing. Fixes code review findings: removes file-path --input variant
(stdin-only), adds duplicate --field key detection, restores conditional
server config in GetQoveryClient, and rewrites tests to exercise real
code paths.
Copilot AI review requested due to automatic review settings March 11, 2026 10:36
Copy link

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 a new qovery api <endpoint> CLI command to perform authenticated HTTP requests against the Qovery API, including support for stdin body input, JSON body construction via --field, custom headers, and optional inclusion of response headers in output.

Changes:

  • Introduces cmd/api.go implementing the api command plus helpers for argument validation, placeholder substitution, body coercion, and response output routing.
  • Adds utils.GetAPIBaseURL() and reuses it in the Qovery client configuration for consistent base URL handling (including trimming trailing slashes).
  • Adds a comprehensive test suite in cmd/api_test.go covering core request/response behaviors and helper functions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
utils/qovery.go Adds GetAPIBaseURL() and uses it in GetQoveryClient server configuration.
cmd/api.go New api command implementation with validation, request building, and response writing logic.
cmd/api_test.go New tests for api command scenarios and helper functions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Suppress unchecked return values on fmt.Fprintf/Fprintln (writeResponse),
defer resp.Body.Close, and pipe Close calls in tests. Replace
strings.Index(...) == -1 with !strings.Contains per staticcheck S1003.
- Fix stale writeContextFile doc comment (no return value)
- Validate HTTP header name is a non-empty RFC 7230 token (rejects ': value')
- Reject empty field keys ('=value') in --field validation
- writeResponse routes both headers and body to the same stream (stdout
  for 2xx, stderr for non-2xx) so --include is consistent on error responses
- Replace TestAPIPathNormalisation inline logic with integration test via runAPI
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.

2 participants