Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.

feat: support self-hosted instances and GitHub Enterprise#6

Merged
NicolasRitouet merged 4 commits intomainfrom
feat/self-hosting
Feb 3, 2026
Merged

feat: support self-hosted instances and GitHub Enterprise#6
NicolasRitouet merged 4 commits intomainfrom
feat/self-hosting

Conversation

@NicolasRitouet
Copy link
Copy Markdown
Member

@NicolasRitouet NicolasRitouet commented Feb 1, 2026

Summary

  • Add KEYWAY_GITHUB_URL env var for GitHub Enterprise web URL
  • Add KEYWAY_GITHUB_API_URL env var for GitHub Enterprise API URL (auto-derives /api/v3 from base URL)
  • Skip update checks when using non-default API URL (self-hosted)
  • Skip update commands (brew/npm/curl) for self-hosted instances
  • Derive badge and docs URLs from GetDashboardURL() config instead of hardcoding
  • Update readme badge detection to work with any dashboard URL

Test plan

  • KEYWAY_API_URL=https://api.example.com keyway version shows no update notice
  • KEYWAY_GITHUB_URL=https://github.example.com sets GitHub OAuth URLs correctly
  • go test ./internal/... passes
  • Default behavior unchanged when no custom env vars are set

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Environment-driven configuration for GitHub API, dashboard, and docs URLs to support self-hosted deployments.
    • Relative badge links to support custom dashboards.
  • Improvements

    • Update checks and update commands are skipped when using a custom/self-hosted API URL.
    • Help output and badge generation use configurable docs/dashboard URLs.
  • Tests

    • Expanded tests for URL resolution, badge generation, and self-hosted update behavior.

Add KEYWAY_GITHUB_URL and KEYWAY_GITHUB_API_URL env vars for GHE.
Skip update checks and update commands for self-hosted instances.
Derive badge and docs URLs from config instead of hardcoding.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 1, 2026

📝 Walkthrough

Walkthrough

Adds environment-driven URL configuration (GitHub API/base, docs, dashboard) and applies it across the codebase; introduces guards to skip update checks and disable update commands when a custom/self-hosted API URL is configured.

Changes

Cohort / File(s) Summary
Configuration Infrastructure
internal/config/config.go, internal/config/config_test.go
Add defaults and env-driven URL helpers (DefaultGitHubAPIURL, DefaultGitHubBaseURL, DefaultDocsURL, GetGitHubURL, GetGitHubAPIURL, GetGitHubBaseURL, GetDocsURL, IsCustomAPIURL) and tests for URL resolution, trimming, and precedence.
API usage
internal/api/auth.go
Switch GitHub repo API URL construction to use config.GetGitHubAPIURL() instead of a hard-coded https://api.github.com/....
CLI badge and readme
internal/cmd/readme.go, internal/cmd/readme_test.go
Generate badge links using configurable dashboard URL (now checking/producing relative badge paths); update tests to expect relative/generic badge patterns (/badge.svg?repo=, /vaults/...).
CLI root & help
internal/cmd/root.go
Replace hard-coded docs URL with config.GetDocsURL() and add guard to skip showing update notice when no update command is available (self-hosted/no-update path).
Version/update checks
internal/version/github.go, internal/version/version.go, internal/version/version_test.go
Detect custom/self-hosted API via config.IsCustomAPIURL(); skip or error early in FetchLatestVersion, CheckForUpdate, and GetUpdateCommand when self-hosted. Tests added/updated to assert self-hosted behavior.
Tests & manifest
internal/cmd/readme_test.go, internal/version/version_test.go, go.mod
Test updates for relative badge URLs and self-hosted update behavior; small manifest/import changes to accommodate new config usages.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI (version/check)
    participant Config as Config (env funcs)
    participant GitHub as GitHub Releases API
    participant Net as Network/HTTP

    CLI->>Config: GetGitHubAPIURL() / IsCustomAPIURL()
    alt custom/self-hosted detected
        CLI-->>CLI: Skip update check / return no update command
    else default GitHub API
        CLI->>Net: HTTP GET releases (using URL from Config)
        Net->>GitHub: request
        GitHub-->>Net: latest release JSON
        Net-->>CLI: response
        CLI->>CLI: parse version & show update notice
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibbled at configs, neat and spry,
Swapped hardcoded roads for envs on high,
Now badges and docs follow the tune,
Self-hosted pals can skip the commune,
A little hop — the links feel new and spry!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: support self-hosted instances and GitHub Enterprise' accurately summarizes the main change—adding support for self-hosted deployments and GitHub Enterprise by introducing environment-driven URL configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/self-hosting

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 1, 2026

Codecov Report

❌ Patch coverage is 85.29412% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/cmd/root.go 0.00% 3 Missing ⚠️
internal/api/auth.go 0.00% 1 Missing ⚠️
internal/version/github.go 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

NicolasRitouet and others added 2 commits February 2, 2026 22:40
Covers GetGitHubURL, GetGitHubAPIURL, GetGitHubBaseURL, GetDocsURL,
IsCustomAPIURL, and self-hosted guards in CheckForUpdate,
FetchLatestVersion, and GetUpdateCommand.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@internal/config/config.go`:
- Around line 107-111: IsCustomAPIURL incorrectly treats values with trailing
slashes as custom; update the function IsCustomAPIURL to normalize both the
environment value (KEYWAY_API_URL) and DefaultAPIURL before comparing (e.g.,
TrimSpace, remove trailing slashes and optionally lower-case) so
"https://api.example.com/" equals "https://api.example.com"; then compare the
normalized strings and return true only when non-empty and different from the
normalized default.

Comment thread internal/config/config.go
Comment on lines +107 to +111
// IsCustomAPIURL returns true if using a non-default API URL (self-hosted)
func IsCustomAPIURL() bool {
apiURL := os.Getenv("KEYWAY_API_URL")
return apiURL != "" && apiURL != DefaultAPIURL
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Normalize API URLs before comparison to avoid false “custom” detection.

If KEYWAY_API_URL is set to the default with a trailing slash, Line 110 will incorrectly treat it as custom and disable update checks. Normalize both sides before comparing.

🛠️ Proposed fix
 func IsCustomAPIURL() bool {
-	apiURL := os.Getenv("KEYWAY_API_URL")
-	return apiURL != "" && apiURL != DefaultAPIURL
+	apiURL := strings.TrimSuffix(GetAPIURL(), "/")
+	defaultURL := strings.TrimSuffix(DefaultAPIURL, "/")
+	return apiURL != defaultURL
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// IsCustomAPIURL returns true if using a non-default API URL (self-hosted)
func IsCustomAPIURL() bool {
apiURL := os.Getenv("KEYWAY_API_URL")
return apiURL != "" && apiURL != DefaultAPIURL
}
// IsCustomAPIURL returns true if using a non-default API URL (self-hosted)
func IsCustomAPIURL() bool {
apiURL := strings.TrimSuffix(os.Getenv("KEYWAY_API_URL"), "/")
defaultURL := strings.TrimSuffix(DefaultAPIURL, "/")
return apiURL != "" && apiURL != defaultURL
}
🤖 Prompt for AI Agents
In `@internal/config/config.go` around lines 107 - 111, IsCustomAPIURL incorrectly
treats values with trailing slashes as custom; update the function
IsCustomAPIURL to normalize both the environment value (KEYWAY_API_URL) and
DefaultAPIURL before comparing (e.g., TrimSpace, remove trailing slashes and
optionally lower-case) so "https://api.example.com/" equals
"https://api.example.com"; then compare the normalized strings and return true
only when non-empty and different from the normalized default.

@NicolasRitouet NicolasRitouet merged commit fd926af into main Feb 3, 2026
10 checks passed
@NicolasRitouet NicolasRitouet deleted the feat/self-hosting branch February 3, 2026 00:32
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.

1 participant