stager

package
Version: v0.0.0-...-d3fb95e Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package stager ensures that given a list of dependencies, those dependencies exist together in a a folder called a "workspace". Each entry in a workspace links to a file in a "cache", which stores contents addressed by its hash.

Index

Constants

View Source
const URW = 0644

URW is a file mode for a data file

View Source
const URWX = 0755

URWX is a file mode for an executable, or a directory

Variables

This section is empty.

Functions

func Apply

func Apply(ops ...Operation) error

Apply all the operations. Stop at the first error.

func FileExists

func FileExists(path string) bool

func Hash

func Hash(data []byte) string

Hash some data in a deterministic way. TODO: use SHA257

func HashFile

func HashFile(path string) (string, error)

HashFile hashes the file at the given path

Types

type File

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

File causes a file to be written

func (*File) Apply

func (f *File) Apply() error

Apply writes the file to disk TODO: check existing file, leave in place if equal

func (*File) String

func (f *File) String() string
type Link struct {
	// contains filtered or unexported fields
}

Link causes a link to be written

func (*Link) Apply

func (l *Link) Apply() error

Apply creates a symlink at the given path pointing to the given file

func (*Link) String

func (l *Link) String() string

type Manager

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

Manager manages staging a manifest of dependencies using a stager. Manager's main job is to infer the name of the workspace directory based on the SHAs of the dependencies in the manifest.

func NewManager

func NewManager(path string, source Source, fs afero.Fs, manifest ...string) *Manager

NewManager returns a new manager. Creating a manager hashes all the assets in the manifest, so creating a manager is a) expensive, and b) may return an error.

func (*Manager) Stage

func (m *Manager) Stage(name, dest string) error

Stage a file into the managed workspace

func (*Manager) Workspace

func (m *Manager) Workspace() string

Workspace returns the path to the managed workspace

type Operation

type Operation interface {
	Apply() error
	String() string
}

Operation is an operation that can be applied

type Ops

type Ops struct {
	Name string
	Ops  []Operation
}

Ops is a group of ops.

func Group

func Group(name string, ops ...Operation) *Ops

Group returns a group of operations.

func (*Ops) Apply

func (ops *Ops) Apply() error

Apply all the ops

func (*Ops) String

func (ops *Ops) String() string

type Source

type Source func(name string) ([]byte, error)

Source is a provider of assets that may or may not be staged.

type T

type T struct {
	Cache     string
	Workspace string
	Source    Source
	Fs        afero.Fs
}

T is a Stager instance.

func (*T) Stage

func (s *T) Stage(name, dest string) error

Stage asset named "name" to a path in the workspace named "dest"

Jump to

Keyboard shortcuts

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