Skip to content

93 auto rollout for dev environment #130

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hupling
Copy link
Contributor

@hupling hupling commented May 22, 2025

Description

Short description or comments

Reference

Issues it-at-m/lhm_actions#93

Summary by CodeRabbit

  • New Features
    • Added support for OpenShift ImageStream resources, enabling automated image tag management and rollout triggers when using the imagestream value.
  • Documentation
    • Updated the README with information on the Autorollout feature for OpenShift, including configuration guidance and reference links.
  • Chores
    • Updated Helm chart version to 1.0.4.

@hupling hupling requested review from a team as code owners May 22, 2025 10:25
@hupling hupling linked an issue May 22, 2025 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented May 22, 2025

Walkthrough

The changes introduce OpenShift ImageStream support to the Helm chart for refarch-templates. New helper templates and a resource template enable automated image updates and rollouts when image tags change. Documentation is updated to explain the autorollout feature, and the chart version is incremented to reflect these enhancements.

Changes

File(s) Change Summary
charts/refarch-templates/Chart.yaml Chart version updated from 1.0.1 to 1.0.4.
charts/refarch-templates/README.md Added documentation about the new autorollout feature for OpenShift, including usage instructions and a configuration example.
charts/refarch-templates/templates/_helpers.tpl Added two Helm helper templates: getFullnameImageStream for generating truncated image stream names, and triggerAnnotation for creating OpenShift image trigger annotations.
charts/refarch-templates/templates/deployment.yaml Modified to conditionally add image trigger annotations in deployment metadata when imagestream is set in values.
charts/refarch-templates/templates/imagestream.yml New template file introducing an OpenShift ImageStream resource, generated when imagestream is set. It creates tags for each module, referencing Docker images and enabling automated imports and rollouts.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Helm
    participant Kubernetes
    participant OpenShift

    User->>Helm: Install/upgrade chart with imagestream set
    Helm->>Kubernetes: Deploy resources (Deployment, ImageStream)
    Kubernetes->>OpenShift: Create ImageStream resource
    OpenShift->>OpenShift: Monitor ImageStream tags for updates
    OpenShift->>Kubernetes: Trigger rollout of Deployment if image tag changes
Loading

Poem

🐰
New streams for images, triggers anew,
Rollouts on OpenShift, no more to-do!
Helpers and docs, all clear and bright,
Chart version hops to a greater height.
With every tag, a fresh deploy—
The rabbit leaps with chartful joy!


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment on lines +17 to +24
{{/*
Get the truncated module name for the image stream
*/}}
{{- define "getFullnameImageStream" -}}
{{- $moduleName := $.Values.imagestream }}
{{- printf "%s-%s" $.Release.Name $moduleName | trunc 63 | trimSuffix "-" -}}
{{- end -}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

schade dass ich hier die code kopieren musst und nicht getFullname nutzen könnte. man hätte da einfach zwei Parameter machen können .

@hupling hupling marked this pull request as draft May 22, 2025 10:30
@hupling hupling marked this pull request as ready for review May 22, 2025 10:37
Copy link
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: 1

♻️ Duplicate comments (1)
charts/refarch-templates/templates/_helpers.tpl (1)

17-24: 🧹 Nitpick (assertive)

Consider refactoring to reduce duplication.

The getFullnameImageStream function duplicates logic from the existing getFullname function. It would be better to parameterize the existing function to handle both cases.

Here's how you could refactor to use a single function:

{{/*
Get the truncated module name with the release name #dev-backend
*/}}
{{- define "getFullname" -}}
-{{- $moduleName := .module.name }}
-{{- printf "%s-%s" .dot.Release.Name $moduleName | trunc 63 | trimSuffix "-" -}}
+{{- if kindIs "map" . -}}
+  {{- $moduleName := .module.name }}
+  {{- printf "%s-%s" .dot.Release.Name $moduleName | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+  {{- $moduleName := . }}
+  {{- printf "%s-%s" $.Release.Name $moduleName | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
{{- end -}}

Then use getFullname in place of getFullnameImageStream.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38e0848 and cbb78b4.

📒 Files selected for processing (5)
  • charts/refarch-templates/Chart.yaml (1 hunks)
  • charts/refarch-templates/README.md (1 hunks)
  • charts/refarch-templates/templates/_helpers.tpl (2 hunks)
  • charts/refarch-templates/templates/deployment.yaml (1 hunks)
  • charts/refarch-templates/templates/imagestream.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/refarch-templates/templates/imagestream.yml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


[error] 4-4: too many spaces inside braces

(braces)

🔇 Additional comments (4)
charts/refarch-templates/Chart.yaml (1)

5-5: Version bump looks good.

The chart version has been incremented from 1.0.1 to 1.0.4 to reflect the addition of the new OpenShift ImageStream integration feature.

charts/refarch-templates/templates/deployment.yaml (1)

9-12: Good implementation of conditional image trigger annotations.

The annotations are correctly added only when the $.Values.imagestream value is set, which keeps this OpenShift-specific feature optional. The template properly uses the new triggerAnnotation helper to generate the correct annotation format.

charts/refarch-templates/README.md (1)

328-336: Clear documentation for the new autorollout feature.

The documentation clearly explains the purpose of the feature (development environments), how it works (automatic rollouts when image tags change), and includes a link to OpenShift documentation for further details. The example configuration is simple and easy to understand.

charts/refarch-templates/templates/_helpers.tpl (1)

56-63: Well-implemented image trigger annotation template.

The triggerAnnotation helper correctly generates the OpenShift-specific annotation format required to trigger automatic deployments when the ImageStream tag changes. The parameter handling and JSON formatting are properly implemented.

Copy link
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: 5

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbb78b4 and 3436a86.

📒 Files selected for processing (1)
  • charts/refarch-templates/templates/imagestream.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/refarch-templates/templates/imagestream.yml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


[error] 5-5: too many spaces inside braces

(braces)

🔇 Additional comments (1)
charts/refarch-templates/templates/imagestream.yml (1)

16-20: Import and reference policy settings look good
The scheduled: true importPolicy and Source referencePolicy align with the autorollout behavior for development. No changes needed here.

Comment on lines +4 to +5
metadata:
name: {{ include "getFullnameImageStream" $}}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Refine helper template spacing in metadata
Although {{ include "getFullnameImageStream" $}} works, it triggers a “braces” warning in YAMLLint. For better readability and to satisfy linters, consider adding a space before the closing braces:

name: {{ include "getFullnameImageStream" $ }}
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 5-5: too many spaces inside braces

(braces)

🤖 Prompt for AI Agents
In charts/refarch-templates/templates/imagestream.yml at lines 4 to 5, the Helm
template expression for the name field lacks a space before the closing braces,
causing a YAMLLint "braces" warning. To fix this, add a space before the closing
braces in the include statement, changing {{ include "getFullnameImageStream"
$}} to {{ include "getFullnameImageStream" $ }} for proper spacing and lint
compliance.

Comment on lines +6 to +9
spec:
lookupPolicy:
local: false
tags:
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Guard spec.tags against empty or undefined modules
If .Values.modules is unset or empty, you’ll emit a tags: block with no entries, potentially invalidating the ImageStream. Wrap this section in an if or default modules to [] in your values.yaml:

spec:
  lookupPolicy:
    local: false
  {{- if .Values.modules }}
  tags:
  {{- range .Values.modules }}
  …
  {{- end }}
  {{- end }}
🤖 Prompt for AI Agents
In charts/refarch-templates/templates/imagestream.yml around lines 6 to 9, the
spec.tags block is rendered even when .Values.modules is empty or undefined,
which can produce invalid YAML. To fix this, wrap the tags section and its
contents inside an if conditional that checks if .Values.modules exists and is
non-empty, or alternatively set a default empty array for modules in
values.yaml. This prevents emitting an empty tags block and ensures valid
ImageStream manifests.

Comment on lines +1 to +3
{{- if $.Values.imagestream }}
kind: ImageStream
apiVersion: image.openshift.io/v1
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Manage YAMLLint false positives & adjust field ordering
The leading {{- if $.Values.imagestream }} is valid Helm syntax but YAMLLint will flag the trim directive as a syntax error. You can safely ignore these false positives by configuring your .yamllint to skip templates under charts/**/templates.
Also, while not functionally required, swapping the order to have apiVersion before kind improves consistency with other Kubernetes resources.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

🤖 Prompt for AI Agents
In charts/refarch-templates/templates/imagestream.yml around lines 1 to 3,
YAMLLint flags the Helm trim directive in the conditional as a syntax error,
which is a false positive; configure your .yamllint file to exclude linting for
templates under charts/**/templates to ignore these safely. Additionally,
reorder the fields so that apiVersion appears before kind to align with
Kubernetes resource conventions, improving consistency.

Comment on lines +11 to +12
- name: {{.name}}
annotations: null
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Use an empty mapping for annotations
Rendering annotations: null produces a YAML null. If you intend no annotations, prefer an empty map:

-      annotations: null
+      annotations: {}
📝 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.

Suggested change
- name: {{.name}}
annotations: null
- name: {{.name}}
annotations: {}
🤖 Prompt for AI Agents
In charts/refarch-templates/templates/imagestream.yml at lines 11 to 12, replace
the line setting annotations to null with an empty mapping to avoid rendering a
YAML null. Change the annotations field from 'annotations: null' to
'annotations: {}' to represent no annotations correctly as an empty map.

Comment on lines +10 to +15
{{- range .Values.modules }}
- name: {{.name}}
annotations: null
from:
kind: DockerImage
name: {{.image.repository}}:{{.image.tag}}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix indentation of range block under tags:
The {{- range .Values.modules }} and its list items must be indented to align under tags:. For example:

  tags:
+  {{- range .Values.modules }}
    - name: {{ .name }}
      annotations: null
      from:
        kind: DockerImage
        name: {{ .image.repository }}:{{ .image.tag }}
  {{- end }}

This alignment ensures valid YAML after rendering.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In charts/refarch-templates/templates/imagestream.yml around lines 10 to 15, the
{{- range .Values.modules }} block and its nested list items are not properly
indented under the tags: key. Adjust the indentation so that the range block and
its contents align correctly beneath tags:, ensuring the rendered YAML structure
is valid and properly nested.

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.

auto rollout for dev environment
1 participant