libocitree

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const CommitPrefix = "/bin/sh -c #(ocitree) "

Variables

View Source
var (
	ErrLocalRepositoryAlreadyExist        = errors.New("local repository with the same name already exist")
	ErrLocalRepositoryUnknown             = errors.New("unknown local repository")
	ErrRelativeReferenceOffsetOutOfBounds = errors.New("relative reference offset is out of bounds")
	ErrCommitHasNoImageAssociated         = errors.New("commit has no image associated")
)
View Source
var (
	ErrUnknownRebaseChoice   = errors.New("unknown rebase choice")
	ErrInvalidRebaseCommitID = errors.New("invalid rebase commit id")
	ErrDuplicateRebaseCommit = errors.New("rebase commit line already parsed")
)
View Source
var (
	ErrRepositoryInvalidNoName  = errors.New("invalid repository, no valid name")
	ErrImageNotPartOfRepository = errors.New("image is not part of repository")
)
View Source
var (
	ErrRebaseNothingToRebase    = errors.New("nothing to rebase")
	ErrRebaseUnknownInstruction = errors.New("unknown instruction")
	ErrRebaseImageNotPartOfRepo = errors.New("rebase image not part of repository")
)
View Source
var (
	ErrUnknownCommitOperation = errors.New("unknown commit operation")
)

Functions

This section is empty.

Types

type AddOptions added in v0.0.3

type AddOptions struct {
	//Chmod sets the access permissions of the destination content.
	Chmod string
	// Chown is a spec for the user who should be given ownership over the
	// newly-added content, potentially overriding permissions which would
	// otherwise be set to 0:0.
	Chown string

	Message string

	ReportWriter io.Writer
}

AddOptions holds option to Manager.Add method.

type CloneOptions added in v0.0.4

type CloneOptions struct {
	PullOptions
}

CloneOptions holds clone options.

type Commit

type Commit struct {
	// contains filtered or unexported fields
}

Commit define the history of a single layer.

func (*Commit) Comment

func (c *Commit) Comment() string

Comment returns the comment associated to this commit.

func (*Commit) CreatedBy

func (c *Commit) CreatedBy() string

CreatedBy returns the operations that created this commit.

func (*Commit) CreationDate

func (c *Commit) CreationDate() *time.Time

CreationDate returns the creation date of the commit.

func (*Commit) ID

func (c *Commit) ID() string

ID returns the ID associated to this commit.

func (*Commit) Operation added in v0.1.0

func (c *Commit) Operation() CommitOperation

Operation returns the operation used to create this commit

func (*Commit) Parent added in v0.1.0

func (c *Commit) Parent() *Commit

Parent returns the parent commit.

func (*Commit) Size

func (c *Commit) Size() int64

Size returns the size of rootfs change contained in this commit.

func (*Commit) Tags

func (c *Commit) Tags() []string

Tags returns the tags associated to this commit.

func (*Commit) WasCreatedByOcitree added in v0.1.0

func (c *Commit) WasCreatedByOcitree() bool

IsCreatedByOCITree returns true if the commit was made using libocitree.

type CommitOperation added in v0.1.0

type CommitOperation uint
const (
	UnknownCommitOperation CommitOperation = iota
	ExecCommitOperation
	AddCommitOperation
)

func (CommitOperation) String added in v0.1.0

func (co CommitOperation) String() string

String implements fmt.Stringer.

type CommitOptions added in v0.0.4

type CommitOptions struct {
	CreatedBy string
	Message   string

	ReportWriter io.Writer
}

CommitOptions contains options to add a commit to repository.

type Commits added in v0.1.0

type Commits []Commit

type ExecOptions added in v0.0.4

type ExecOptions struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	Message      string
	ReportWriter io.Writer
}

ExecOptions holds options for Manager.Exec method.

type FetchOptions added in v0.0.4

type FetchOptions struct {
	PullOptions
}

FetchOptions holds fetch options.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager defines a repositories manager.

func NewManagerFromStore

func NewManagerFromStore(store storage.Store, sysctx *types.SystemContext) (*Manager, error)

NewManagerFromStore returns a new Manager using the given store. An error is returned if libimage.Runtime can't be created using the given store and system context. Call Destroy() once you're done with the manager.

func (*Manager) Clone

func (m *Manager) Clone(remoteRef reference.RemoteRef, options CloneOptions) error

Clone clones remote repository with the given name to local storage.

func (*Manager) Fetch added in v0.0.2

func (m *Manager) Fetch(remoteRef reference.RemoteRef, options FetchOptions) error

Fetch fetches multiple version of the given repository reference. It starts by updating every HEAD tags and then finally, it downloads the given remote reference.

func (*Manager) LocalRepositoryExist added in v0.0.4

func (m *Manager) LocalRepositoryExist(name reference.Name) bool

LocalRepositoryExist returns true if a local repository with the given name exist.

func (*Manager) Repositories

func (m *Manager) Repositories() ([]*Repository, error)

Repositories returns the list of repositories

func (*Manager) Repository

func (m *Manager) Repository(name reference.Name) (*Repository, error)

Repository returns the repository associated with the given name. An error is returned if local repository is missing or corrupted.

func (*Manager) ResolveRelativeReference added in v0.2.0

func (m *Manager) ResolveRelativeReference(ref reference.Relative) (reference.Reference, error)

ResolveRelativeReference turns a relative reference into an absolute one.

type PullOptions added in v0.0.4

type PullOptions struct {
	MaxRetries   uint
	RetryDelay   time.Duration
	ReportWriter io.Writer
}

PullOptions holds configuration options for pulling operations.

type RebaseChoice added in v0.1.0

type RebaseChoice uint
const (
	PickRebaseChoice RebaseChoice = iota
	DropRebaseChoice
	UnknownRebaseChoice
)

func (RebaseChoice) String added in v0.1.0

func (rc RebaseChoice) String() string

String implements fmt.Stringer.

type RebaseCommit added in v0.1.0

type RebaseCommit struct {
	Commit

	Choice RebaseChoice
	// contains filtered or unexported fields
}

RebaseCommit correspond to a commit and a rebase choice.

type RebaseCommits added in v0.1.0

type RebaseCommits struct {
	// contains filtered or unexported fields
}

RebaseCommits define a read only wrapper over a slice of RebaseCommit. Commits are initially sorted from newer to older.

func (RebaseCommits) Get added in v0.1.0

func (rc RebaseCommits) Get(i int) *RebaseCommit

Get returns the RebaseCommit at the given index.

func (RebaseCommits) GetByID added in v0.2.0

func (rc RebaseCommits) GetByID(idprefix string) (*RebaseCommit, int)

GetById returns the RebaseCommit with the given ID prefix.

func (RebaseCommits) Len added in v0.1.0

func (rc RebaseCommits) Len() int

Len returns length of underlying RebaseCommit slice.

func (RebaseCommits) ParseChoices added in v0.2.0

func (rc RebaseCommits) ParseChoices(choices string) error

ParseChoices parses a multiline strnig where each line contains a choice and a commit ID separated by a space. Empty lines and lines starting with # are ignored.

func (RebaseCommits) String added in v0.1.0

func (rc RebaseCommits) String() string

String implements fmt.Stringer.

func (RebaseCommits) Swap added in v0.2.0

func (rc RebaseCommits) Swap(i, j int)

Swap swaps commit at index i and j

type RebaseSession added in v0.1.0

type RebaseSession struct {
	// contains filtered or unexported fields
}

RebaseSession define a rebase session of a repository.

func (*RebaseSession) Apply added in v0.1.0

func (rs *RebaseSession) Apply() error

Apply applies rebase choice. RebaseSession must no be used after this method has been called.

func (*RebaseSession) BaseImage added in v0.1.0

func (rs *RebaseSession) BaseImage() *libimage.Image

BaseImage returns the rebase target image.

func (*RebaseSession) Commits added in v0.1.0

func (rs *RebaseSession) Commits() RebaseCommits

Commits returns the RebaseCommits part of this session.

func (*RebaseSession) InteractiveEdit added in v0.1.0

func (rs *RebaseSession) InteractiveEdit() error

InteractiveEdit starts an interactive session

func (*RebaseSession) RebaseHead added in v0.1.0

func (rs *RebaseSession) RebaseHead() reference.LocalRef

RebaseHead returns reference to rebase head.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository is an object holding the history of a rootfs (OCI/Docker image).

func (*Repository) Add added in v0.0.4

func (r *Repository) Add(dest string, options AddOptions, sources ...string) error

Add commits the given source files to HEAD.

func (*Repository) AddTag added in v0.0.4

func (r *Repository) AddTag(tag reference.Tag) error

AddTag adds the given tag to HEAD.

func (*Repository) Checkout added in v0.0.4

func (r *Repository) Checkout(ref reference.Reference) error

Checkout to commit with the given Identifier.

func (*Repository) Commits

func (r *Repository) Commits() (Commits, error)

Commits returns the commits history of this repository. Commits are ordered from newer to older commits.

func (*Repository) Exec added in v0.0.4

func (r *Repository) Exec(options ExecOptions, cmd string, args ...string) error

func (*Repository) HeadRef added in v0.0.4

func (r *Repository) HeadRef() reference.LocalRef

NameRef returns the underlying HEAD reference.

func (*Repository) ID

func (r *Repository) ID() string

ID returns the ID of the image.

func (*Repository) Mount added in v0.0.2

func (r *Repository) Mount() (string, error)

Mount mounts the repository and returns the mountpoint.

func (*Repository) Name

func (r *Repository) Name() reference.Name

Name returns the name of the repository.

func (*Repository) OtherHeadTags added in v0.2.0

func (r *Repository) OtherHeadTags() []reference.Tag

OtherHeadRefs returns other reference to HEAD.

func (*Repository) OtherTags added in v0.0.4

func (r *Repository) OtherTags() ([]reference.Tag, error)

OtherTags returns tags associated to this repository but not pointing to HEAD.

func (*Repository) RebaseSession added in v0.1.0

func (r *Repository) RebaseSession(ref reference.Reference) (*RebaseSession, error)

RebaseSession starts and returns a new RebaseSession with the given tag as base reference.

func (*Repository) RebaseSessionByImage added in v0.2.0

func (r *Repository) RebaseSessionByImage(baseImage *libimage.Image) (*RebaseSession, error)

RebaseSessionByImage starts and returns a new RebaseSession with the given image as new base. An error is returned if the image is not part of the repository.

func (*Repository) ReloadHead added in v0.0.4

func (r *Repository) ReloadHead() error

ReloadHead reloads underlying HEAD image.

func (*Repository) RemoveTag added in v0.0.4

func (r *Repository) RemoveTag(tag reference.Tag) error

RemoveTag returns the given tag from HEAD.

func (*Repository) Unmount added in v0.0.2

func (r *Repository) Unmount() error

Unmount unmount the repository.

Jump to

Keyboard shortcuts

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