Skip to content

split cli.py and oci.py into packages:#47

Merged
mergify[bot] merged 1 commit intotinkerbell:mainfrom
jacobweinstock:refactor-cli-oci
Mar 9, 2026
Merged

split cli.py and oci.py into packages:#47
mergify[bot] merged 1 commit intotinkerbell:mainfrom
jacobweinstock:refactor-cli-oci

Conversation

@jacobweinstock
Copy link
Copy Markdown
Member

@jacobweinstock jacobweinstock commented Mar 8, 2026

Description

These two files were too large. Public APIs are re-exported from init.py with all so existing imports (from captain.cli import main, from captain import oci) remain unchanged. No behavioral changes — pure structural refactor.

Fixes: #

How Has This Been Tested?

How are existing users impacted? What migration steps/scripts do we need?

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors two large single-file modules (captain/cli.py at ~1393 lines and captain/oci.py at ~550 lines) into proper Python packages with multiple submodules. Public APIs are re-exported from __init__.py with __all__, preserving all existing import paths (e.g., from captain.cli import main, from captain import oci). No behavioral changes — pure structural reorganization.

Changes:

  • Split captain/oci.py into a captain/oci/ package with four submodules: _common.py (shared constants/helpers), _build.py (image building/layer creation), _publish.py (publishing logic), and _pull.py (pull/tag operations).
  • Split captain/cli.py into a captain/cli/ package with five submodules: _parser.py (CLI parser infrastructure), _main.py (entry point), _commands.py (command handlers), _stages.py (build stage orchestration), and _release.py (release subcommand).
  • Updated the project_dir derivation in _main.py to account for the additional directory nesting (parent.parent.parent instead of parent.parent).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
captain/oci.py Deleted — code moved to captain/oci/ package
captain/oci/__init__.py Re-exports public API: compute_version_tag, publish, pull, tag_all, tag_image
captain/oci/_common.py Shared constants (_ARCHES), helpers (_image_ref, _default_log), and compute_version_tag
captain/oci/_build.py _deterministic_tar, _collect_arch_artifacts, _build_platform_image
captain/oci/_publish.py _create_push_cleanup, _publish_single_arch, _publish_combined, publish
captain/oci/_pull.py pull, tag_image, tag_all
captain/cli.py Deleted — code moved to captain/cli/ package
captain/cli/__init__.py Re-exports public API: main, COMMANDS
captain/cli/_parser.py CLI parser infrastructure, flag definitions, command extraction
captain/cli/_main.py Main CLI entry point (main())
captain/cli/_commands.py Build and utility command handlers
captain/cli/_stages.py Build stage orchestration (kernel, tools, mkosi, iso)
captain/cli/_release.py Release subcommand handler (publish, pull, tag)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

These two files were too large. Public APIs are re-exported
from __init__.py with __all__ so existing
imports (from captain.cli import main, from captain import oci) remain
unchanged. No behavioral changes — pure structural refactor.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jacobweinstock jacobweinstock added the ready-to-merge Signal Mergify to merge the PR label Mar 9, 2026
@mergify mergify bot added the queued label Mar 9, 2026
mergify bot added a commit that referenced this pull request Mar 9, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 9, 2026

Merge Queue Status

Rule: default


This pull request spent 10 minutes 46 seconds in the queue, including 10 minutes 37 seconds running CI.

Required conditions to merge
  • #changes-requested-reviews-by=0
  • base=main
  • check-success=DCO
  • check-success=build-initramfs (amd64)
  • check-success=build-initramfs (arm64)
  • check-success=build-iso (amd64)
  • check-success=build-iso (arm64)
  • check-success=build-kernel (amd64)
  • check-success=build-kernel (arm64)
  • check-success=download-tools (amd64)
  • check-success=download-tools (arm64)
  • label!=do-not-merge
  • label=ready-to-merge
  • queue-position>=0
  • any of:
  • any of [🛡 GitHub repository ruleset rule main]:
    • check-success = build-initramfs (amd64)
    • check-neutral = build-initramfs (amd64)
    • check-skipped = build-initramfs (amd64)
  • any of [🛡 GitHub repository ruleset rule main]:
    • check-success = build-initramfs (arm64)
    • check-neutral = build-initramfs (arm64)
    • check-skipped = build-initramfs (arm64)
  • any of [🛡 GitHub repository ruleset rule main]:
    • check-success = build-kernel (amd64)
    • check-neutral = build-kernel (amd64)
    • check-skipped = build-kernel (amd64)
  • any of [🛡 GitHub repository ruleset rule main]:
    • check-success = build-kernel (arm64)
    • check-neutral = build-kernel (arm64)
    • check-skipped = build-kernel (arm64)
  • any of [🛡 GitHub repository ruleset rule main]:
    • check-success = download-tools (amd64)
    • check-neutral = download-tools (amd64)
    • check-skipped = download-tools (amd64)
  • any of [🛡 GitHub repository ruleset rule main]:
    • check-success = download-tools (arm64)
    • check-neutral = download-tools (arm64)
    • check-skipped = download-tools (arm64)
  • any of [🛡 GitHub repository ruleset rule main]:
    • check-success = build-iso (amd64)
    • check-neutral = build-iso (amd64)
    • check-skipped = build-iso (amd64)
  • any of [🛡 GitHub repository ruleset rule main]:
    • check-success = build-iso (arm64)
    • check-neutral = build-iso (arm64)
    • check-skipped = build-iso (arm64)

@mergify mergify bot merged commit 2d0e189 into tinkerbell:main Mar 9, 2026
20 checks passed
@mergify mergify bot removed the queued label Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Signal Mergify to merge the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants