Skip to content

feat: integrated secret during the ci build-time#111

Merged
nitisht merged 4 commits into
parseablehq:mainfrom
pratik50:feat/secret-inject
Jul 20, 2026
Merged

feat: integrated secret during the ci build-time#111
nitisht merged 4 commits into
parseablehq:mainfrom
pratik50:feat/secret-inject

Conversation

@pratik50

@pratik50 pratik50 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Integrate secret during the binary-build time from github secret with test-cases and readme update

Summary by CodeRabbit

  • New Features
    • Added --output/-o to cloud profile add (default text, or structured json with sanitized profile details).
  • Bug Fixes
    • Standardized orchestrator authentication across device login, API-key validation (now uses x-api-key), and cloud session refresh; added clearer failures when the orchestrator URL is missing.
  • Documentation
    • Updated cloud authentication and automation guidance for both terminal and JSON/agent-friendly usage.
  • Tests
    • Expanded cloud CLI and HTTP tests for JSON output, credential redaction, header validation, and error handling.
  • Chores
    • Release validation/build now requires and injects the orchestrator auth token in addition to the URL.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f061a72f-2224-41c8-87b2-44a3ca664cd3

📥 Commits

Reviewing files that changed from the base of the PR and between 46be624 and 078b673.

📒 Files selected for processing (1)
  • README.md

📝 Walkthrough

Walkthrough

Cloud 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.

Changes

Cloud authentication and profile management

Layer / File(s) Summary
Release credential injection
pkg/config/defaults.go, buildscripts/gen-ldflags.go, .goreleaser.yml, .github/workflows/release.yaml
Defines linker-injected orchestrator credentials and supplies both values during release validation and GoReleaser execution.
Orchestrator request authentication
pkg/http/http.go, pkg/http/refresh.go, pkg/http/http_test.go
Adds bearer-token request authentication and applies it to cloud session refresh requests with corresponding tests.
Cloud profile validation and JSON output
cmd/cloud.go, cmd/login.go, cmd/cloud_profile_test.go
Adds --output/-o, sanitized JSON profile results, orchestrator URL checks, context-aware validation, authenticated device requests, and x-api-key flow coverage.
Cloud authentication and automation documentation
README.md
Documents profile-based authentication, cloud and self-hosted login, structured output, and automation guidance.

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
Loading

Possibly related PRs

  • parseablehq/pb#110: Also updates cloud profile API-key login and validation behavior in cmd/cloud.go.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is related to the main change: CI build-time integration of a secret for release binaries.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@pratik50 pratik50 self-assigned this Jul 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/cloud.go (1)

504-518: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider adding context support to validateCloudAPIKey.

This function was significantly modified in this PR (new endpoint, new auth, new headers) but still uses http.NewRequest without context, while doCloudOAuthTokenRequest and doCloudJSON both use http.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 RunE would need to pass cmd.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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f7218e and 94aed6e.

📒 Files selected for processing (10)
  • .github/workflows/release.yaml
  • .goreleaser.yml
  • README.md
  • buildscripts/gen-ldflags.go
  • cmd/cloud.go
  • cmd/cloud_profile_test.go
  • pkg/config/defaults.go
  • pkg/http/http.go
  • pkg/http/http_test.go
  • pkg/http/refresh.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 05bac1c0-c35b-40ee-a028-7faea1e67df8

📥 Commits

Reviewing files that changed from the base of the PR and between dddef58 and 46be624.

📒 Files selected for processing (1)
  • README.md

Comment thread README.md Outdated
@nitisht
nitisht merged commit 9486fd1 into parseablehq:main Jul 20, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants