-
Notifications
You must be signed in to change notification settings - Fork 11
chore: init argocd integration #716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds ArgoCD job dispatch support: new ArgoCDDispatcher, job routing for agent type "argo-cd", store helper to fetch job+release context, go.mod dependency updates, and verification schema restructuring in the SDK. Changes
Sequence Diagram(s)sequenceDiagram
participant Router as Dispatcher Router
participant Caller as Job Trigger
participant Store as Store
participant ArgoDisp as ArgoCDDispatcher
participant Tmpl as Template Engine
participant ArgoCD as ArgoCD API
Caller->>Router: DispatchJob(job)
Router->>Router: inspect job.AgentType
alt AgentType == "argo-cd"
Router->>ArgoDisp: DispatchJob(job)
ArgoDisp->>Store: GetWithRelease(job.ID)
Store-->>ArgoDisp: JobWithRelease
ArgoDisp->>ArgoDisp: parseConfig(job)
ArgoDisp->>Tmpl: Render(cfg.Template, job+release data)
Tmpl-->>ArgoDisp: renderedSpec
ArgoDisp->>ArgoCD: NewClient(cfg.serverUrl,cfg.apiKey)
ArgoCD-->>ArgoDisp: client
ArgoDisp->>ArgoCD: UpdateSpec(renderedSpec)
ArgoCD-->>ArgoDisp: success / error
ArgoDisp-->>Router: result
else other agent types
Router-->>Router: existing dispatch flow (e.g., GitHub)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes
Possibly related PRs
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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
apps/workspace-engine/go.sumis excluded by!**/*.sum
📒 Files selected for processing (6)
apps/workspace-engine/go.mod(3 hunks)apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go(1 hunks)apps/workspace-engine/pkg/workspace/jobdispatch/types.go(1 hunks)apps/workspace-engine/pkg/workspace/releasemanager/deployment/jobs/dispatcher.go(1 hunks)apps/workspace-engine/pkg/workspace/store/jobs.go(2 hunks)packages/workspace-engine-sdk/src/schema.ts(6 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
apps/workspace-engine/**/*.go
📄 CodeRabbit inference engine (apps/workspace-engine/CLAUDE.md)
apps/workspace-engine/**/*.go: Do not add extraneous inline comments that state the obvious
Do not add comments that simply restate what the code does
Do not add comments for standard Go patterns (e.g., noting WaitGroup or semaphore usage)
Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods
Files:
apps/workspace-engine/pkg/workspace/jobdispatch/types.goapps/workspace-engine/pkg/workspace/jobdispatch/argocd.goapps/workspace-engine/pkg/workspace/releasemanager/deployment/jobs/dispatcher.goapps/workspace-engine/pkg/workspace/store/jobs.go
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Use TypeScript with explicit types (prefer interfaces for public APIs)
Import styles: Use named imports, group imports by source (std lib > external > internal)
Consistent type imports:import type { Type } from "module"
Prefer async/await over raw promises
Handle errors explicitly (use try/catch and typed error responses)
Files:
packages/workspace-engine-sdk/src/schema.ts
⚙️ CodeRabbit configuration file
**/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.
Files:
packages/workspace-engine-sdk/src/schema.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (CLAUDE.md)
Formatting: Prettier is used with
@ctrlplane/prettier-config
Files:
packages/workspace-engine-sdk/src/schema.ts
🧠 Learnings (6)
📓 Common learnings
Learnt from: adityachoudhari26
Repo: ctrlplanedev/ctrlplane PR: 637
File: packages/events/src/kafka/client.ts:10-16
Timestamp: 2025-08-01T04:41:41.345Z
Learning: User adityachoudhari26 prefers not to add null safety checks for required environment variables when they are guaranteed to be present in their deployment configuration, similar to their preference for simplicity over defensive programming in test code.
Learnt from: adityachoudhari26
Repo: ctrlplanedev/ctrlplane PR: 601
File: e2e/tests/api/policies/retry-policy.spec.ts:23-24
Timestamp: 2025-06-24T23:52:50.732Z
Learning: The user adityachoudhari26 prefers not to add null safety checks or defensive programming in test code, particularly in e2e tests, as they prioritize simplicity and focus on the main functionality being tested rather than comprehensive error handling within the test itself.
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/pkg/model/selector/types.go : Add the new condition type to pkg/model/selector/types.go
Applied to files:
apps/workspace-engine/pkg/workspace/jobdispatch/types.go
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/**/*.go : Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods
Applied to files:
apps/workspace-engine/go.mod
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/**/*.go : Do not add comments for standard Go patterns (e.g., noting WaitGroup or semaphore usage)
Applied to files:
apps/workspace-engine/go.mod
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/**/*.go : Do not add extraneous inline comments that state the obvious
Applied to files:
apps/workspace-engine/go.mod
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/**/*.go : Do not add comments that simply restate what the code does
Applied to files:
apps/workspace-engine/go.mod
🧬 Code graph analysis (4)
apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go (2)
apps/workspace-engine/pkg/oapi/oapi.gen.go (2)
JobAgentConfig(76-76)Id(75-75)apps/workspace-engine/pkg/workspace/store/jobs.go (1)
Jobs(17-20)
apps/workspace-engine/pkg/workspace/releasemanager/deployment/jobs/dispatcher.go (2)
apps/workspace-engine/pkg/workspace/jobdispatch/types.go (1)
JobAgentTypeArgoCD(7-7)apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go (1)
NewArgoCDDispatcher(28-32)
apps/workspace-engine/pkg/workspace/store/jobs.go (5)
apps/workspace-engine/pkg/oapi/oapi.gen.go (8)
JobWithRelease(356-362)ReleaseId(79-79)ReleaseTarget(495-499)Job(310-322)Release(485-492)Environment(222-229)Deployment(146-155)Resource(540-554)apps/workspace-engine/pkg/workspace/store/releases.go (1)
Releases(16-19)apps/workspace-engine/pkg/workspace/store/environments.go (1)
Environments(18-21)apps/workspace-engine/pkg/workspace/store/deployments.go (1)
Deployments(24-27)apps/workspace-engine/pkg/workspace/store/resources.go (1)
Resources(21-24)
packages/workspace-engine-sdk/src/schema.ts (3)
apps/api/src/types/openapi.ts (1)
components(631-1175)apps/web/app/api/openapi.ts (1)
components(283-599)packages/workspace-engine-sdk/src/index.ts (1)
components(7-7)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: workspace-engine-tests
- GitHub Check: build (linux/amd64)
- GitHub Check: build-and-push (linux/amd64)
- GitHub Check: tests
- GitHub Check: build (linux/amd64)
- GitHub Check: Typecheck
- GitHub Check: Lint
| func (d *ArgoCDDispatcher) parseConfig(job *oapi.Job) (argoCDAgentConfig, error) { | ||
| var parsed argoCDAgentConfig | ||
| rawCfg, err := json.Marshal(job.JobAgentConfig) | ||
| if err != nil { | ||
| return argoCDAgentConfig{}, err | ||
| } | ||
| if err := json.Unmarshal(rawCfg, &parsed); err != nil { | ||
| return argoCDAgentConfig{}, err | ||
| } | ||
| if parsed.ServerUrl == "" { | ||
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: serverUrl") | ||
| } | ||
| if parsed.ApiKey == "" { | ||
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: apiKey") | ||
| } | ||
| if parsed.Template == "" { | ||
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: template") | ||
| } | ||
| return parsed, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require the ArgoCD application name.
UpdateSpec sends Name: &cfg.Application; if the config omits application, we end up handing ArgoCD an empty string and the API rejects the request. Please fail fast in parseConfig the same way we already do for serverUrl, apiKey, and template.
if parsed.Template == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: template")
}
+ if parsed.Application == "" {
+ return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: application")
+ }📝 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.
| func (d *ArgoCDDispatcher) parseConfig(job *oapi.Job) (argoCDAgentConfig, error) { | |
| var parsed argoCDAgentConfig | |
| rawCfg, err := json.Marshal(job.JobAgentConfig) | |
| if err != nil { | |
| return argoCDAgentConfig{}, err | |
| } | |
| if err := json.Unmarshal(rawCfg, &parsed); err != nil { | |
| return argoCDAgentConfig{}, err | |
| } | |
| if parsed.ServerUrl == "" { | |
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: serverUrl") | |
| } | |
| if parsed.ApiKey == "" { | |
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: apiKey") | |
| } | |
| if parsed.Template == "" { | |
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: template") | |
| } | |
| return parsed, nil | |
| func (d *ArgoCDDispatcher) parseConfig(job *oapi.Job) (argoCDAgentConfig, error) { | |
| var parsed argoCDAgentConfig | |
| rawCfg, err := json.Marshal(job.JobAgentConfig) | |
| if err != nil { | |
| return argoCDAgentConfig{}, err | |
| } | |
| if err := json.Unmarshal(rawCfg, &parsed); err != nil { | |
| return argoCDAgentConfig{}, err | |
| } | |
| if parsed.ServerUrl == "" { | |
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: serverUrl") | |
| } | |
| if parsed.ApiKey == "" { | |
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: apiKey") | |
| } | |
| if parsed.Template == "" { | |
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: template") | |
| } | |
| if parsed.Application == "" { | |
| return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: application") | |
| } | |
| return parsed, nil | |
| } |
🤖 Prompt for AI Agents
In apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go around lines 34 to
52, parseConfig currently validates serverUrl, apiKey, and template but does not
validate the ArgoCD application name; add a check that parsed.Application is not
empty and return an error such as fmt.Errorf("missing required ArgoCD job
config: application") so we fail fast before calling UpdateSpec (which sets
Name: &cfg.Application) and avoid sending an empty name to the ArgoCD API.
Summary by CodeRabbit
New Features
Chores