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
- func HumanSize(b int64) string
- func SnapshotExists(paths *Paths, name string) bool
- type Paths
- func (p *Paths) CloudimgBlobDir() string
- func (p *Paths) ReadSnapshotDB() (*SnapshotDB, error)
- func (p *Paths) ResolveSnapshotID(name string) (string, error)
- func (p *Paths) SnapshotDBFile() string
- func (p *Paths) SnapshotDataDir(id string) string
- func (p *Paths) WriteSnapshotDB(db *SnapshotDB) error
- type SnapshotDB
- type SnapshotRecord
Constants ¶
const DefaultRootDir = "/data01/cocoon"
Variables ¶
This section is empty.
Functions ¶
func HumanSize ¶
HumanSize formats a byte count as a human-readable string. Delegates to internal/util for the shared implementation.
func SnapshotExists ¶
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 (*Paths) CloudimgBlobDir ¶
func (*Paths) ReadSnapshotDB ¶
func (p *Paths) ReadSnapshotDB() (*SnapshotDB, error)
ReadSnapshotDB reads Cocoon's snapshots.json.
func (*Paths) ResolveSnapshotID ¶
ResolveSnapshotID resolves a snapshot name to its ID.
func (*Paths) SnapshotDBFile ¶
func (*Paths) SnapshotDataDir ¶
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.