Documentation ¶
Index ¶
- Variables
- func BuildDataExistsForCommit(s RepoBuildStore, commitID string) (bool, error)
- func DataType(filename string) (string, interface{})
- func DataTypeSuffix(data interface{}) string
- func RegisterDataType(name string, emptyInstance interface{})
- func RemoveAll(path string, vfs rwvfs.WalkableFileSystem) error
- func RemoveAllDataForCommit(s RepoBuildStore, commitID string) error
- type MultiStore
- type RepoBuildStore
Constants ¶
This section is empty.
Variables ¶
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.
var DataTypeNames = make(map[reflect.Type]string)
var DataTypes = make(map[string]interface{})
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 ¶
func BuildDataExistsForCommit(s RepoBuildStore, commitID string) (bool, error)
func DataType ¶
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 ¶
func RemoveAll(path string, vfs rwvfs.WalkableFileSystem) error
RemoveAll removes a tree recursively.
func RemoveAllDataForCommit ¶
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 ¶
func NewMulti(fs rwvfs.FileSystem) *MultiStore
NewMulti creates a new multi-repo build store.
func (*MultiStore) RepoBuildStore ¶
func (s *MultiStore) RepoBuildStore(repoURI string) (RepoBuildStore, error)
type RepoBuildStore ¶
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 ¶
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 ¶
func Repo(repoStoreFS rwvfs.WalkableFileSystem) RepoBuildStore
Repo creates a new single-repository build store rooted at the given filesystem.