image

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package image provides high-level access to Harbor / docker-save image archives: metadata scanning, merged filesystem views, directory listing without extraction, selective extraction of single entries, and full merged rootfs extraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyImage

func ApplyImage(imageTarPath string, meta *types.ImageMetadata, outputDir string, bufferSize int, progress ProgressReporter) error

func BuildFileSystem

func BuildFileSystem(imageTarPath string, meta *types.ImageMetadata) (*fsview.Node, error)

BuildFileSystem merges all layers of the image into an in-memory tree without writing anything to disk.

func ExtractPath

func ExtractPath(imageTarPath string, meta *types.ImageMetadata, sourcePath, destPath string, bufferSize int) (int, error)

ExtractPath copies a single file or directory from the merged image filesystem to destPath, streaming only the entries that belong to the selection instead of extracting the whole image.

Semantics mirror cp: a directory source copied into an existing directory lands at destPath/<basename>, while a non-existent destination receives the copy directly. Extracting the image root ("/" or ".") puts its contents into destPath itself. Returns the number of entries written.

func FormatListing

func FormatListing(root *fsview.Node, target string) (string, error)

FormatListing renders the merged image filesystem at target the way `ls -al` would: one long-format line per entry, plus a total block line for directories. target "" or "/" lists the image root.

func PrepareOutputDir

func PrepareOutputDir(outputDir string, force bool) error

func ScanImageMetadata

func ScanImageMetadata(imageTarPath string, sel Selection) (*types.ImageMetadata, error)

func WriteConfigYAML

func WriteConfigYAML(outputDir string, meta *types.ImageMetadata) error

Types

type FileEntry

type FileEntry struct {
	Name    string    `json:"name"`
	Type    string    `json:"type"`
	Mode    string    `json:"mode"`
	Size    int64     `json:"size"`
	ModTime time.Time `json:"mod_time"`
	Target  string    `json:"target,omitempty"`
}

FileEntry is a structured description of one entry in the merged image filesystem — the machine-friendly counterpart of a FormatListing line.

func ListEntries

func ListEntries(root *fsview.Node, target string) ([]FileEntry, error)

ListEntries resolves target inside the merged tree and returns every entry to display: the sorted children when target is a directory (or the image root), the entry itself otherwise.

type ProgressReporter

type ProgressReporter interface {
	SetLayer(string)
	AddLayer()
	MarkDone()
}

type Selection

type Selection struct {
	ImageIndex int
	RepoTag    string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL