feat: integrated secret during the ci build-time#111
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughCloud authentication now uses release-injected orchestrator credentials. Cloud profile creation supports text or sanitized JSON output, API-key validation uses authenticated requests, refresh flows include orchestrator authentication, and README guidance covers profiles and automation. ChangesCloud authentication and profile management
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant CloudProfileAddCmd
participant OrchestratorAuth
participant OrchestratorAPI
participant ConfigStore
CloudProfileAddCmd->>OrchestratorAuth: add bearer token
CloudProfileAddCmd->>OrchestratorAPI: validate x-api-key
OrchestratorAPI-->>CloudProfileAddCmd: return workspace data
CloudProfileAddCmd->>ConfigStore: save profile and workspace ID
CloudProfileAddCmd-->>CloudProfileAddCmd: emit text or JSON output
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/cloud.go (1)
504-518: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winConsider adding context support to
validateCloudAPIKey.This function was significantly modified in this PR (new endpoint, new auth, new headers) but still uses
http.NewRequestwithout context, whiledoCloudOAuthTokenRequestanddoCloudJSONboth usehttp.NewRequestWithContext. Without context, a user pressing Ctrl+C during API key validation won't cancel the in-flight request — it will block until the 30s client timeout.♻️ Proposed refactor to add context support
-func validateCloudAPIKey(orchestratorURL, apiKey string) (*cloudAPIKeyValidationResponse, error) { +func validateCloudAPIKey(ctx context.Context, orchestratorURL, apiKey string) (*cloudAPIKeyValidationResponse, error) { if strings.TrimSpace(orchestratorURL) == "" { return nil, errors.New("cloud orchestrator URL is not configured") } endpoint, err := url.JoinPath(orchestratorURL, "api/v1/cli/apikey/validate") if err != nil { return nil, fmt.Errorf("invalid orchestrator URL: %w", err) } - req, err := http.NewRequest(http.MethodGet, endpoint, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil) if err != nil { return nil, err }The caller in
RunEwould need to passcmd.Context()(or derive one).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/cloud.go` around lines 504 - 518, Update validateCloudAPIKey and its RunE caller to accept and propagate cmd.Context(), replacing http.NewRequest with http.NewRequestWithContext so Ctrl+C cancels API-key validation consistently with doCloudOAuthTokenRequest and doCloudJSON.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/cloud.go`:
- Around line 504-518: Update validateCloudAPIKey and its RunE caller to accept
and propagate cmd.Context(), replacing http.NewRequest with
http.NewRequestWithContext so Ctrl+C cancels API-key validation consistently
with doCloudOAuthTokenRequest and doCloudJSON.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 68b49d2e-e0d1-47f8-aea0-f61076c10a4a
📒 Files selected for processing (10)
.github/workflows/release.yaml.goreleaser.ymlREADME.mdbuildscripts/gen-ldflags.gocmd/cloud.gocmd/cloud_profile_test.gopkg/config/defaults.gopkg/http/http.gopkg/http/http_test.gopkg/http/refresh.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 355-365: Update the non-interactive setup examples in the API-key
documentation to avoid passing secrets through the --api-key argument. Use and
document the existing or newly supported secret-safe mechanism, such as
environment-variable or stdin-based loading, for both self-hosted and Parseable
Cloud profile commands while preserving the profile examples.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Integrate secret during the binary-build time from github secret with test-cases and readme update
Summary by CodeRabbit
--output/-otocloud profile add(defaulttext, or structuredjsonwith sanitized profile details).x-api-key), and cloud session refresh; added clearer failures when the orchestrator URL is missing.