buildstore

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2015 License: BSD-3-Clause, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildDataDirName = ".srclib-cache"

BuildDataDirName is the name of the directory in which local repository build data is stored, relative to the top-level dir of a VCS repository.

View Source
var DataTypeNames = make(map[reflect.Type]string)
View Source
var DataTypes = make(map[string]interface{})
View Source
var FollowCrossFSSymlinks, _ = strconv.ParseBool(os.Getenv("SRCLIB_FOLLOW_CROSS_FS_SYMLINKS"))

FollowCrossFSSymlinks is whether symlinks inside a buildstore should be followed if they cross filesystem boundaries. This should only be true during testing. Setting it to true during normal operation could make it possible for an attacker who uploads symlinks to a build data store to read files on your local filesystem.

Functions

func BuildDataExistsForCommit added in v0.0.27

func BuildDataExistsForCommit(s RepoBuildStore, commitID string) (bool, error)

func DataType

func DataType(filename string) (string, interface{})

DataType returns the data type name and empty instance (previously registered with RegisterDataType) to use for a build data file named filename. If no registered data type is found for filename, "" and nil are returned.

For example, if a data type "foo.v0" was registered, a filename of "qux_foo.v0.json" would return "foo.v0" and the registered type.

func DataTypeSuffix

func DataTypeSuffix(data interface{}) string

func RegisterDataType

func RegisterDataType(name string, emptyInstance interface{})

RegisterDataType makes a build data type available by the provided name.

When serializing build data of a certain type, the corresponding type name is included in the file basename. When deserializing build data from files, the file basename is parsed to determine the data type to deserialize into. For example, a data type with name "foo.v0" and type Foo{} would result in files named "whatever.foo.v0.json" being written, and those files would deserialize into Foo{} structs.

The name should contain a version identifier so that types may be modified more easily; for example, name could be "graph.v0" (and a subsequent version could be registered as "graph.v1" with a different struct).

The emptyInstance should be an zero value of the type (usually a nil pointer to a struct, or a nil slice or map) that holds the build data; it is used to instantiate instances dynamically.

If RegisterDataType is called twice with the same type or type name, if name is empty, or if emptyInstance is nil, it panics

func RemoveAll added in v0.0.29

func RemoveAll(path string, vfs rwvfs.WalkableFileSystem) error

RemoveAll removes a tree recursively.

func RemoveAllDataForCommit added in v0.0.27

func RemoveAllDataForCommit(s RepoBuildStore, commitID string) error

RemoveAllDataForCommit removes all files and directories from the repo build store for the given commit.

Types

type MultiStore

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

A MultiStore contains RepoBuildStores for multiple repositories.

func NewMulti added in v0.0.27

func NewMulti(fs rwvfs.FileSystem) *MultiStore

NewMulti creates a new multi-repo build store.

func (*MultiStore) RepoBuildStore added in v0.0.27

func (s *MultiStore) RepoBuildStore(repoURI string) (RepoBuildStore, error)

type RepoBuildStore added in v0.0.27

type RepoBuildStore interface {
	// Commit returns a VFS for accessing and writing build data for a
	// specific commit.
	Commit(commitID string) rwvfs.WalkableFileSystem

	// FilePath returns the path (from the repo build store's root) to
	// a file at the specified commit ID.
	FilePath(commitID string, file string) string
}

A RepoBuildStore stores and exposes a repository's build data in a VFS.

func LocalRepo added in v0.0.27

func LocalRepo(repoDir string) (RepoBuildStore, error)

LocalRepo creates a new single-repository build store for the VCS repository whose top-level directory is repoDir.

The store is laid out as follows:

.                the root dir of repoStoreFS
<COMMITID>/**/*  build data for a specific commit

func Repo added in v0.0.27

func Repo(repoStoreFS rwvfs.WalkableFileSystem) RepoBuildStore

Repo creates a new single-repository build store rooted at the given filesystem.

Jump to

Keyboard shortcuts

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