Skip to content

fix: correct label helper and annotation references in job/cronjob te…#100

Open
fernandoataoldotcom wants to merge 8 commits into
mainfrom
fix/label-and-annotation-inconsistencies
Open

fix: correct label helper and annotation references in job/cronjob te…#100
fernandoataoldotcom wants to merge 8 commits into
mainfrom
fix/label-and-annotation-inconsistencies

Conversation

@fernandoataoldotcom

@fernandoataoldotcom fernandoataoldotcom commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

…mplates

  • job.yaml: use chart.commonLabels instead of chart.appLabels to match all other templates (adds managed-by, helm.sh/chart, teamowner labels)
  • job.yaml: fix annotation reference from $.Values.cronJob.annotations to $.Values.job.annotations
  • cronjob.yaml: use merge (deepCopy $) to build an isolated context for suffixName, avoiding mutation of the root context $ which could leak into templates rendered afterward

…mplates

- job.yaml: use chart.commonLabels instead of chart.appLabels to match
  all other templates (adds managed-by, helm.sh/chart, teamowner labels)
- job.yaml: fix annotation reference from $.Values.cronJob.annotations
  to $.Values.job.annotations
- cronjob.yaml: replace merge with set for suffixName context to fix
  label rendering when multiple cronjobs are defined

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Helm chart templates to standardize label/annotation helpers and to correct context handling for Job/CronJob resources so they render consistent metadata across templates.

Changes:

  • job.yaml: switch from chart.appLabels to chart.commonLabels and fix annotations lookup to Values.job.annotations.
  • cronjob.yaml: change how suffixName is passed into chart.commonLabels to address label rendering with multiple cronjobs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
templates/job.yaml Uses chart.commonLabels for Jobs and corrects annotation source to Values.job.annotations.
templates/cronjob.yaml Adjusts suffixName context passed to chart.commonLabels for CronJobs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread templates/cronjob.yaml Outdated
Comment thread templates/job.yaml Outdated
Comment thread templates/cronjob.yaml Outdated
Comment thread templates/job.yaml
…t mutation

Replace `set $ "suffixName"` with `merge (deepCopy $) (dict "suffixName" $name)`
in both cronjob.yaml and job.yaml. `set` mutates the root context ($) in place,
causing the last job/cronjob suffixName to leak into templates rendered afterward
(e.g., Deployment, Service), incorrectly appending the suffix to their
app.kubernetes.io/name label.
Assert that chart.commonLabels renders managed-by and helm.sh/chart
in Job metadata, and that job.annotations (not cronJob.annotations)
appears in Job metadata.annotations.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/job_test.yaml Outdated
Comment thread templates/cronjob.yaml
Comment thread templates/cronjob.yaml
Align with the assertion style used throughout the rest of the test
suite. isNotEmpty may not be supported by all helm-unittest versions.
Render two cronjobs and assert each document gets a distinct
app.kubernetes.io/name label, covering the deepCopy fix that
prevents suffixName from leaking between loop iterations.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/cronjob_test.yaml Outdated
Map iteration order is non-deterministic, so documentIndex-based
assertions can be flaky. Use documentSelector to match documents
by metadata.name before asserting labels.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread templates/job.yaml
Comment thread templates/cronjob.yaml
After replacing set $ with deepCopy, the pod template's .Root no
longer carries suffixName, causing pod app.kubernetes.io/name labels
to lose the job suffix. Pass $newContext (which includes suffixName)
as Root so Job/CronJob metadata and pod labels stay consistent.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants