store

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PathPaddingCharacters = "bramble_store_padding"
	PathPaddingLength     = 50

	// BramblePrefixOfRecord is the prefix we use when hashing the build output
	// this allows us to get a consistent hash even if we're building in a
	// different location
	BramblePrefixOfRecord = "/home/bramble/bramble/bramble_store_padding/bramb" // TODO: could we make this more obviously fake?

)

Functions

This section is empty.

Types

type BuildDerivationOptions

type BuildDerivationOptions struct {
	// ForceBuild will make sure we build even if the derivation already exists
	ForceBuild bool

	Shell   bool
	Verbose bool
}

type Builder

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

func (*Builder) BuildDerivation

func (b *Builder) BuildDerivation(ctx context.Context, drv Derivation, opts BuildDerivationOptions) (builtDrv Derivation, didBuild bool, err error)

type CacheClient

type CacheClient interface {
	PostChunk(context.Context, io.Reader) (string, error)
	PostDerivation(context.Context, Derivation) (string, error)
	PostOutput(context.Context, OutputRequestBody) error
}

func NewS3CacheClient

func NewS3CacheClient(s3 *simples3.S3) CacheClient

type Derivation

type Derivation struct {

	// Args are arguments that are passed to the builder
	Args []string
	// Builder will either be set to a string constant to signify an internal
	// builder (like "fetch_url"), or it will be set to the path of an
	// executable in the bramble store
	Builder string
	// Env are environment variables set during the build
	Env map[string]string
	// Dependencies are derivations that are using as imports to this build,
	// outputs dependencies are tracked in the outputs
	Dependencies DerivationOutputs
	// Name is the name of the derivation
	Name string

	Network bool `json:",omitempty"`

	// Outputs are build outputs, a derivation can have many outputs, the
	// default output is called "out". Multiple outputs are useful when your
	// build process can produce multiple artifacts, but building them as a
	// standalone derivation would involve a complete rebuild.
	//
	// This attribute is removed when hashing the derivation.
	OutputNames []string
	Outputs     []Output

	// Platform is the platform we've built this derivation on
	Platform string

	Source Source

	// Target is the platform we've built this derivation for. If Target is
	// blank then the Platform value is the target.
	Target string `json:",omitempty"`
	// contains filtered or unexported fields
}

Derivation is the basic building block of a Bramble build

func (Derivation) BuildDependencyGraph

func (drv Derivation) BuildDependencyGraph() (graph *dag.AcyclicGraph, err error)

func (Derivation) Filename

func (drv Derivation) Filename() (filename string)

func (Derivation) Hash

func (drv Derivation) Hash() string

func (Derivation) JSON

func (drv Derivation) JSON() []byte

func (Derivation) PrettyJSON

func (drv Derivation) PrettyJSON() string

func (Derivation) RuntimeDependencyGraph

func (drv Derivation) RuntimeDependencyGraph() (graph *ds.AcyclicGraph, err error)

RuntimeDependencyGraph graphs the full dependency graph needed at runtime for all outputs. Includes all immediate dependencies and their dependencies

type DerivationOutput

type DerivationOutput struct {
	Filename   string
	OutputName string
	Output     string
}

DerivationOutput is one of the derivation inputs. Path is the location of the derivation, output is the name of the specific output this derivation uses for the build

type DerivationOutputs

type DerivationOutputs []DerivationOutput

func (DerivationOutputs) Len

func (dos DerivationOutputs) Len() int

func (DerivationOutputs) Less

func (dos DerivationOutputs) Less(i, j int) bool

func (DerivationOutputs) Swap

func (dos DerivationOutputs) Swap(i, j int)

type ExecError

type ExecError struct {
	Err  error
	Logs *os.File
}

func (ExecError) Error

func (err ExecError) Error() string

type NewDerivationOptions

type NewDerivationOptions struct {
	Args         []string
	Builder      string
	Env          map[string]string
	Dependencies DerivationOutputs
	Name         string
	Outputs      []string
	Platform     string
	Source       Source
	Target       string
	Network      bool
}

type Output

type Output struct {
	Path         string
	Dependencies []string
}

DerivationOutput tracks the build outputs. Outputs are not included in the Derivation hash. The path tracks the output location in the bramble store and Dependencies tracks the bramble outputs that are runtime dependencies.

func (Output) Empty

func (o Output) Empty() bool

type OutputRequestBody

type OutputRequestBody struct {
	Output Output
	TOC    []chunkedarchive.TOCEntry
}

type RunDerivationOptions

type RunDerivationOptions struct {
	Args    []string
	Network bool
	Stdin   io.Reader
	Dir     string

	Mounts        []string
	HiddenPaths   []string
	ReadOnlyPaths []string
}

type S3CacheClient

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

func (*S3CacheClient) PostChunk

func (cc *S3CacheClient) PostChunk(ctx context.Context, r io.Reader) (string, error)

func (*S3CacheClient) PostDerivation

func (cc *S3CacheClient) PostDerivation(ctx context.Context, drv Derivation) (string, error)

func (*S3CacheClient) PostOutput

func (cc *S3CacheClient) PostOutput(ctx context.Context, req OutputRequestBody) error

type Source

type Source struct {
	RelativeBuildPath string
	Path              string
}

type SourceFiles

type SourceFiles struct {
	ProjectLocation string
	Location        string
	Files           []string
}

type Store

type Store struct {
	BramblePath string
	StorePath   string
	// contains filtered or unexported fields
}

func NewStore

func NewStore(bramblePath string) (*Store, error)

func (*Store) CacheServer

func (s *Store) CacheServer() http.Handler

Uploads a derivation and all outputs Sources aren't uploaded Outputs are uploaded in 4mb body chunks

func (*Store) LoadDerivation

func (s *Store) LoadDerivation(filename string) (drv Derivation, found bool, err error)

func (*Store) NewBuilder

func (s *Store) NewBuilder(lockfileWriter types.LockfileWriter) *Builder

func (*Store) NewDerivation

func (s *Store) NewDerivation(options NewDerivationOptions) (exists bool, drv Derivation, err error)

func (*Store) RunDerivation

func (s *Store) RunDerivation(ctx context.Context, drv Derivation, opts RunDerivationOptions) (err error)

func (*Store) StoreLocalSources

func (s *Store) StoreLocalSources(ctx context.Context, sources SourceFiles) (out Source, err error)

func (*Store) UploadDerivationsToCache

func (s *Store) UploadDerivationsToCache(ctx context.Context, derivations []Derivation, cc CacheClient) (err error)

func (*Store) WriteBlob

func (s *Store) WriteBlob(src io.Reader) (hash string, err error)
func (s *Store) WriteConfigLink(location string) (err error)

func (*Store) WriteDerivation

func (s *Store) WriteDerivation(drv Derivation) (filename string, err error)

Jump to

Keyboard shortcuts

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