libostree

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

ostree

ostree is a wrapper around libostree that aims to provide an idiomatic API.

Notes
  1. A minimal glib implementation exists within the ostree pkg. This is to avoid a dependency on glib for the time being.
    • This implementation is not complete and will be expanded as needed.
    • The glib implementation is not intended to be used outside of the ostree pkg.
    • GCancellable is not implemented on some functions. If the func accepts a context.Context it most likely implements a GCancellable.
  2. Not all of libostree is wrapped. Only the parts that are needed for beskar are wrapped. Which is basically everything need to perform pull operations.
    • OstreeAsyncProgress is not implemented. Just send nil.
Developer Warnings
  • glib/gobject are used here and add a layer of complexity to the code, specifically with regard to memory management. glib/gobject are reference counted and objects are freed when the reference count reaches 0. Therefore, you will see C.g_XXX_ref_sink or C.g_XXX_ref (increases reference count) and C.g_XXX_unref() (decrease reference count) in some places and C.free() in others. A good rule of thumb is that if you see a g_ prefix you are dealing with a reference counted object and should not call C.free(). See glib for more information. See gobject for more information.
Testdata

The testdata directory contains a simple ostree repo that can be used for testing. It was created using the generate-testdata.sh script. testdata has been committed to this git repo so that it remains static. If you need to regenerate the testdata you can, however, keep in mind that newer versions of ostree may produce different results and may cause tests to fail. The version of ostree used to generate the testdata is 2023.7.

Documentation

Index

Constants

View Source
const (
	// Mirror - Write out refs suitable for mirrors and fetch all refs if none requested
	Mirror = 1 << iota

	// CommitOnly - Fetch only the commit metadata
	CommitOnly

	// Untrusted - Do verify checksums of local (filesystem-accessible) repositories (defaults on for HTTP)
	Untrusted

	// BaseUserOnlyFiles - Since 2017.7.  Reject writes of content objects with modes outside of 0775.
	BaseUserOnlyFiles

	// TrustedHTTP - Don't verify checksums of objects HTTP repositories (Since: 2017.12)
	TrustedHTTP

	// None - No special options for pull
	None = 0
)
View Source
const (
	ListRefsExtFlagsAliases = 1 << iota
	ListRefsExtFlagsExcludeRemotes
	ListRefsExtFlagsExcludeMirrors
	ListRefsExtFlagsNone ListRefsExtFlags = 0
)
View Source
const (
	ErrInvalidPath = Err("invalid path")
)

Variables

This section is empty.

Functions

func GoError

func GoError(e *C.GError) error

GoError converts a C glib error to a Go error. The C error is freed after conversion.

Types

type Err

type Err string

func (Err) Error

func (e Err) Error() string

type FlagSet

type FlagSet int

type ListRefsExtFlags

type ListRefsExtFlags int

type Option

type Option func(builder *C.GVariantBuilder, deferFree deferredFreeFn)

Option defines an option for pulling ostree repos. It is used to build a *C.GVariant via a *C.GVariantBuilder. deferFree is an optional function that frees the memory allocated by the option. deferFree may be called more than once.

func AppendUserAgent

func AppendUserAgent(appendUserAgent string) Option

AppendUserAgent sets the append-user-agent option to the given value in the pull options. Additional string to append to the user agent.

func Depth

func Depth(depth int) Option

Depth sets the depth option to the given value in the pull options. How far in the history to traverse; default is 0, -1 means infinite

func DisableStaticDelta

func DisableStaticDelta() Option

DisableStaticDelta sets the disable-static-deltas option to true in the pull options. Do not use static deltas.

func DryRun

func DryRun() Option

DryRun sets the dry-run option to true in the pull options. Only print information on what will be downloaded (requires static deltas).

func Flags

func Flags(flags FlagSet) Option

Flags adds the given flags to the pull options.

func HTTPHeaders added in v0.0.30

func HTTPHeaders(headers map[string]string) Option

HTTPHeaders sets the http-headers option to the given value in the pull options. Additional HTTP headers to send with requests.

func MaxOutstandingFetcherRequests added in v0.0.30

func MaxOutstandingFetcherRequests(n uint32) Option

MaxOutstandingFetcherRequests sets the max-outstanding-fetcher-requests option to the given value in the pull options. The max amount of concurrent connections allowed.

func NetworkRetries

func NetworkRetries(n int) Option

NetworkRetries sets the n-network-retries option to the given value in the pull options. Number of times to retry each download on receiving.

func NoGPGVerify

func NoGPGVerify() Option

NoGPGVerify sets the gpg-verify option to false in the pull options.

func NoGPGVerifySummary

func NoGPGVerifySummary() Option

NoGPGVerifySummary sets the gpg-verify-summary option to false in the pull options.

func Refs

func Refs(refs ...string) Option

Refs adds the given refs to the pull options. When pulling refs from a remote, only the specified refs will be pulled.

func RequireStaticDelta

func RequireStaticDelta() Option

RequireStaticDelta sets the require-static-deltas option to true in the pull options. Require static deltas.

type Ref

type Ref struct {
	Name     string
	Checksum string
}

type Repo

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

func Init

func Init(path string, mode RepoMode) (repo *Repo, err error)

Init initializes & opens a new ostree repository at the given path.

Create the underlying structure on disk for the repository, and call
ostree_repo_open() on the result, preparing it for use.

Since version 2016.8, this function will succeed on an existing
repository, and finish creating any necessary files in a partially
created repository.  However, this function cannot change the mode
of an existing repository, and will silently ignore an attempt to
do so.

Since 2017.9, "existing repository" is defined by the existence of an
`objects` subdirectory.

This function predates ostree_repo_create_at(). It is an error to call
this function on a repository initialized via ostree_repo_open_at().

func Open

func Open(path string) (*Repo, error)

Open opens an ostree repository at the given path.

func (*Repo) AddRemote

func (r *Repo) AddRemote(name, url string, opts ...Option) error

AddRemote adds a remote to the repository.

func (*Repo) DeleteRemote

func (r *Repo) DeleteRemote(name string) error

DeleteRemote deletes a remote from the repository.

func (*Repo) ListRefsExt

func (r *Repo) ListRefsExt(flags ListRefsExtFlags, prefix ...string) ([]Ref, error)

func (*Repo) ListRemotes

func (r *Repo) ListRemotes() []string

ListRemotes lists the remotes in the repository.

func (*Repo) Pull

func (r *Repo) Pull(ctx context.Context, remote string, opts ...Option) error

Pull pulls refs from the named remote. Returns an error if the refs could not be fetched.

func (*Repo) RegenerateSummary

func (r *Repo) RegenerateSummary() error

func (*Repo) ReloadRemoteConfig

func (r *Repo) ReloadRemoteConfig() error

ReloadRemoteConfig reloads the remote configuration.

type RepoMode

type RepoMode string

RepoMode - The mode to use when creating a new repo. If an unknown mode is passed, RepoModeBare will be used silently.

See https://ostreedev.github.io/ostree/formats/#the-archive-format See https://ostreedev.github.io/ostree/formats/#aside-bare-formats

const (
	// RepoModeBare - The default mode. Keeps all file metadata. May require elevated privileges.
	// The bare repository format is the simplest one. In this mode regular files are directly stored to disk, and all
	// metadata (e.g. uid/gid and xattrs) is reflected to the filesystem. It allows further direct access to content and
	// metadata, but it may require elevated privileges when writing objects to the repository.
	RepoModeBare RepoMode = "bare"

	// RepoModeArchive - The archive format. Best for small storage footprint. Mostly used for server-side repositories.
	// The archive format simply gzip-compresses each content object. Metadata objects are stored uncompressed. This
	// means that it’s easy to serve via static HTTP. Note: the repo config file still uses the historical term
	// archive-z2 as mode. But this essentially indicates the modern archive format.
	//
	// When you commit new content, you will see new .filez files appearing in `objects/`.
	RepoModeArchive RepoMode = "archive"

	// RepoModeArchiveZ2 - Functionally equivalent to RepoModeArchive. Only useful for backwards compatibility.
	RepoModeArchiveZ2 RepoMode = "archive-z2"

	// RepoModeBareUser - Like RepoModeBare but ignore incoming uid/gid and xattrs.
	// The bare-user format is a bit special in that the uid/gid and xattrs from the content are ignored. This is
	// primarily useful if you want to have the same OSTree-managed content that can be run on a host system or an
	// unprivileged container.
	RepoModeBareUser RepoMode = "bare-user"

	// RepoModeBareUserOnly - Like RepoModeBareUser. No metadata stored. Only useful for checkouts. Does not need xattrs.
	// Same as BARE_USER, but all metadata is not stored, so it can only be used for user checkouts. Does not need xattrs.
	RepoModeBareUserOnly RepoMode = "bare-user-only"

	// RepoModeBareSplitXAttrs - Like RepoModeBare but store xattrs in a separate file.
	// Similarly, the bare-split-xattrs format is a special mode where xattrs are stored as separate repository objects,
	// and not directly reflected to the filesystem. This is primarily useful when transporting xattrs through lossy
	// environments (e.g. tar streams and containerized environments). It also allows carrying security-sensitive xattrs
	// (e.g. SELinux labels) out-of-band without involving OS filesystem logic.
	RepoModeBareSplitXAttrs RepoMode = "bare-split-xattrs"
)

Jump to

Keyboard shortcuts

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