Skip to content

Update build script to use versions from pom if not specified. - #55

Merged
chandrams merged 2 commits into
kruize:mvp_demofrom
kusumachalasani:image_tag
Nov 6, 2026
Merged

chandrams merged 2 commits into
kruize:mvp_demofrom
kusumachalasani:image_tag

Conversation

@kusumachalasani

@kusumachalasani kusumachalasani commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Update build script to use versions from pom if not specified.
And correct the image registry.

Summary by Sourcery

Derive default image tags from the project version and correct the default image repository.

Bug Fixes:

  • Correct the default container image registry repository from optimizer to kruize-optimizer.

Enhancements:

  • Use the Maven project version from pom.xml as the default image tag when no tag is provided, with an error when the version cannot be resolved.

Signed-off-by: kusuma chalasani <kchalasani@ibm.com>
@kusumachalasani kusumachalasani added this to the Release 0.0.2 milestone Nov 6, 2026
@kusumachalasani kusumachalasani self-assigned this Nov 6, 2026
@kusumachalasani kusumachalasani added the bug Something isn't working label Nov 6, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The build script now preserves explicitly supplied tags but otherwise reads the project version from pom.xml, errors when that lookup fails, and uses the corrected default Quay image repository.

Flow diagram for resolving the container image name

flowchart TD
    A[Start build_and_push.sh] --> B{IMAGE_NAME supplied?}
    B -->|Yes| C[Use supplied IMAGE_NAME]
    B -->|No| D{IMAGE_TAG supplied?}
    D -->|Yes| E[Use supplied IMAGE_TAG]
    D -->|No| F[Read project version from pom.xml]
    F --> G{Version found?}
    G -->|No| H[Print error and exit]
    G -->|Yes| E
    E --> I[Build quay.io/kruize/kruize-optimizer:TAG]
    C --> J[Build and push IMAGE_NAME]
    I --> J
Loading

File-Level Changes

Change Details Files
Derive the default image tag from the project version when no tag is supplied, while retaining explicit tag overrides.
  • Initialize the tag as unset instead of using a hardcoded default.
  • Extract the first matching project version from pom.xml when needed.
  • Fail with an error if the version cannot be read.
  • Update usage text to document the new default behavior.
build_and_push.sh
Correct the default container image registry repository path.
  • Change the default image name from quay.io/kruize/optimizer to quay.io/kruize/kruize-optimizer.
build_and_push.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="build_and_push.sh" line_range="79" />
<code_context>
 if [ -z "$IMAGE_NAME" ]; then
-    IMAGE_NAME="quay.io/kruize/optimizer:${IMAGE_TAG}"
+    if [ -z "$IMAGE_TAG" ]; then
+        IMAGE_TAG="$(sed -n 's|^    <version>\(.*\)</version>.*|\1|p' pom.xml | head -n 1)"
+        if [ -z "$IMAGE_TAG" ]; then
+            echo "Error: could not read project version from pom.xml" >&2
</code_context>
<issue_to_address>
**Valid POMs fail image builds**

When the project version in pom.xml uses different indentation or spans multiple lines, `sed` leaves `IMAGE_TAG` empty, so the empty-tag check exits before Maven builds the image.

Parse the POM version without requiring fixed indentation or a single-line element.

Also at `build_and_push.sh:80`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and with the default push enabled, this can publish an image under a different repository and a tag parsed from pom.xml; if that destination or version is wrong, consumers may pull the wrong artifact. Reverting the script does not remove an image already pushed, so cleanup or republishing would be needed.

Blocking findings: build_and_push.sh:79


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread build_and_push.sh Resolved
Signed-off-by: kusuma chalasani <kchalasani@ibm.com>
@kusumachalasani kusumachalasani moved this to Under Review in Monitoring Nov 6, 2026

@khansaad khansaad 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.

LGTM

@chandrams chandrams 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.

LGTM

@chandrams
chandrams merged commit ed5e8e1 into kruize:mvp_demo Nov 6, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Under Review to Done in Monitoring Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants