core

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package core exposes core objects used by datamon

Index

Constants

View Source
const (
	DiffEntryTypeAdd = iota
	DiffEntryTypeDel
	DiffEntryTypeDif
)

Variables

View Source
var MemProfDir string

Functions

func CreateRepo

func CreateRepo(repo model.RepoDescriptor, store storage.Store) error

func DeleteBundle added in v1.1.0

func DeleteBundle(repo string, store storage.Store, bundleID string) error

DeleteBundle removes a single bundle from a repo

func DeleteEntriesFromRepo added in v1.1.0

func DeleteEntriesFromRepo(repo string, store storage.Store, toDelete []string) error

DeleteEntriesFromRepo remove a list of file entries from all bundles in a repo

func DeleteLabel added in v1.1.0

func DeleteLabel(repo string, store storage.Store, name string) error

DeleteLabel removes a single label from a repo

func DeleteRepo added in v1.1.0

func DeleteRepo(repo string, store storage.Store) error

DeleteRepo removes a repository from metadata

func DownloadMetadata

func DownloadMetadata(ctx context.Context, bundle *Bundle) error

DownloadMetadata from the archive to main memory

func GetLatestBundle

func GetLatestBundle(repo string, store storage.Store) (string, error)

GetLatestBundle returns the latest bundle descriptor from a repo

func GetRepo

func GetRepo(repo string, store storage.Store) (*model.RepoDescriptor, error)

func GetRepoDescriptorByRepoName

func GetRepoDescriptorByRepoName(store storage.Store, repoName string) (model.RepoDescriptor, error)

GetRepoDescriptorByRepoName returns the descriptor of a named repo

func ListBundles

func ListBundles(repo string, store storage.Store, opts ...ListOption) (model.BundleDescriptors, error)

ListBundles returns a list of bundle descriptors from a repo. It collects all bundles until completion.

NOTE: this func could become deprecated. At this moment, however, it is used by pkg/web.

func ListBundlesApply

func ListBundlesApply(repo string, store storage.Store, apply ApplyBundleFunc, opts ...ListOption) error

ListBundlesApply applies some function to the retrieved bundles, in lexicographic order of keys.

The execution of the applied function does not block background retrieval of more keys and bundle descriptors.

Example usage: printing bundle descriptors as they come

  err := core.ListBundlesApply(repo, store, func(bundle model.BundleDescriptor) error {
				fmt.Fprintf(os.Stderr, "%v\n", bundle)
				return nil
			})

func ListLabels

func ListLabels(repo string, store storage.Store, prefix string, opts ...ListOption) ([]model.LabelDescriptor, error)

ListLabels returns all labels from a repo

func ListLabelsApply

func ListLabelsApply(repo string, store storage.Store, prefix string, apply ApplyLabelFunc, opts ...ListOption) error

ListLabelsApply applies some function to the retrieved labels, in lexicographic order of keys.

func ListRepos

func ListRepos(store storage.Store, opts ...ListOption) ([]model.RepoDescriptor, error)

ListRepos returns all repos from a store

func ListReposApply

func ListReposApply(store storage.Store, apply ApplyRepoFunc, opts ...ListOption) error

ListReposApply applies some function to the retrieved repos, in lexicographic order of keys.

func ListReposPaginated

func ListReposPaginated(store storage.Store, token string) ([]model.RepoDescriptor, error)

ListReposPaginated is at this moment only used by the CSI package. Question: shall we deprecate this?

func NewBDescriptor

func NewBDescriptor(descriptorOps ...BundleDescriptorOption) *model.BundleDescriptor

func NewLabelDescriptor

func NewLabelDescriptor(descriptorOps ...LabelDescriptorOption) *model.LabelDescriptor

func PopulateFiles

func PopulateFiles(ctx context.Context, bundle *Bundle) error

func Publish

func Publish(ctx context.Context, bundle *Bundle) error

Publish an bundle to a consumable store

func PublishFile

func PublishFile(ctx context.Context, bundle *Bundle, file string) error

func PublishMetadata

func PublishMetadata(ctx context.Context, bundle *Bundle) error

PublishMetadata from the archive to the consumable store

func PublishSelectBundleEntries

func PublishSelectBundleEntries(ctx context.Context, bundle *Bundle, selectionPredicate func(string) (bool, error)) error

func RepoExists

func RepoExists(repo string, store storage.Store) error

func Update

func Update(ctx context.Context, bundleSrc *Bundle, bundleDest *Bundle) error

func Upload

func Upload(ctx context.Context, bundle *Bundle) error

Upload an bundle to archive

func UploadSpecificKeys

func UploadSpecificKeys(ctx context.Context, bundle *Bundle, getKeys func() ([]string, error)) error

Upload specified keys (files) within a bundle's consumable store

Types

type ApplyBundleFunc

type ApplyBundleFunc func(model.BundleDescriptor) error

ApplyBundleFunc is a function to be applied on a bundle

type ApplyLabelFunc

type ApplyLabelFunc func(model.LabelDescriptor) error

ApplyLabelFunc is a function to be applied on a label

type ApplyRepoFunc

type ApplyRepoFunc func(model.RepoDescriptor) error

ApplyRepoFunc is a function to be applied on a repo

type Bundle

type Bundle struct {
	RepoID          string
	BundleID        string
	MetaStore       storage.Store
	ConsumableStore storage.Store
	BlobStore       storage.Store

	BundleDescriptor model.BundleDescriptor
	BundleEntries    []model.BundleEntry
	Streamed         bool

	SkipOnError bool // When uploading files
	// contains filtered or unexported fields
}

Bundle represents the bundle in its archived state

func New

func New(bd *model.BundleDescriptor, bundleOps ...BundleOption) *Bundle

func (*Bundle) Exists

func (b *Bundle) Exists(ctx context.Context) (bool, error)

func (*Bundle) GetBundleEntries

func (b *Bundle) GetBundleEntries() []model.BundleEntry

func (*Bundle) InitializeBundleID

func (b *Bundle) InitializeBundleID() error

InitializeBundleID create and set a new bundle ID

func (*Bundle) ReadAt

func (b *Bundle) ReadAt(file *fsEntry, destination []byte, offset int64) (int, error)

type BundleDescriptorOption

type BundleDescriptorOption func(descriptor *model.BundleDescriptor)

func Message

func Message(m string) BundleDescriptorOption

func Parents

func Parents(p []string) BundleDescriptorOption

type BundleDiff

type BundleDiff struct {
	Entries []DiffEntry
}

func Diff

func Diff(ctx context.Context, bundleExisting *Bundle, bundleAdditional *Bundle) (BundleDiff, error)

type BundleOption

type BundleOption func(*Bundle)

func BlobStore

func BlobStore(store storage.Store) BundleOption

func BundleID

func BundleID(bID string) BundleOption

func ConcurrentFileDownloads

func ConcurrentFileDownloads(concurrentFileDownloads int) BundleOption

func ConcurrentFileUploads

func ConcurrentFileUploads(concurrentFileUploads int) BundleOption

func ConcurrentFilelistDownloads

func ConcurrentFilelistDownloads(concurrentFilelistDownloads int) BundleOption

func ConsumableStore

func ConsumableStore(store storage.Store) BundleOption

func Logger

func Logger(l *zap.Logger) BundleOption

func MetaStore

func MetaStore(store storage.Store) BundleOption

func Repo

func Repo(r string) BundleOption

func SkipMissing

func SkipMissing(s bool) BundleOption

func Streaming

func Streaming(s bool) BundleOption

type DiffEntry

type DiffEntry struct {
	Type DiffEntryType
	// could use a method rather than storing Name in order to curb memory use
	Name       string
	Existing   model.BundleEntry
	Additional model.BundleEntry
}

type DiffEntryType

type DiffEntryType uint

func (DiffEntryType) String

func (det DiffEntryType) String() string

type Label

type Label struct {
	Descriptor model.LabelDescriptor
}

func NewLabel

func NewLabel(ld *model.LabelDescriptor, labelOps ...LabelOption) *Label

func (*Label) DownloadDescriptor

func (label *Label) DownloadDescriptor(ctx context.Context, bundle *Bundle, checkRepoExists bool) error

func (*Label) UploadDescriptor

func (label *Label) UploadDescriptor(ctx context.Context, bundle *Bundle) error

type LabelDescriptorOption

type LabelDescriptorOption func(descriptor *model.LabelDescriptor)

func LabelContributors

func LabelContributors(c []model.Contributor) LabelDescriptorOption

type LabelOption

type LabelOption func(*Label)

func LabelName

func LabelName(name string) LabelOption

type ListOption

type ListOption func(*Settings)

ListOption sets options for listing core objects

func BatchSize

func BatchSize(batchSize int) ListOption

BatchSize sets the batch window to fetch core objects. It defaults to defaultBatchSize

func ConcurrentList

func ConcurrentList(concurrentList int) ListOption

ConcurrentList sets the max level of concurrency to retrieve core objects. It defaults to 2 x #cpus.

func WithDoneChan

func WithDoneChan(done chan struct{}) ListOption

WithDoneChan sets a signaling channel controlled by the caller to interrupt ongoing goroutines

type MutableFS

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

ReadOnlyFS is the virtual filesystem created on top of a bundle.

func NewMutableFS

func NewMutableFS(bundle *Bundle, pathToStaging string) (*MutableFS, error)

NewMutableFS creates a new instance of the datamon filesystem.

func (*MutableFS) Commit

func (dfs *MutableFS) Commit() error

func (*MutableFS) JoinMount

func (dfs *MutableFS) JoinMount(ctx context.Context) error

func (*MutableFS) MountMutable

func (dfs *MutableFS) MountMutable(path string) error

func (*MutableFS) Unmount

func (dfs *MutableFS) Unmount(path string) error

type ReadOnlyFS

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

ReadOnlyFS is the virtual filesystem created on top of a bundle.

func NewReadOnlyFS

func NewReadOnlyFS(bundle *Bundle, l *zap.Logger) (*ReadOnlyFS, error)

NewReadOnlyFS creates a new instance of the datamon filesystem.

func (*ReadOnlyFS) JoinMount

func (dfs *ReadOnlyFS) JoinMount(ctx context.Context) error

func (*ReadOnlyFS) MountReadOnly

func (dfs *ReadOnlyFS) MountReadOnly(path string) error

func (*ReadOnlyFS) Unmount

func (dfs *ReadOnlyFS) Unmount(path string) error

type Settings

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

Settings defines various settings for core features

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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