Skip to content

Flexible Preloading#12

Merged
CodeByNikolas merged 1 commit intomainfrom
feat/flexible-preloading
Mar 24, 2026
Merged

Flexible Preloading#12
CodeByNikolas merged 1 commit intomainfrom
feat/flexible-preloading

Conversation

@lukaskratzel
Copy link
Copy Markdown

@lukaskratzel lukaskratzel commented Mar 23, 2026

Summary by CodeRabbit

  • New Features
    • Expanded image preloading configuration to support custom command and argument specifications for container images alongside simple image string format.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

The Helm chart's image preloading configuration now supports both simple image reference strings and map objects with optional custom command overrides. The template logic conditionally derives image references and applies custom commands or default shell-based echo behavior based on entry structure.

Changes

Cohort / File(s) Summary
Template Logic Enhancement
charts/theia-cloud/templates/image-preloading.yaml
Modified iteration variable from $image to $entry and introduced conditional logic to handle both simple image strings and map objects. Template now derives $imageRef via tpl function and conditionally applies custom command/args from map entries or defaults to sh -c with echo behavior. Enables distroless container support.
Documentation Update
charts/theia-cloud/values.yaml
Updated preloading.images configuration documentation to describe new format supporting either simple image reference strings or map objects with optional image, args, and command/args fields. Clarified default /bin/sh behavior and custom command usage patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Images now flexible, simple or complex,
Maps and plain strings in template context,
Custom commands dance for distroless grace,
Our preloading logic finds its perfect place! ✨

🚥 Pre-merge checks | ✅ 3
✅ 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 'Flexible Preloading' directly reflects the main change: making the preloading.images configuration more flexible by supporting both simple strings and map objects with custom commands.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/flexible-preloading

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.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
charts/theia-cloud/templates/image-preloading.yaml (1)

49-56: Consider adding validation for map entries without image field.

If a user provides a map entry without the image key (e.g., { args: ["--version"] }), $imageRef will be empty, resulting in an invalid container spec. Consider adding a validation check or at least a required call to fail with a clear error message.

💡 Suggested validation
      {{- if $isMap }}
+       {{- if not $entry.image }}
+         {{- fail (printf "preloading.images[%d]: map entry must have 'image' field" $index) }}
+       {{- end }}
        {{- $imageRef = tpl ($entry.image | toString) $ }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/theia-cloud/templates/image-preloading.yaml` around lines 49 - 56,
When iterating $images in image-preloading.yaml, map entries ($entry where
$isMap is true) that lack an image key leave $imageRef empty and produce invalid
container specs; update the template around the $imageRef assignment to validate
and fail fast: when $isMap is true, check that $entry.image exists and call
required (or fail) with a clear message like "image is required for preloading
entries" before calling tpl, and similarly ensure non-map entries are non-empty
before tpl so $imageRef is never empty; reference the symbols $images, $entry,
$imageRef, $isMap, kindIs, and tpl when adding this validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/theia-cloud/templates/image-preloading.yaml`:
- Around line 68-71: The template currently treats a present but null args value
as valid because hasKey $entry "args" will be true even when $entry.args is nil;
change the logic around hasKey/$customArgs so you only set $hasArgsKey and
$customArgs when $entry.args is non-nil (e.g., test $entry.args or use an if ne
$entry.args nil) and otherwise leave $customArgs unset or set to an empty list;
update any subsequent toYaml usage to rely on $hasArgsKey or the non-nil
$customArgs so you never call toYaml on a nil value (inspect the same block
using hasKey, $entry, $hasArgsKey, and $customArgs to apply the guard).

---

Nitpick comments:
In `@charts/theia-cloud/templates/image-preloading.yaml`:
- Around line 49-56: When iterating $images in image-preloading.yaml, map
entries ($entry where $isMap is true) that lack an image key leave $imageRef
empty and produce invalid container specs; update the template around the
$imageRef assignment to validate and fail fast: when $isMap is true, check that
$entry.image exists and call required (or fail) with a clear message like "image
is required for preloading entries" before calling tpl, and similarly ensure
non-map entries are non-empty before tpl so $imageRef is never empty; reference
the symbols $images, $entry, $imageRef, $isMap, kindIs, and tpl when adding this
validation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 687ad457-82f8-4817-b1e2-0634e22d295a

📥 Commits

Reviewing files that changed from the base of the PR and between 757d45f and a7695b0.

📒 Files selected for processing (2)
  • charts/theia-cloud/templates/image-preloading.yaml
  • charts/theia-cloud/values.yaml

Comment on lines +68 to +71
{{- if hasKey $entry "args" }}
{{- $hasArgsKey = true }}
{{- $customArgs = $entry.args }}
{{- end }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Edge case: args: null would produce invalid YAML.

If a user explicitly sets args: ~ (null) in a map entry, hasKey returns true but $customArgs becomes nil. The toYaml call would render null, producing invalid YAML. This is a minor edge case but could cause confusing errors.

🛡️ Optional guard against nil args
        {{- if hasKey $entry "args" }}
          {{- $hasArgsKey = true }}
-         {{- $customArgs = $entry.args }}
+         {{- $customArgs = $entry.args | default list }}
        {{- end }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/theia-cloud/templates/image-preloading.yaml` around lines 68 - 71, The
template currently treats a present but null args value as valid because hasKey
$entry "args" will be true even when $entry.args is nil; change the logic around
hasKey/$customArgs so you only set $hasArgsKey and $customArgs when $entry.args
is non-nil (e.g., test $entry.args or use an if ne $entry.args nil) and
otherwise leave $customArgs unset or set to an empty list; update any subsequent
toYaml usage to rely on $hasArgsKey or the non-nil $customArgs so you never call
toYaml on a nil value (inspect the same block using hasKey, $entry, $hasArgsKey,
and $customArgs to apply the guard).

Copy link
Copy Markdown

@CodeByNikolas CodeByNikolas left a comment

Choose a reason for hiding this comment

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

a valuable change thank you

@CodeByNikolas CodeByNikolas merged commit 1cae3fe into main Mar 24, 2026
7 of 8 checks passed
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.

2 participants