Add script to start proxy locally#36
Conversation
WalkthroughAdds local development support: new start-proxy.sh script, README instructions, .gitignore entry for the built binary, environment-driven API server URL, and APP_ENV-based TLS toggle; handlers now read KUBE_API_SERVER and return JSON 500 on API connection failures. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant Script as start-proxy.sh
participant App as kubevirt-apiserver-proxy
participant Kube as Kubernetes API
Dev->>Script: run start-proxy.sh
Script->>Script: export APP_ENV=dev\nextract KUBE_API_SERVER from oc config
Script->>Script: go build
Script->>App: execute binary
App->>App: read APP_ENV and KUBE_API_SERVER
alt APP_ENV == "dev"
App->>App: start HTTP server (no TLS)
else
App->>App: start HTTPS server (TLS)
end
Dev->>App: HTTP request
App->>Kube: forward request to API_SERVER_URL
alt success
Kube-->>App: response
App-->>Dev: proxied response
else failure
App-->>Dev: HTTP 500 JSON error
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
🔇 Additional comments (3)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.gitignore(1 hunks)README.md(1 hunks)handlers/handlers.go(2 hunks)main.go(2 hunks)start-proxy.sh(1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
start-proxy.sh
[warning] 7-7: Declare and assign separately to avoid masking return values.
(SC2155)
🔇 Additional comments (6)
.gitignore (1)
11-12: LGTM!Good practice to ignore the built binary. The placement and comment are appropriate.
README.md (1)
7-11: LGTM!Clear and concise documentation for the local development workflow.
main.go (1)
29-34: Environment-based TLS toggle looks good.The dev/prod separation using APP_ENV is appropriate for local development. In production mode, ensure the certificate files exist at
./cert/tls.crtand./cert/tls.key(which aligns with the volume mount configuration shown in the README).handlers/handlers.go (3)
19-24: LGTM!The
getEnvOrDefaulthelper is simple, clear, and follows standard patterns for environment variable handling.
15-15: Good improvement for flexibility.Using environment-based configuration for the API server URL makes the proxy more flexible for different deployment scenarios. The default
kubernetes.default.svcis appropriate for in-cluster usage.
74-75: Improved error handling.Returning a JSON error response in addition to logging provides better feedback to API clients when the connection to the Kubernetes API server fails.
1e40577 to
c479067
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: adamviktora, metalice The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Adds
start-proxy.shscript to run proxy locallySummary by CodeRabbit
New Features
Bug Fixes
Documentation