Skip to content

Comments

refact(refarch-templates)!: modules as dict instead of array#238

Open
simonhir wants to merge 6 commits intomainfrom
refact/refarch-templates-modules-as-dict
Open

refact(refarch-templates)!: modules as dict instead of array#238
simonhir wants to merge 6 commits intomainfrom
refact/refarch-templates-modules-as-dict

Conversation

@simonhir
Copy link
Member

@simonhir simonhir commented Jan 28, 2026

Description

  • refarch-templates: refactor modules to dict instead of array
    • allows using multiple value files (e.g. base values.yaml and additional values per env)

⚠️ Blocked by #239

  • Communicate upcoming breaking change
  • Document migration in README

Summary by CodeRabbit

  • Chores

    • Bumped chart version to 2.0.0.
  • Documentation

    • Updated docs and examples to show module configuration as a mapping/dictionary instead of a list; corrected wording and examples.
  • Refactor

    • Templates and example values now iterate modules by name (key) and expose module names for resource naming and labels — update your values to the mapping format.

@simonhir simonhir requested review from a team as code owners January 28, 2026 06:46
@simonhir simonhir requested a review from langehm January 28, 2026 06:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Converts Helm chart modules from a list to a mapping (module keys as names), updates templates to iterate key/value pairs and propagate moduleName into template data (affecting naming/labels and image/container references), and bumps chart version from 1.1.7 to 2.0.0.

Changes

Cohort / File(s) Summary
Chart metadata & docs
charts/refarch-templates/Chart.yaml, charts/refarch-templates/README.md
Chart version bumped to 2.0.0. README revised to show mapping-style modules (dict) and updated examples/wording.
Values & examples
charts/refarch-templates/values.yaml, charts/refarch-templates/values-example.yaml, charts/refarch-templates/ci/test-values.yaml
modules changed from list to map (modules: {}); examples and test-values refactored to keyed per-module mappings; images, volumes, and volumeMounts reorganized under per-module keys.
Template helpers
charts/refarch-templates/templates/_helpers.tpl
Helpers switched to use moduleName (.moduleName / $moduleName) instead of .module.name when generating fullnames, labels, and selectors.
Module-iterating templates
charts/refarch-templates/templates/config-map-application-yml.yaml, charts/refarch-templates/templates/deployment.yaml, charts/refarch-templates/templates/hpa.yaml, charts/refarch-templates/templates/image-stream.yml, charts/refarch-templates/templates/ingress.yaml, charts/refarch-templates/templates/service-monitor.yaml, charts/refarch-templates/templates/service.yaml, charts/refarch-templates/templates/tests/test-connection.yaml
All module loops changed to {{- range $moduleName, $module := .Values.modules -}}; local data dicts now include "moduleName"; references updated to use $moduleName for names and $module for properties (including image fields).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I nibbled YAML, swapped lists for keys,
I hopped through templates with swift, small ease.
Each module now has a name to show,
The chart bumped to two-oh-oh—ready to go!
I celebrate with carrots and YAML breeze.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: refactoring modules from an array/list to a dictionary/mapping structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 refact/refarch-templates-modules-as-dict

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.

@simonhir simonhir requested a review from devtobi January 28, 2026 06:46
@simonhir simonhir changed the title refact(refarch-templates): modules as dict instead of array refact(refarch-templates)!: modules as dict instead of array Jan 28, 2026
@simonhir simonhir self-assigned this Jan 28, 2026
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: 8

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
charts/refarch-templates/templates/deployment.yaml (1)

9-12: Critical: .name reference causes pipeline failure.

This is the root cause of the pipeline error metadata.name 'test-release-%!s(int=0)'. After refactoring to dict-based modules, .name no longer resolves to the module name—the name is now the dictionary key ($moduleName). The .name reference evaluates to nil or an unexpected type, causing the Go template format error.

Proposed fix
   {{- if $.Values.imageStream.enabled }}
   annotations:
-    {{- include "triggerAnnotation" (list .name $.Values.imageStream.name $.Release.Name ) | trim | nindent 4 }}
+    {{- include "triggerAnnotation" (list $moduleName $.Values.imageStream.name $.Release.Name ) | trim | nindent 4 }}
   {{- end }}
🤖 Fix all issues with AI agents
In `@charts/refarch-templates/README.md`:
- Around line 127-131: Add a blank line between the "Example:" line and the
fenced code block that begins with "```yaml" to satisfy MD031; specifically,
update the README's example so the line containing "Example:" is followed by an
empty line before the "```yaml" fence (the fenced code block that contains
"modules:"), ensuring the fence is surrounded by blank lines.
- Around line 123-125: Fix the grammar/typos in the module description
sentences: change "Each module consist of individuell Kubernetes resources (e.g.
Deployment, Service, HPA, ...)." to "Each module consists of individual
Kubernetes resources (e.g. Deployment, Service, HPA, ...)." and ensure
surrounding sentences remain: "Modules consist of individual components in a
dict." and "All configuration options need to be inside a `module`." so replace
"consist"→"consists" and "individuell"→"individual" in the README text.

In `@charts/refarch-templates/templates/deployment.yaml`:
- Around line 2-3: The Helm template uses {{- range $moduleName, $module :=
.Values.modules -}} and {{ $data := dict "dot" $dot "module" $module
"moduleName" $moduleName }} without whitespace trimming; update the template to
add left/right trimming (use {{- and -}}) around both the range and the dict
lines so that the range invocation and the $data definition use trimmed braces
(affecting the range, dict, $data, $moduleName, and $module tokens) to eliminate
YAMLlint brace spacing warnings.

In `@charts/refarch-templates/templates/hpa.yaml`:
- Around line 2-3: Update the Helm template tags to use whitespace trimming so
YAML linting doesn't complain: change the opening and closing action delimiters
around the range and dict lines—specifically the lines using {{- range
$moduleName, $module := .Values.modules -}} and {{ $data := dict "dot" $dot
"module" $module "moduleName" $moduleName }} —to include leading/trailing
hyphens (i.e., use {{- and -}}) so whitespace is trimmed consistently around the
$moduleName, $module and $data declarations.
- Line 17: HPA's scaleTargetRef.name is using {{ $moduleName }} but the
Deployment metadata.name is generated with the helper include "getFullname"
$data, so update the HPA template to reference the same helper; replace the
scaleTargetRef.name value (currently using $moduleName) with the corresponding
include call (the same expression used in the Deployment: include "getFullname"
$data) so both resources share an identical name generation source (ensure you
pass the same $data/context used by the Deployment).

In `@charts/refarch-templates/templates/ingress.yaml`:
- Around line 2-3: The dict assignment for $data is missing whitespace trimming
and leaves extra spaces in rendered YAML; update the directive that defines
$data (the line using $data := dict "dot" $dot "module" $module "moduleName"
$moduleName) to use Helm/Go template whitespace control by changing the
delimiters to {{- ... -}} so it matches the surrounding directives (e.g., the
{{- range $moduleName, $module := .Values.modules -}} block).

In `@charts/refarch-templates/templates/service.yaml`:
- Around line 2-3: The template uses standard Go template delimiters without
whitespace trimming which triggers YAMLlint brace spacing warnings; update the
two template actions by adding trimming markers so the range and dict
invocations use {{- range $moduleName, $module := .Values.modules -}} and {{-
$data := dict "dot" $dot "module" $module "moduleName" $moduleName -}} (i.e.,
replace the opening '{{' with '{{-' and the closing '}}' with '-}}' for the
range and dict expressions in service.yaml) to ensure consistent whitespace
trimming.

In `@charts/refarch-templates/templates/tests/test-connection.yaml`:
- Around line 2-3: The dict assignment for $data lacks whitespace trimming and
should use the same trimmed directive style as the range; update the dict
declaration (the template expression that sets $data with dict "dot" $dot
"module" $module "moduleName" $moduleName) to use {{- and -}} (i.e. change {{
$data := ... }} to a trimmed form) so it matches the existing {{- range ... -}}
usage and satisfies YAMLlint.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
charts/refarch-templates/ci/test-values.yaml (1)

16-27: Update commented backend example to dict format.

The commented backend block still uses the old list-based - name structure. This is now inconsistent with the dict-based modules layout and can mislead future edits. Please rewrite it to the new modules.backend: style (or remove the block).

✅ Suggested update
-#  - name: backend
-#    image:
-#      registry: ghcr.io
-#      repository: it-at-m/refarch-templates/refarch-backend
-#      tag: "latest"
-#    applicationYML:
-#      spring:
-#        profiles:
-#          active: "no-security"
-#    service:
-#      http: true
+#  backend:
+#    image:
+#      registry: ghcr.io
+#      repository: it-at-m/refarch-templates/refarch-backend
+#      tag: "latest"
+#    applicationYML:
+#      spring:
+#        profiles:
+#          active: "no-security"
+#    service:
+#      http: true

@hupling
Copy link
Contributor

hupling commented Jan 29, 2026

@simonhir an sich ein gute Idee, aber ich weiß nicht, ob wir jetzt schon einen Breaking Change veröffentlichen sollten oder warten

it-at-m/lhm_actions#106 das wurde auch abgelehnt

@simonhir
Copy link
Member Author

@hupling in my opinion as long as correct versioning is used a breaking change is always ok and should be done especially for best practices and in this case the behavior is different than helm create charts and therefore it should also be done as fast as possible (besides it annoyed me 😅).
I understand that it could be overwhelming but on the other side if you collect major changes these changes could be much more complicated than multiple smaller once. I think a middle way might be the best, but that's only relevant once we notice that there are many breaking changes in a specific project.

Copy link
Contributor

@langehm langehm left a comment

Choose a reason for hiding this comment

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

Looks good to me otherwise - this is definitely a breaking change. As @simonhir mentioned we should not accumulate these.

@hupling
Copy link
Contributor

hupling commented Feb 4, 2026

Meinung von @ejcsid können wir das am Montag besprechen wie vorgehen, z.B.: wir erstellen ein Major-Release für den Change. Brauchen wir 2 Branches (also für 1.x und 2.x)? Pflegen wir Features nur noch in 2.x, machen aber Versions- und Security-Updates auch in 1.x?

{{- if $module.env }}
env:
{{- toYaml $module.env | nindent 12 }}
{{- end }}
Copy link
Member Author

Choose a reason for hiding this comment

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

Also allow env as map?

{{- end }}
{{- if (or $module.volumes $module.applicationYML) }}
volumes:
{{- if $module.volumes }}
Copy link
Member Author

Choose a reason for hiding this comment

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

Also allow volumes as map?

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.

3 participants