repository

package
v0.0.0-...-95f4d66 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package repository contains the packaging logic of the updater.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repositories

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

Repositories manages multiple repositories.

func NewRepositories

func NewRepositories(rootPath, locksPath string) *Repositories

NewRepositories returns a new Repositories.

func (*Repositories) Cleanup

func (r *Repositories) Cleanup(ctx context.Context) error

Cleanup cleans up the repositories.

func (*Repositories) Create

func (r *Repositories) Create(ctx context.Context, pkg string, version string, stableSourcePath string) error

Create creates a new repository for the given package name.

func (*Repositories) Delete

func (r *Repositories) Delete(_ context.Context, pkg string) error

Delete deletes the repository for the given package name.

func (*Repositories) Get

func (r *Repositories) Get(pkg string) *Repository

Get returns the repository for the given package name.

func (*Repositories) GetPackageState

func (r *Repositories) GetPackageState(pkg string) (State, error)

GetPackageState returns the state of the given package.

func (*Repositories) GetState

func (r *Repositories) GetState() (map[string]State, error)

GetState returns the state of all repositories.

type Repository

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

Repository contains the stable and experimental package of a single artifact managed by the updater.

On disk the repository is structured as follows: . ├── 7.50.0 ├── 7.51.0 ├── stable -> 7.50.0 (symlink) └── experiment -> 7.51.0 (symlink)

and the locks directory (if any) is structured as follows: . ├── 7.50.0 │ └── 1234 ├── 7.51.0 │ └── 5678

We voluntarily do not load the state of the repository in memory to avoid any bugs where what's on disk and what's in memory are not in sync. All the functions of the repository are "atomic" and ensure no invalid state can be reached even if an error happens during their execution. It is possible to end up with garbage left on disk if an error happens during some operations. This is cleaned up during the next operation.

func (*Repository) Cleanup

func (r *Repository) Cleanup(ctx context.Context) error

Cleanup calls the cleanup function of the repository

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, name string, stableSourcePath string) error

Create creates a fresh new repository at the given root path and moves the given stable source path to the repository as the first stable. If a repository already exists at the given path, it is fully removed.

1. Remove the previous repository if it exists. 2. Create the root directory. 3. Move the stable source to the repository. 4. Create the stable link.

func (*Repository) DeleteExperiment

func (r *Repository) DeleteExperiment(ctx context.Context) error

DeleteExperiment deletes the experiment.

1. Cleanup the repository. 2. Delete the experiment link. 3. Cleanup the repository to remove the previous experiment package.

func (*Repository) ExperimentFS

func (r *Repository) ExperimentFS() fs.FS

ExperimentFS returns the experiment package fs.

func (*Repository) GetState

func (r *Repository) GetState() (State, error)

GetState returns the state of the repository.

func (*Repository) PromoteExperiment

func (r *Repository) PromoteExperiment(ctx context.Context) error

PromoteExperiment promotes the experiment to stable.

1. Cleanup the repository. 2. Set the stable link to the experiment package. 3. Delete the experiment link. 4. Cleanup the repository to remove the previous stable package.

func (*Repository) SetExperiment

func (r *Repository) SetExperiment(ctx context.Context, name string, sourcePath string) error

SetExperiment moves package files from the given source path to the repository and sets it as the experiment.

1. Cleanup the repository. 2. Move the experiment source to the repository. 3. Set the experiment link to the experiment package.

func (*Repository) StableFS

func (r *Repository) StableFS() fs.FS

StableFS returns the stable package fs.

type State

type State struct {
	Stable     string
	Experiment string
}

State is the state of the repository.

func (*State) HasExperiment

func (s *State) HasExperiment() bool

HasExperiment returns true if the repository has an experiment package.

func (*State) HasStable

func (s *State) HasStable() bool

HasStable returns true if the repository has a stable package.

Jump to

Keyboard shortcuts

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