Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new cronjob primitive to the Operator Component Framework, extending the primitives layer with first-class support for reconciling Kubernetes batch/v1 CronJobs (builder/resource, mutator + editors, flavors), plus accompanying docs and an example.
Changes:
- Introduces
pkg/primitives/cronjobwith builder/resource lifecycle integration, mutation planning/apply, flavors, and default handlers. - Adds new mutation editors for
CronJobSpecandJobSpecunderpkg/mutation/editors. - Adds docs and an end-to-end example; also updates repo lint config and a few existing test files.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/primitives/cronjob/resource.go | CronJob primitive resource wrapper around generic IntegrationResource |
| pkg/primitives/cronjob/mutator.go | Plan/apply mutator for CronJob + containers/initContainers editing |
| pkg/primitives/cronjob/handlers.go | Default operational + suspension handlers for CronJob |
| pkg/primitives/cronjob/flavors.go | Field-application flavors for labels/annotations + pod template metadata |
| pkg/primitives/cronjob/builder.go | Fluent builder wiring defaults, mutations, flavors, handlers, extractors |
| pkg/primitives/cronjob/mutator_test.go | Extensive mutator behavior tests (ordering, selectors, nil-safety, etc.) |
| pkg/primitives/cronjob/handlers_test.go | Tests for default operational/suspension handlers |
| pkg/primitives/cronjob/flavors_test.go | Tests for flavor behavior and ordering |
| pkg/primitives/cronjob/builder_test.go | Builder validation and option wiring tests |
| pkg/mutation/editors/cronjobspec.go | New typed editor for batchv1.CronJobSpec |
| pkg/mutation/editors/cronjobspec_test.go | Tests for CronJobSpecEditor methods |
| pkg/mutation/editors/jobspec.go | New typed editor for batchv1.JobSpec |
| pkg/mutation/editors/jobspec_test.go | Tests for JobSpecEditor methods |
| pkg/component/suite_test.go | Removes revive nolint from dot-imports |
| pkg/component/component_test.go | Removes revive nolint from dot-imports |
| internal/generic/resource_task_test.go | Removes dupl nolint marker |
| internal/generic/resource_integration_test.go | Removes dupl nolint marker |
| examples/cronjob-primitive/resources/cronjob.go | Example resource factory assembling CronJob primitive with features/flavors |
| examples/cronjob-primitive/main.go | Runnable fake-client reconciliation demo exercising feature/suspend flows |
| examples/cronjob-primitive/features/mutations.go | Example feature mutations using the cronjob mutator/editors |
| examples/cronjob-primitive/app/controller.go | Example controller wiring a CronJob-backed component |
| examples/cronjob-primitive/README.md | Documentation for running and understanding the example |
| docs/primitives/cronjob.md | New primitive documentation for CronJob |
| .golangci.yml | Updates golangci-lint v2 config layout, enabled linters, and exclusions |
Owner
Author
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
<!-- claude-review-cycle --> |
JobSpecEditor provides typed methods for Job spec fields (completions, parallelism, backoff limit, etc.). CronJobSpecEditor provides typed methods for CronJob spec fields (schedule, concurrency policy, time zone, etc.). The suspend field is intentionally excluded from CronJobSpecEditor as it is managed by the framework's suspension system. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements the CronJob primitive using IntegrationBuilder with Operational and Suspendable concepts. Key behaviors: - Operational status based on LastScheduleTime (Pending vs Operational) - Suspension via spec.suspend=true (DeleteOnSuspend=false) - Full pod-template mutation pipeline: metadata, cronjob spec, job spec, pod template metadata, pod spec, containers, init containers - Flavors for preserving labels, annotations, and pod template metadata Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Documents the Integration lifecycle, mutation pipeline ordering, editors (CronJobSpec, JobSpec, PodSpec, Container, ObjectMeta), operational status semantics, and suspension behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Demonstrates building a CronJob resource with version-gated mutations, tracing/metrics features, field preservation flavors, suspension via spec.suspend, and data extraction. Uses the shared ExampleApp CRD and a fake client for standalone execution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix container field paths in docs mutation ordering table to use full CronJob path (spec.jobTemplate.spec.template.spec.containers) - Use correct OperationPending status name in docs to match framework constant - Explicitly convert LastScheduleTime to UTC before formatting timestamp - Fix range variable address-of footgun in mutator_test.go findEnv helper Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix capabilities table in cronjob.md to use `OperationPending` instead of `Pending` to match the actual status value from the concepts package. Add resource_test.go for the cronjob primitive covering Identity, Object, Mutate, feature ordering, custom field applicator, ConvergingStatus, DeleteOnSuspend, Suspend, SuspensionStatus, and ExtractData. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
563d078 to
5058194
Compare
Owner
Author
|
approved |
The FeatureMutator interface in internal/generic used an unexported beginFeature() method, which meant primitive mutators in external packages (cronjob, deployment, configmap) could never satisfy the interface. The type assertion in ApplyMutations always returned false, so feature boundaries were silently skipped for all primitives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored:
|
Rephrase the note about spec.suspend to acknowledge that Raw() can be used to set it, while still recommending the framework's suspend mechanism. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored: <!-- claude-review-cycle --> |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…semantics - Add require.NoError checks for Builder.Build() in all three TestMutate_OrderingAndFlavors subtests to fail clearly on builder validation errors instead of risking nil dereferences. - Add comment in ApplyMutations explaining why BeginFeature is not called before the first mutation (newMutator creates the initial scope). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
Claude Review Cycle 1 CompleteAddressed:
Intentionally ignored: <!-- claude-review-cycle --> |
Apply the same pattern from deployment/configmap: NewMutator no longer creates an initial feature plan. BeginFeature must be called before registering mutations. Also fix mutate_helper to call BeginFeature before every mutation (including the first). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tive Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align with framework-wide SSA refactor: remove DefaultFieldApplicator, WithCustomFieldApplicator, WithFieldApplicationFlavor, flavors.go, and update tests to use Object() output instead of empty structs in Mutate(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Implements the
cronjobKubernetes resource primitive following the pattern established by the existingConfigMapandDeploymentprimitives.Summary
cronjobprimitive package underpkg/primitives/cronjob/Checklist