repo

package
v1.5.0-alpha14 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version1 is the repo versioning for v1-v1.1.4
	Version1 = iota + 1
	// Version2 is the repo versioning up to v1.2.1
	Version2
	// Version3 is the repo version to (including) v1.4.0
	Version3
	// Version4 is the latest version
	Version4
)
View Source
const LegacyVersionFile = "repo.version"

LegacyVersionFile is the name of the repo file containing the repo version. This file is only used in versions 1.4.0 and below. Subsequent bacalhau versions persist the repo version to system_metadata.yaml

View Source
const SystemMetadataFile = "system_metadata.yaml"

SystemMetadataFile is the name of the file containing the SystemMetadata.

View Source
const UnknownVersion = -1

Variables

This section is empty.

Functions

func GenerateInstanceID added in v1.5.0

func GenerateInstanceID() string

GenerateInstanceID creates a unique, anonymous identifier for the instance of bacalhau.

func IsUnknownVersion added in v1.3.0

func IsUnknownVersion(err error) bool

func IsValidVersion added in v1.2.1

func IsValidVersion(version int) bool

IsValidVersion returns true if the version is valid.

Types

type ErrUnknownRepoVersion added in v1.3.0

type ErrUnknownRepoVersion int

func NewUnknownRepoVersionError added in v1.3.0

func NewUnknownRepoVersionError(version int) ErrUnknownRepoVersion

func (ErrUnknownRepoVersion) Error added in v1.3.0

func (e ErrUnknownRepoVersion) Error() string

type FsRepo

type FsRepo struct {
	Migrations *MigrationManager
	// contains filtered or unexported fields
}

func NewFS

func NewFS(params FsRepoParams) (*FsRepo, error)

func (*FsRepo) EnsureRepoPathsConfigured added in v1.3.2

func (fsr *FsRepo) EnsureRepoPathsConfigured(c config_legacy.ReadWriter)

EnsureRepoPathsConfigured modifies the config to include keys for accessing repo paths

func (*FsRepo) Exists

func (fsr *FsRepo) Exists() (bool, error)

Exists returns true if the repo exists and is valid, false otherwise.

func (*FsRepo) Init

func (fsr *FsRepo) Init() error

Init initializes a new repo, returning an error if the repo already exists.

func (*FsRepo) InstanceID added in v1.5.0

func (fsr *FsRepo) InstanceID() string

InstanceID reads the InstanceID in the metadata. It returns empty string if it fails to read the metadata.

func (*FsRepo) MustInstanceID added in v1.5.0

func (fsr *FsRepo) MustInstanceID() (string, error)

MustInstanceID reads the InstanceID in the metadata. It fails if the metadata file doesn't exist.

func (*FsRepo) Open

func (fsr *FsRepo) Open() error

Open opens an existing repo, returning an error if the repo is uninitialized.

func (*FsRepo) Path

func (fsr *FsRepo) Path() (string, error)

Path returns the filesystem path to of the repo directory.

func (*FsRepo) ReadLastUpdateCheck added in v1.5.0

func (fsr *FsRepo) ReadLastUpdateCheck() (time.Time, error)

ReadLastUpdateCheck returns the last update check value from system_metadata.yaml It fails if the metadata file doesn't exist.

func (*FsRepo) ReadLegacyVersion added in v1.5.0

func (fsr *FsRepo) ReadLegacyVersion() (int, error)

ReadLegacyVersion reads the repo version from the LegacyVersionFile.

func (*FsRepo) ReadNodeName added in v1.5.0

func (fsr *FsRepo) ReadNodeName() (string, error)

func (*FsRepo) SystemMetadata added in v1.5.0

func (fsr *FsRepo) SystemMetadata() (*SystemMetadata, error)

func (*FsRepo) Version added in v1.2.2

func (fsr *FsRepo) Version() (int, error)

Version returns the version of the repo.

func (*FsRepo) WriteLastUpdateCheck added in v1.5.0

func (fsr *FsRepo) WriteLastUpdateCheck(lastUpdateCheck time.Time) error

WriteLastUpdateCheck updates the LastUpdateCheck in the metadata. It fails if the metadata file doesn't exist.

func (*FsRepo) WriteLegacyVersion added in v1.5.0

func (fsr *FsRepo) WriteLegacyVersion(version int) error

WriteLegacyVersion writes the repo version to LegacyVersionFile.

func (*FsRepo) WriteNodeName added in v1.5.0

func (fsr *FsRepo) WriteNodeName(name string) error

func (*FsRepo) WriteRunInfo

func (fsr *FsRepo) WriteRunInfo(ctx context.Context, summaryShellVariablesString string) (string, error)

func (*FsRepo) WriteVersion added in v1.5.0

func (fsr *FsRepo) WriteVersion(version int) error

WriteVersion updates the RepoVersion in the SystemMetadataFile. If the metadata file doesn't exist, it creates a new one.

type FsRepoParams added in v1.2.2

type FsRepoParams struct {
	Path       string
	Migrations *MigrationManager
}

type Migration added in v1.2.2

type Migration struct {
	FromVersion int
	ToVersion   int
	Migrations  []MigrationFn
}

func NewMigration added in v1.2.2

func NewMigration(fromVersion, toVersion int, migrations ...MigrationFn) Migration

NewMigration creates a new migration.

func (Migration) Migrate added in v1.2.2

func (m Migration) Migrate(repo FsRepo) error

Migrate runs the migrations on the given repo.

type MigrationFn added in v1.2.2

type MigrationFn = func(FsRepo) error

type MigrationManager added in v1.2.2

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

func NewMigrationManager added in v1.2.2

func NewMigrationManager(migrations ...Migration) (*MigrationManager, error)

NewMigrationManager creates a new migration manager.

func (*MigrationManager) Add added in v1.2.2

func (m *MigrationManager) Add(migration Migration) error

Add adds a migration to the manager.

func (*MigrationManager) Migrate added in v1.2.2

func (m *MigrationManager) Migrate(repo FsRepo) error

Migrate runs the migrations on the given repo.

type SystemMetadata added in v1.5.0

type SystemMetadata struct {
	RepoVersion     int       `yaml:"RepoVersion"`
	InstanceID      string    `yaml:"InstanceID"`
	LastUpdateCheck time.Time `yaml:"LastUpdateCheck"`
	NodeName        string    `yaml:"NodeName"`
}

func LoadSystemMetadata added in v1.5.0

func LoadSystemMetadata(path string) (*SystemMetadata, error)

type Version added in v1.5.0

type Version struct {
	Version int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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