Skip to content

[BUILD-1746] feat: map DockerStrategy.From to runtime-stage-from param - #143

Merged
psrvere merged 4 commits into
migtools:mainfrom
psrvere:BUILD-1746-runtime-stage-from
Jul 21, 2026
Merged

[BUILD-1746] feat: map DockerStrategy.From to runtime-stage-from param#143
psrvere merged 4 commits into
migtools:mainfrom
psrvere:BUILD-1746-runtime-stage-from

Conversation

@psrvere

@psrvere psrvere commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Maps BuildConfig's Spec.Strategy.DockerStrategy.From field to Shipwright Build's runtime-stage-from param
  • Handles all three From.Kind types: DockerImage (literal), ImageStreamTag (resolved), ImageStreamImage (resolved via dedicated API)
  • Removes the RuntimeStageFromRFE warning constant — the feature is now implemented

Changes

  • processDockerStrategyFromField() — new function that resolves the From reference and sets the runtime-stage-from param value
  • resolveImageStreamImageRef() — new function for resolving ImageStreamImage references (separate from the existing resolveImageStreamRef which handles ImageStreamTag)
  • Split ImageStreamImage case in processStrategyFromField and processCustomBuildSourceImages to use the correct resolver
  • Removed RuntimeStageFromRFE constant from rfe.go

Test plan

  • Unit tests: 67/67 PASS
  • Cluster test: DockerImage kind → param set with literal name (6.9MB image)
  • Cluster test: ImageStreamTag kind → param resolved from IS (6.9MB image)
  • Cluster test: No From field → no param added, no error (38.8MB image)
  • Cluster test: True multi-stage Dockerfile → only last FROM replaced
  • Full e2e: BuildConfig → crane convert → Shipwright Build → BuildRun — PASS

Dependencies

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Docker-based builds now support specifying the source image used for runtime stages.
    • ImageStream images are resolved using their canonical digest-based references for more accurate build configuration.
  • Bug Fixes

    • Improved conversion of Docker strategy and source image references.
    • Replaced unsupported handling with successful validation and conversion of Docker source images.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@psrvere, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2eb685c-f66c-4e26-bf39-e9d2c61c13b4

📥 Commits

Reviewing files that changed from the base of the PR and between 51aea8a and d04164e.

📒 Files selected for processing (3)
  • convert/buildconfigs.go
  • convert/buildconfigs_test.go
  • convert/rfe.go
📝 Walkthrough

Walkthrough

Docker BuildConfig conversion now maps Docker strategy From values to a runtime-stage-from parameter and resolves ImageStreamImage references using their Docker image digest. Tests cover supported, unsupported, and empty inputs.

Changes

Docker strategy From conversion

Layer / File(s) Summary
Docker From mapping and image resolution
convert/buildconfigs.go, convert/rfe.go
Docker From values are validated and mapped to the runtime-stage-from parameter; ImageStreamImage references resolve to DockerImageReference values.
Docker From and image resolution tests
convert/buildconfigs_test.go
Tests cover ImageStreamTag, ImageStreamImage, DockerImage, unknown, and nil From values, including digest-based image references.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BuildConfigConverter
  participant KubernetesClient
  participant ShipwrightBuild
  BuildConfigConverter->>BuildConfigConverter: validate Docker From kind
  BuildConfigConverter->>KubernetesClient: fetch ImageStreamImage
  KubernetesClient-->>BuildConfigConverter: return DockerImageReference
  BuildConfigConverter->>ShipwrightBuild: append runtime-stage-from parameter
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: mapping DockerStrategy.From to Shipwright's runtime-stage-from parameter.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

psrvere and others added 3 commits July 16, 2026 10:18
…m param

Maps BuildConfig DockerStrategy.From field to Shipwright's runtime-stage-from
parameter, supporting ImageStreamTag, ImageStreamImage, and DockerImage kinds.

Resolves: BUILD-1746

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nstant

- Remove RuntimeStageFromRFE from rfe.go (feature now implemented)
- Collapse identical ImageStreamTag/ImageStreamImage cases into single case
- Extract "runtime-stage-from" to RuntimeStageFromParamName constant
- Update tests to use constant instead of hardcoded strings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Prateek Singh Rathore <prateek.singh.rathore@gmail.com>
… of ImageStreamTag

resolveImageStreamRef always fetched ImageStreamTag objects (expects name:tag format),
causing failures when called with ImageStreamImage refs (name@sha256:digest). Added
resolveImageStreamImageRef that fetches the correct API type and returns DockerImageReference.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

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

🧹 Nitpick comments (2)
convert/buildconfigs.go (2)

326-361: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consolidate parameter creation logic.

The ParamValue struct initialization and append call are identical across the cases. Extracting the image resolution and parameter construction reduces code duplication and improves maintainability.

♻️ Proposed refactor
+	var imageRef string
+	var err error
 	switch fromKind := from.Kind; fromKind {
 	case ImageStreamTag:
-		imageRef, err := t.resolveImageStreamRef(from.Name, from.Namespace)
-		if err != nil {
-			return err
-		}
-		paramValue := shipwrightv1beta1.ParamValue{
-			Name: RuntimeStageFromParamName,
-			SingleValue: &shipwrightv1beta1.SingleValue{
-				Value: &imageRef,
-			},
-		}
-		b.Spec.ParamValues = append(b.Spec.ParamValues, paramValue)
+		imageRef, err = t.resolveImageStreamRef(from.Name, from.Namespace)
 	case ImageStreamImage:
-		imageRef, err := t.resolveImageStreamImageRef(from.Name, from.Namespace)
-		if err != nil {
-			return err
-		}
-		paramValue := shipwrightv1beta1.ParamValue{
-			Name: RuntimeStageFromParamName,
-			SingleValue: &shipwrightv1beta1.SingleValue{
-				Value: &imageRef,
-			},
-		}
-		b.Spec.ParamValues = append(b.Spec.ParamValues, paramValue)
+		imageRef, err = t.resolveImageStreamImageRef(from.Name, from.Namespace)
 	case DockerImage:
-		paramValue := shipwrightv1beta1.ParamValue{
-			Name: RuntimeStageFromParamName,
-			SingleValue: &shipwrightv1beta1.SingleValue{
-				Value: &from.Name,
-			},
-		}
-		b.Spec.ParamValues = append(b.Spec.ParamValues, paramValue)
+		imageRef = from.Name
 	default:
 		return fmt.Errorf("docker strategy 'From' kind %s is unknown for BuildConfig %s", fromKind, bc.Name)
 	}
+
+	if err != nil {
+		return err
+	}
+
+	paramValue := shipwrightv1beta1.ParamValue{
+		Name: RuntimeStageFromParamName,
+		SingleValue: &shipwrightv1beta1.SingleValue{
+			Value: &imageRef,
+		},
+	}
+	b.Spec.ParamValues = append(b.Spec.ParamValues, paramValue)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@convert/buildconfigs.go` around lines 326 - 361, Consolidate the duplicated
ParamValue construction and b.Spec.ParamValues append logic in the from.Kind
switch. Have each case only determine the image reference—resolving
ImageStreamTag and ImageStreamImage as needed, while using from.Name for
DockerImage—then construct and append the shared parameter once after the
switch, preserving existing error returns and unknown-kind handling.

238-241: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove dead code for Docker strategies.

Since Docker strategy From fields are now exclusively routed to the newly introduced processDockerStrategyFromField method, the DockerStrategy fallback block here is unreachable and can be safely removed.

♻️ Proposed refactor
 	var from *corev1.ObjectReference
-	if bc.Spec.Strategy.DockerStrategy != nil && bc.Spec.Strategy.DockerStrategy.From != nil {
-		from = bc.Spec.Strategy.DockerStrategy.From
-	} else if bc.Spec.Strategy.SourceStrategy != nil && bc.Spec.Strategy.SourceStrategy.From.Name != "" {
+	if bc.Spec.Strategy.SourceStrategy != nil && bc.Spec.Strategy.SourceStrategy.From.Name != "" {
 		from = &bc.Spec.Strategy.SourceStrategy.From
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@convert/buildconfigs.go` around lines 238 - 241, Remove the DockerStrategy
condition and assignment from the strategy conversion logic, leaving the
SourceStrategy From handling intact. The DockerStrategy From field is now
handled exclusively by processDockerStrategyFromField, so update the surrounding
if/else flow without changing SourceStrategy behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@convert/buildconfigs.go`:
- Around line 326-361: Consolidate the duplicated ParamValue construction and
b.Spec.ParamValues append logic in the from.Kind switch. Have each case only
determine the image reference—resolving ImageStreamTag and ImageStreamImage as
needed, while using from.Name for DockerImage—then construct and append the
shared parameter once after the switch, preserving existing error returns and
unknown-kind handling.
- Around line 238-241: Remove the DockerStrategy condition and assignment from
the strategy conversion logic, leaving the SourceStrategy From handling intact.
The DockerStrategy From field is now handled exclusively by
processDockerStrategyFromField, so update the surrounding if/else flow without
changing SourceStrategy behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18ae5071-7e65-421e-8bdc-c0496fff90ce

📥 Commits

Reviewing files that changed from the base of the PR and between 99125df and 51aea8a.

📒 Files selected for processing (3)
  • convert/buildconfigs.go
  • convert/buildconfigs_test.go
  • convert/rfe.go
💤 Files with no reviewable changes (1)
  • convert/rfe.go

@psrvere
psrvere force-pushed the BUILD-1746-runtime-stage-from branch from 51aea8a to 2782121 Compare July 16, 2026 04:49
…trategy fallback

- Extract image resolution into switch cases and build ParamValue once after
- Remove unreachable DockerStrategy branch from processStrategyFromField since
  Docker From is now handled by processDockerStrategyFromField

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@psrvere
psrvere merged commit 1cc26b8 into migtools:main Jul 21, 2026
2 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