cocoon

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cocoon provides types and path helpers for Cocoon's snapshot storage.

This package has NO dependency on the registry package — it is imported by registry for push/pull operations.

Index

Constants

View Source
const DefaultRootDir = "/data01/cocoon"

Variables

This section is empty.

Functions

func HumanSize

func HumanSize(b int64) string

HumanSize formats a byte count as a human-readable string. Delegates to internal/util for the shared implementation.

func SnapshotExists

func SnapshotExists(paths *Paths, name string) bool

SnapshotExists checks if a snapshot already exists locally.

Types

type Paths

type Paths struct {
	RootDir string
}

Paths holds cocoon storage paths for a given root directory.

func NewPaths

func NewPaths(rootDir string) *Paths

func (*Paths) CloudimgBlobDir

func (p *Paths) CloudimgBlobDir() string

func (*Paths) ReadSnapshotDB

func (p *Paths) ReadSnapshotDB() (*SnapshotDB, error)

ReadSnapshotDB reads Cocoon's snapshots.json.

func (*Paths) ResolveSnapshotID

func (p *Paths) ResolveSnapshotID(name string) (string, error)

ResolveSnapshotID resolves a snapshot name to its ID.

func (*Paths) SnapshotDBFile

func (p *Paths) SnapshotDBFile() string

func (*Paths) SnapshotDataDir

func (p *Paths) SnapshotDataDir(id string) string

func (*Paths) WriteSnapshotDB

func (p *Paths) WriteSnapshotDB(db *SnapshotDB) error

WriteSnapshotDB writes Cocoon's snapshots.json atomically.

type SnapshotDB

type SnapshotDB struct {
	Snapshots map[string]*SnapshotRecord `json:"snapshots"`
	Names     map[string]string          `json:"names"`
}

SnapshotDB matches Cocoon's snapshots.json format.

type SnapshotRecord

type SnapshotRecord struct {
	ID           string              `json:"id"`
	Name         string              `json:"name"`
	Description  string              `json:"description,omitempty"`
	Image        string              `json:"image,omitempty"`
	ImageBlobIDs map[string]struct{} `json:"image_blob_ids,omitempty"`
	CPU          int                 `json:"cpu,omitempty"`
	Memory       int64               `json:"memory,omitempty"`
	Storage      int64               `json:"storage,omitempty"`
	NICs         int                 `json:"nics,omitempty"`
	CreatedAt    time.Time           `json:"created_at"`
	Pending      bool                `json:"pending,omitempty"`
	DataDir      string              `json:"data_dir,omitempty"`
}

SnapshotRecord matches Cocoon's snapshot DB record.

Jump to

Keyboard shortcuts

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