Skip to content

refactor(oci): share feature and template publish helpers - #1563

Merged
skevetter merged 1 commit into
mainfrom
refactor/oci-share-publish-helpers
Oct 19, 2026
Merged

skevetter merged 1 commit into
mainfrom
refactor/oci-share-publish-helpers

Conversation

@skevetter

@skevetter skevetter commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Moves the shared OCI publish logic from cmd/feature/publish.go and cmd/template/publish.go into pkg/image/publish.go.
  • Shared helpers: ResolvePublishVersion, ValidatePublishDir, ParsePublishReference, BuildPublishImage, PushPublishImage, WritePublishedMetadata.
  • Each command keeps its own flags, help text, metadata parsing, and stdout JSON shape.
  • Helper-level tests move to pkg/image/publish_test.go. Command-wrapper tests stay in cmd/feature.

Why

Feature and template publish were near-identical copies. A single implementation keeps error prefixes and push/log behavior from drifting. This is behavior-preserving: every error and log string is byte-identical, and there are no CLI, output, or exit-code changes.

Validation

Run on the rebased tree (base fa8621043), all passing:

  • mise run cli:format
  • mise run cli:lint:ci
  • golangci-lint run --new-from-rev=origin/main ./cmd/... ./pkg/...
  • go build ./...
  • go test ./cmd/feature/... ./cmd/template/... ./pkg/image/...
  • GOOS=windows go build ./cmd/... ./pkg/image/...

cmd/template has no test files.

CodeRabbit CLI

Ran coderabbit review --agent --committed. It produced 1 minor finding: WritePublishedMetadata ignores stdout write errors. Skipped, because origin/main also ignores them (_, _ = os.Stdout.Write). Handling them would add a new error exit path, which this refactor must not change.

Auto-merge

Eligible: yes. Non-test changed lines: 285 (cmd/feature/publish.go 93, cmd/template/publish.go 89, pkg/image/publish.go 103). Three files, no go.mod, lockfile, or .golangci changes, no //nolint, no new dependencies.

Next

Review the shared helper boundary in pkg/image/publish.go. Confirm CI passes before marking ready.

Summary by CodeRabbit

  • Improvements
    • Feature and template publishing now follow consistent behavior for version defaults, image references, and published metadata.
    • Publishing targets are checked to ensure they exist and are directories before publishing proceeds.

@skevetter skevetter added the auto-refactor Automated refactor PR label Oct 18, 2026
@netlify

netlify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 586c363
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6ad529c08cd86b438cf56b38

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 40b8adde-ed0a-4b00-a5ca-ce230f2d9b75
📥 Commits

Reviewing files that changed from the base of the PR and between fa86210 and 586c363.

📒 Files selected for processing: 5
  • cmd/feature/publish.go
  • cmd/feature/publish_test.go
  • cmd/template/publish.go
  • pkg/image/publish.go
  • pkg/image/publish_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Walkthrough

Feature and template publishing now use shared helpers in pkg/image for version resolution, reference parsing, image construction and pushing, directory validation, and metadata output.

Changes: Image publishing

Layer / File(s) Summary
Shared publish helpers
pkg/image/publish.go, pkg/image/publish_test.go
The new helpers handle publish references, directory validation, image construction, registry pushes, and indented JSON metadata output with a trailing newline. Tests cover these helpers. Writer errors during metadata output are ignored.
Feature and template command integration
cmd/feature/publish.go, cmd/feature/publish_test.go, cmd/template/publish.go
Both commands delegate publish operations and directory validation to pkg/image. Their local reference and image-building helpers are removed. Feature-command tests for those helpers are removed; corresponding helper tests are added in pkg/image.

Priority: ⬇️ Low

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

Change: Refactor

Merge Risk: ⚪ Minimal · up to 586c3

This refactor is described as behavior-preserving, and no concrete merge-blocking issue was found in the supplied changes.

Security architecture risk: ⚪ Minimal · up to 586c3

The refactor centralizes publishing without changing the reviewed commands’ validation, registry destinations, credential selection, or output contracts. No introduced or materially worsened security risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The reviewed publishing path continues to act with the invoking process’s filesystem access and default-keychain registry authority. Its direct effect remains uploading the selected local content to the selected registry reference; helper export alone does not create an independently accessible service or grant additional privileges.

Trust Boundaries and Controls

  • observed — The filesystem-to-archive and process-to-authenticated-registry boundaries are unchanged for existing callers. Directory checks, command-specific metadata parsing, reference parsing, and default-keychain selection remain in the execution path. No additional destination authorization or archive filtering is added by this refactor.

Resilience and Maintainability Implications

  • observed — Push errors still stop command execution before metadata output, and success logging follows the registry call. No new retry, locking, rollback, or cleanup mechanism is introduced. Metadata write errors remain ignored as before, so a completed push and successful output delivery are not transactional. Registry-side partial-failure and recovery guarantees remain unestablished rather than newly weakened by this extraction.
Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the refactor, rationale, affected helpers, validation commands, and known review finding. It does not follow the repository template and omits the Type of change, AI assistanc… Update the description to use the repository template. Mark the refactor type, disclose AI assistance and its usage, complete the testing and checklist sections, state whether integration tests are required, and document manual verification…
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly describes the main change: sharing OCI publish helpers between feature and template commands.
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.
Full details: Description check

Explanation

The description explains the refactor, rationale, affected helpers, validation commands, and known review finding. It does not follow the repository template and omits the Type of change, AI assistance declaration, required checklist, manual verification details, and integration-test status.

Resolution

Update the description to use the repository template. Mark the refactor type, disclose AI assistance and its usage, complete the testing and checklist sections, state whether integration tests are required, and document manual verification results.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@netlify

netlify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 586c363
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6ad529c00ae1e07970507928

@skevetter
skevetter marked this pull request as ready for review October 18, 2026 21:11
@mergify

mergify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@skevetter

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@skevetter
skevetter merged commit 6839175 into main Oct 19, 2026
111 checks passed
@skevetter
skevetter deleted the refactor/oci-share-publish-helpers branch October 19, 2026 00:06
@skevetter

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-refactor Automated refactor PR size/xl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant