feat(api): add qovery api command for authenticated HTTP requests#617
Open
fabienfleureau wants to merge 3 commits intomainfrom
Open
feat(api): add qovery api command for authenticated HTTP requests#617fabienfleureau wants to merge 3 commits intomainfrom
fabienfleureau wants to merge 3 commits intomainfrom
Conversation
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.
There was a problem hiding this comment.
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.goimplementing theapicommand 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.gocovering 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
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.
Summary
qovery api <endpoint>command with--method,--input -(stdin),--field,--header, and--includeflagsvalidateAPIArgs()helper (full-URL rejection, stdin-only--input,--field+--inputmutex, method/header/field format validation, duplicate field key detection) andwriteResponse()helper for clean testable response routing--inputvariant (H3), adds duplicate--fieldkey detection (M4), restores conditional server config inGetQoveryClient(L4), rewrites pure-logic tests to call real helpers (M1/M2/M3), removesbytes.NewReaderimport hack (L1), adds stdout-empty assertion toTestAPIDelete(L2)