feat: deploy github webhook server in dev environment#863
Open
feat: deploy github webhook server in dev environment#863
Conversation
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/cli/install_test.go">
<violation number="1" location="internal/cli/install_test.go:713">
P2: `TestInstallCommand_WebhookResourceRequestsFlag` is a false-positive test: it searches global dry-run output for `cpu: 10m`/`memory: 64Mi`, which can come from non-webhook manifests, so webhook request regressions may go undetected.</violation>
</file>
<file name="internal/cli/install.go">
<violation number="1" location="internal/cli/install.go:74">
P2: `--webhook-resource-requests` is accepted without `--github-webhook-secret-name`, but in that case the webhook server is not enabled and the flag has no effect. Add validation to reject this unsupported flag combination.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Comment on lines
+713
to
+717
| for _, expected := range []string{"cpu: 10m", "memory: 64Mi"} { | ||
| if !strings.Contains(output, expected) { | ||
| t.Errorf("expected %q in output when --webhook-resource-requests is set", expected) | ||
| } | ||
| } |
There was a problem hiding this comment.
P2: TestInstallCommand_WebhookResourceRequestsFlag is a false-positive test: it searches global dry-run output for cpu: 10m/memory: 64Mi, which can come from non-webhook manifests, so webhook request regressions may go undetected.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/cli/install_test.go, line 713:
<comment>`TestInstallCommand_WebhookResourceRequestsFlag` is a false-positive test: it searches global dry-run output for `cpu: 10m`/`memory: 64Mi`, which can come from non-webhook manifests, so webhook request regressions may go undetected.</comment>
<file context>
@@ -678,6 +678,60 @@ func TestInstallCommand_NoControllerResourcesByDefault(t *testing.T) {
+ }
+ })
+
+ for _, expected := range []string{"cpu: 10m", "memory: 64Mi"} {
+ if !strings.Contains(output, expected) {
+ t.Errorf("expected %q in output when --webhook-resource-requests is set", expected)
</file context>
Suggested change
| for _, expected := range []string{"cpu: 10m", "memory: 64Mi"} { | |
| if !strings.Contains(output, expected) { | |
| t.Errorf("expected %q in output when --webhook-resource-requests is set", expected) | |
| } | |
| } | |
| webhookDeployment := extractYAMLDocument(t, []byte(output), "kind: Deployment\nmetadata:\n name: kelos-webhook-github") | |
| for _, expected := range []string{"cpu: 10m", "memory: 64Mi"} { | |
| if !strings.Contains(webhookDeployment, expected) { | |
| t.Errorf("expected %q in webhook deployment when --webhook-resource-requests is set", expected) | |
| } | |
| } |
| controllerResourceLimits, | ||
| ghproxyAllowedUpstreams, | ||
| )) | ||
| if githubWebhookSecretName != "" || webhookResourceRequests != "" { |
There was a problem hiding this comment.
P2: --webhook-resource-requests is accepted without --github-webhook-secret-name, but in that case the webhook server is not enabled and the flag has no effect. Add validation to reject this unsupported flag combination.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/cli/install.go, line 74:
<comment>`--webhook-resource-requests` is accepted without `--github-webhook-secret-name`, but in that case the webhook server is not enabled and the flag has no effect. Add validation to reject this unsupported flag combination.</comment>
<file context>
@@ -69,6 +71,23 @@ func newInstallCommand(cfg *ClientConfig) *cobra.Command {
controllerResourceLimits,
ghproxyAllowedUpstreams,
))
+ if githubWebhookSecretName != "" || webhookResourceRequests != "" {
+ webhookVals := map[string]interface{}{}
+ if githubWebhookSecretName != "" {
</file context>
Suggested change
| if githubWebhookSecretName != "" || webhookResourceRequests != "" { | |
| if webhookResourceRequests != "" && githubWebhookSecretName == "" { | |
| return fmt.Errorf("--webhook-resource-requests requires --github-webhook-secret-name") | |
| } | |
| if githubWebhookSecretName != "" || webhookResourceRequests != "" { |
Add --github-webhook-secret-name and --webhook-resource-requests flags to the install CLI, and wire them into the deploy-dev workflow along with rollout management and PodMonitoring for the webhook server.
ExtractGitHubWorkItem conditionally omitted Number, Body, URL, and Branch from the template vars map when they were zero/empty. This caused template execution to fail with "map has no entry for key" when a promptTemplate referenced those variables unconditionally. Also convert kelos-reviewer to webhook-based TaskSpawner.
dd4b158 to
c27ee1e
Compare
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.
What type of PR is this?
/kind feature
What this PR does / why we need it:
Deploys the GitHub webhook server in the dev environment and converts the kelos-reviewer TaskSpawner from polling-based to webhook-based.
--github-webhook-secret-nameand--webhook-resource-requestsflags tokelos installExtractGitHubWorkItemto always includeNumber,Body,URL, andBranchin template vars (avoids "map has no entry for key" errors)kelos-reviewerfromgithubPullRequests(polling) togithubWebhook(issue_commentevents)Which issue(s) this PR is related to:
N/A
Special notes for your reviewer:
kelos-systemnamespace and requires a secret namedgithub-webhook-secretwith aWEBHOOK_SECRETkeyissue_commentevents with/kelos reviewin the body, filtered by author (gjkim42,kelos-bot[bot])Does this PR introduce a user-facing change?