Skip to content

chore: templatable release#718

Merged
adityachoudhari26 merged 2 commits intomainfrom
templatable-release
Nov 12, 2025
Merged

chore: templatable release#718
adityachoudhari26 merged 2 commits intomainfrom
templatable-release

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Nov 12, 2025

Summary by CodeRabbit

  • New Features
    • Added templating support for job releases with improved variable conversion and formatting.
    • Enhanced template rendering for job and release data with better data structure handling.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 12, 2025

Walkthrough

Introduces templating support for releases and jobs by creating new TemplatableRelease and TemplatableJobWithRelease types with conversion methods that transform raw job and release data into template-safe formats for rendering in ArgoCD workflows.

Changes

Cohort / File(s) Summary
Type definitions and conversions
apps/workspace-engine/pkg/oapi/job.go
Adds String() method to LiteralValue for JSON-based serialization; introduces TemplatableRelease struct wrapping Release with string-typed variables; implements Release.ToTemplatable() to convert variable types; introduces TemplatableJobWithRelease struct wrapping JobWithRelease with templatable release; implements JobWithRelease.ToTemplatable() with error propagation
Template execution updates
apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go
Calls ToTemplatable() on job with release after retrieval; updates template rendering to use templatable result; adds error handling for conversion failures

Sequence Diagram

sequenceDiagram
    participant argocd as ArgoCD Handler
    participant job as JobWithRelease
    participant release as Release
    participant template as Template Engine

    argocd->>job: ToTemplatable()
    job->>release: ToTemplatable()
    release->>release: Convert LiteralValue<br/>to strings
    release-->>job: TemplatableRelease
    job-->>argocd: TemplatableJobWithRelease
    argocd->>template: Render(templatable)
    template-->>argocd: Rendered output
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Focus areas:
    • Verify LiteralValue.String() correctly deserializes and serializes JSON union types
    • Confirm ToTemplatable() methods properly handle nil checks and error cases
    • Validate template variable substitution works correctly with string-typed variables

Poem

🐰 Hop, hop, huzzah! Templates take flight,
Raw data transforms to a templatable sight,
From unions to strings, conversions take flight,
ArgoCD renders with variables so right! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: templatable release' accurately reflects the main changes: adding templating support for releases and jobs through new TemplatableRelease and TemplatableJobWithRelease structs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 templatable-release

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.

❤️ Share

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

@adityachoudhari26 adityachoudhari26 changed the title Templatable-release chore: templatable release Nov 12, 2025
Copy link
Copy Markdown
Contributor

@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: 0

🧹 Nitpick comments (2)
apps/workspace-engine/pkg/oapi/job.go (2)

18-21: Field shadowing: Variables field shadows embedded Release.Variables.

The Variables map[string]string field shadows the embedded Release.Variables (which is map[string]LiteralValue per the relevant code snippet). This means the embedded Release.Variables becomes inaccessible via the TemplatableRelease type.

If this shadowing is intentional for template rendering (to expose only the string-converted variables), consider adding a comment explaining this design choice. Otherwise, consider renaming to avoid confusion:

 type TemplatableRelease struct {
 	Release
-	Variables map[string]string
+	VariablesString map[string]string
 }

35-38: Field shadowing: Release field shadows embedded JobWithRelease.Release.

Similar to TemplatableRelease, the Release *TemplatableRelease field shadows the embedded JobWithRelease.Release (which is type Release). This makes the original Release inaccessible.

If this shadowing is intentional for template rendering, consider documenting it. Otherwise, rename to avoid confusion:

 type TemplatableJobWithRelease struct {
 	JobWithRelease
-	Release *TemplatableRelease
+	TemplatableRelease *TemplatableRelease
 }
📜 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 885cc77 and 45aac2c.

📒 Files selected for processing (2)
  • apps/workspace-engine/pkg/oapi/job.go (1 hunks)
  • apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
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/argocd.go
  • apps/workspace-engine/pkg/oapi/job.go
🧠 Learnings (1)
📓 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.
🧬 Code graph analysis (1)
apps/workspace-engine/pkg/oapi/job.go (1)
apps/workspace-engine/pkg/oapi/oapi.gen.go (3)
  • LiteralValue (380-382)
  • Release (495-502)
  • JobWithRelease (366-372)
⏰ 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). (5)
  • GitHub Check: Typecheck
  • GitHub Check: workspace-engine-tests
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Lint
  • GitHub Check: tests
🔇 Additional comments (5)
apps/workspace-engine/pkg/oapi/job.go (3)

23-33: LGTM with note on error handling.

The conversion logic is straightforward. Note that since LiteralValue.String() silently returns empty strings on failure, this method never returns an error. If more explicit error handling is added to String(), this method could propagate those errors.


40-50: LGTM!

The conversion logic and error handling are appropriate. The error wrapping provides good context for debugging.


10-16: toString() is defined in the same package; the original concern is incorrect.

The toString() helper function is defined in apps/workspace-engine/pkg/oapi/oapi.go:61 and is accessible to job.go since both files share the same package (oapi). No import is needed. The error handling choice—returning an empty string when unmarshal fails—is a valid design decision for the String() method and is already documented by the function comment at lines 8-9.

Likely an incorrect or invalid review comment.

apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go (2)

70-73: LGTM!

The templatable conversion is properly integrated with appropriate error handling and context.


86-86: LGTM!

Correctly updated to use the templatable variant, which provides string-converted variables for template rendering.

@adityachoudhari26 adityachoudhari26 merged commit 5187952 into main Nov 12, 2025
8 checks passed
@adityachoudhari26 adityachoudhari26 deleted the templatable-release branch November 12, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant