Skip to content

Conversation

@joaomariolago
Copy link
Collaborator

@joaomariolago joaomariolago commented Nov 6, 2025

Allows users to install extensions directly from local file system without need of external manifests or docker hub.

Summary by Sourcery

Allow users to install Kraken extensions directly from local .tar image files by uploading a Docker image tar, extracting metadata from its labels, and managing temporary extensions through new upload and finalize workflows

New Features:

  • Enable direct installation of Kraken extensions from local .tar Docker image files via upload and finalize endpoints
  • Add frontend UI for uploading .tar files in the Extension Manager with a dedicated speed dial action and file upload dialog

Enhancements:

  • Implement backend methods to load Docker images from tar content, inspect image LABEL metadata, and create or finalize temporary extensions
  • Introduce automatic cleanup of abandoned temporary extensions older than one hour in the Kraken service
  • Update the extension creation modal to support configuring uploaded extensions before finalizing installation

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 6, 2025

Reviewer's Guide

This PR enables installing Kraken extensions directly from local tar images by adding backend support for importing Docker images, extracting metadata, staging temporary extensions, and new API endpoints, along with front-end UI and logic for uploading, configuring, and finalizing these extensions.

Sequence diagram for extension installation from .tar file

sequenceDiagram
  actor User
  participant Frontend
  participant Backend
  participant Docker
  User->>Frontend: Selects and uploads .tar file
  Frontend->>Backend: POST /extension/upload (tar file)
  Backend->>Docker: Import image from tar
  Docker-->>Backend: Image loaded
  Backend->>Docker: Inspect image labels
  Docker-->>Backend: Metadata returned
  Backend->>Backend: Create temporary extension
  Backend-->>Frontend: Return temp_tag and metadata
  User->>Frontend: Configures extension details
  Frontend->>Backend: POST /extension/finalize (with temp_tag)
  Backend->>Backend: Finalize temporary extension
  Backend->>Docker: Tag image with final identifier
  Backend->>Backend: Install extension
  Backend-->>Frontend: Installation progress
Loading

ER diagram for temporary extension staging and finalization

erDiagram
  EXTENSION_SETTINGS {
    string identifier
    string name
    string docker
    string tag
    string permissions
    bool enabled
    string user_permissions
  }
  EXTENSION_SOURCE {
    string identifier
    string tag
    string name
    string docker
    bool enabled
    string permissions
    string user_permissions
  }
  EXTENSION_SETTINGS ||--|| EXTENSION_SOURCE : "finalize uses source to update settings"
  EXTENSION_SETTINGS {
    string identifier "temporary extension"
  }
Loading

Class diagram for new and updated extension upload logic

classDiagram
  class Extension {
    +static async load_image_from_tar(tar_content: bytes) -> str
    +static async inspect_image_labels(image_name: str) -> Dict[str, Any]
    +static async cleanup_temporary_extensions() -> None
    +async create_temporary_extension(image_name: str, metadata: Dict[str, Any]) -> Extension
    +async finalize_temporary_extension(temp_extension: Extension, identifier: str, source: ExtensionSource) -> Extension
  }
  class ExtensionSource {
    identifier: str
    tag: str
    name: str
    docker: str
    enabled: bool
    permissions: str
    user_permissions: str
  }
  class ExtensionSettings {
    identifier: str
    name: str
    docker: str
    tag: str
    permissions: str
    enabled: bool
    user_permissions: str
  }
  Extension o-- ExtensionSource
  Extension o-- ExtensionSettings
Loading

File-Level Changes

Change Details Files
Support importing Docker images from tar files and extracting metadata
  • Implemented load_image_from_tar to import and identify images asynchronously
  • Added inspect_image_labels to parse Docker LABELs into extension metadata
  • Provided fallback logic to list images when stream parsing fails
core/services/kraken/extension/extension.py
Manage temporary extension lifecycle
  • Created temporary extensions with unique tags for uploaded images
  • Finalized temporary extensions by assigning identifiers and retagging images
  • Added cleanup_temporary_extensions to remove unused temporary entries
core/services/kraken/extension/extension.py
core/services/kraken/kraken.py
Add API endpoints for uploading and finalizing extensions
  • Introduced POST /upload to receive .tar, load image, extract metadata, and create a temp extension
  • Introduced POST /finalize to convert a temp extension into a permanent one and stream installation
  • Extended error handling to map ExtensionPullFailed to HTTP 400
core/services/kraken/api/v2/routers/extension.py
Integrate front-end UI and logic for file-based extension installation
  • Replaced FAB with a speed-dial offering "Create from scratch" and "Upload from file"
  • Added a file upload dialog, validation rules, and uploadFile/open/close handlers
  • Implemented finalizeUploadedExtension to call finalize endpoint and show progress
core/frontend/src/views/ExtensionManagerView.vue
Expose upload and finalize operations in KrakenManager and types
  • Added uploadExtensionTarFile and finalizeExtension methods calling new API routes
  • Extended kraken types with ExtensionUploadMetadata and ExtensionUploadResponse
core/frontend/src/components/kraken/KrakenManager.ts
core/frontend/src/types/kraken.ts
Enhance extension creation modal for uploaded extensions
  • Added tempTag prop and is_from_upload computed flag
  • Adjusted modal title and primary button text based on upload context
core/frontend/src/components/kraken/modals/ExtensionCreationModal.vue

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

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.

1 participant