Skip to content

feat(helm): Add --clp-package-image CLI arg to setup scripts for local image testing (resolves #2019).#2020

Merged
junhaoliao merged 6 commits intoy-scope:mainfrom
junhaoliao:fix-helm-no-image-import
Feb 26, 2026
Merged

feat(helm): Add --clp-package-image CLI arg to setup scripts for local image testing (resolves #2019).#2020
junhaoliao merged 6 commits intoy-scope:mainfrom
junhaoliao:fix-helm-no-image-import

Conversation

@junhaoliao
Copy link
Member

@junhaoliao junhaoliao commented Feb 24, 2026

Description

Add a --clp-package-image CLI argument to the Helm chart setup scripts
(set-up-test.sh, set-up-multi-dedicated-test.sh, set-up-multi-shared-test.sh) so that a
locally-built Docker image can be loaded into the kind cluster and used for deployment.

# Use a local image
bash tools/deployment/package-helm/set-up-test.sh --clp-package-image clp-package:dev-junhao-a6bf

# Use default image (backwards compatible — no args needed)
bash tools/deployment/package-helm/set-up-test.sh

When --clp-package-image is omitted, CLP_PACKAGE_IMAGE is empty, get_image_helm_args returns
nothing, and the scripts behave exactly as before.

Also hardens .set-up-common.sh with two robustness fixes:

  • parse_common_args now validates that --clp-package-image is followed by a non-flag value
    (previously, set -o nounset would crash with a confusing "unbound variable" error, or the next
    flag would be silently consumed as the image name).
  • get_image_helm_args now uses a regex to split repo:tag on the last colon whose right side
    contains no / (previously, ${image%%:*} would mis-parse registry ports like
    localhost:5000/repo:tag, and images without tags were silently accepted).

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

1. Deploy with --clp-package-image

bash tools/deployment/package-helm/set-up-test.sh --clp-package-image clp-package:dev-junhao-a6bf

All 14 pods running with 0 restarts.

2. Deploy without args (backwards compatibility)

bash tools/deployment/package-helm/set-up-test.sh

All 14 pods running with 0 restarts. Default image pulled from
ghcr.io/y-scope/clp/clp-package.

3. Unknown argument

bash tools/deployment/package-helm/set-up-test.sh --bad-arg
# → Unknown argument: --bad-arg (exit 1)

4. Missing value for --clp-package-image

Tests call parse_common_args with the given input and check the exit code and output.

# Input Output Exit
1 --clp-package-image (end of args) Error: '--clp-package-image' requires a value. 1
2 --clp-package-image --other-flag Error: '--clp-package-image' requires a value. 1
3 --clp-package-image clp-package:dev-test CLP_PACKAGE_IMAGE=clp-package:dev-test 0
4 (no args) CLP_PACKAGE_IMAGE= 0
5 --bad-arg Unknown argument: --bad-arg 1
6 --clp-package-image --clp-package-image Error: '--clp-package-image' requires a value. 1

6/6 passed.

5. Image reference parsing

Tests call get_image_helm_args "test-cluster" <input> and check the generated --set flags.

# Input Parsed repo Parsed tag Exit
1 clp-package:dev clp-package dev 0
2 localhost:5000/repo:v1 localhost:5000/repo v1 0
3 registry.io:5000/org/repo:latest registry.io:5000/org/repo latest 0
4 clp-package (no tag) 1
5 localhost:5000/repo (port but no tag) 1
6 ghcr.io/y-scope/clp:v0.3.0-rc1 ghcr.io/y-scope/clp v0.3.0-rc1 0
7 "" (empty / omitted) (no-op) (no-op) 0

7/7 passed.

Summary by CodeRabbit

  • Chores
    • Centralized argument parsing for deployment scripts to support a common image option across test setups.
    • Standardized image handling so test Helm installs can optionally use locally loaded package images via added image-related flags.
    • Updated package Helm chart version to reflect the tooling and deployment invocation changes.

@junhaoliao junhaoliao requested a review from a team as a code owner February 24, 2026 09:59
@junhaoliao junhaoliao requested a review from hoophalab February 24, 2026 09:59
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 934f0e2 and 3cb3170.

📒 Files selected for processing (1)
  • tools/deployment/package-helm/Chart.yaml

Walkthrough

Adds common argument parsing and image-handling helpers for Helm deployments; updates three setup scripts to call the parser and include image-related Helm flags (loads local Docker images into kind clusters and passes repository/tag/pullPolicy to Helm). Chart version bumped.

Changes

Cohort / File(s) Summary
Common helpers
tools/deployment/package-helm/.set-up-common.sh
Added parse_common_args() to parse --clp-package-image and get_image_helm_args(cluster_name, image) to validate image refs, load local images into a kind cluster, and emit Helm --set flags for image repository, tag, and pullPolicy.
Setup scripts
tools/deployment/package-helm/set-up-test.sh, tools/deployment/package-helm/set-up-multi-dedicated-test.sh, tools/deployment/package-helm/set-up-multi-shared-test.sh
Each script now calls parse_common_args "$@" and appends the output of get_image_helm_args(...) to the helm install command (intentional word-splitting; shellcheck disabled for that expansion).
Chart metadata
tools/deployment/package-helm/Chart.yaml
Bumped chart version from 0.1.4-dev.3 to 0.1.4-dev.4.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant CLI as "Setup script (CLI)"
participant Helper as "set-up-common.sh"
participant Kind as "kind cluster"
participant Helm as "Helm"
CLI->>Helper: parse_common_args("$@")
Helper-->>CLI: set CLP_PACKAGE_IMAGE (if provided)
CLI->>Helper: get_image_helm_args(CLUSTER_NAME, CLP_PACKAGE_IMAGE)
Helper->>Kind: load Docker image into cluster (if local)
Helper-->>CLI: emit Helm --set flags (repo, tag, pullPolicy)
CLI->>Helm: helm install ... <expanded --set flags>
Helm->>Kind: deploy charts with provided image settings

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

🚥 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 accurately describes the main change: adding a --clp-package-image CLI argument to Helm setup scripts for local image testing, which is the primary focus of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tools/deployment/package-helm/.set-up-common.sh`:
- Around line 79-86: The parse_common_args function sets CLP_PACKAGE_IMAGE from
the next positional argument but doesn't validate that a value exists; update
the --clp-package-image handling in parse_common_args to check that "$2" is
non-empty and does not start with '-' before assigning to CLP_PACKAGE_IMAGE, and
if the check fails print a clear error like "Missing value for
--clp-package-image" to stderr and exit with a non-zero status so flags like the
next option aren't mis-parsed.
- Around line 67-72: The current split uses the first colon and mis-parses
registry ports and missing tags; replace it with a last-colon split using
repo="${image%:*}" and tag="${image##*:}" and then validate the result: ensure
the image contains a tag by checking tag != repo and that the tag does not
contain a '/' (i.e. the part after the final slash contains the colon),
otherwise exit with an error; update the echo to use the validated ${repo} and
${tag} variables (refs: variables image, repo, tag in the snippet).

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fb76c3 and cbc9e11.

📒 Files selected for processing (4)
  • tools/deployment/package-helm/.set-up-common.sh
  • tools/deployment/package-helm/set-up-multi-dedicated-test.sh
  • tools/deployment/package-helm/set-up-multi-shared-test.sh
  • tools/deployment/package-helm/set-up-test.sh

hoophalab
hoophalab previously approved these changes Feb 26, 2026
Copy link
Contributor

@hoophalab hoophalab left a comment

Choose a reason for hiding this comment

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

I don't use the script but it looks correct.

apiVersion: "v2"
name: "clp"
version: "0.1.4-dev.2"
version: "0.1.4-dev.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably don't need to bump the version?

Copy link
Member Author

Choose a reason for hiding this comment

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

anything inside a Helm chart directory is considered part of the chart, unless we add the files to the https://helm.sh/docs/chart_template_guide/helm_ignore_file/

if the version is not updated, the linter complains:

------------------------------------------------------------------------------------------------------------------------
 Charts to be processed:
------------------------------------------------------------------------------------------------------------------------
 clp => (version: "0.1.4-dev.3", path: "tools/deployment/package-helm")
------------------------------------------------------------------------------------------------------------------------

Linting chart "clp => (version: \"0.1.4-dev.3\", path: \"tools/deployment/package-helm\")"
Checking chart "clp => (version: \"0.1.4-dev.3\", path: \"tools/deployment/package-helm\")" for a version bump...
Old chart version: 0.1.4-dev.3
New chart version: 0.1.4-dev.3

------------------------------------------------------------------------------------------------------------------------
 ✖︎ clp => (version: "0.1.4-dev.3", path: "tools/deployment/package-helm") > chart version not ok. Needs a version bump! 
------------------------------------------------------------------------------------------------------------------------
Error: failed linting charts: failed processing charts
failed linting charts: failed processing charts
task: Failed to run task "lint:helm": exit status 1

@junhaoliao junhaoliao changed the title feat(helm): Add --clp-package-image CLI arg to setup scripts for local image testing (resolves #2019). feat(helm): Add --clp-package-image CLI arg to setup scripts for local image testing (resolves #2019). Feb 26, 2026
@junhaoliao junhaoliao merged commit eaf8c31 into y-scope:main Feb 26, 2026
24 checks passed
@junhaoliao junhaoliao added this to the February 2026 milestone Mar 3, 2026
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