Documentation ¶
Overview ¶
Package merkletree operates on a merkle tree for remote execution API, https://github.com/bazelbuild/remote-apis/blob/c1c1ad2c97ed18943adb55f06657440daa60d833/build/bazel/remote/execution/v2/remote_execution.proto#L838
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrAbsPath indicates name in Entry is absulute path. ErrAbsPath = errors.New("merkletree: absolute path name") // ErrAmbigFileSymlink indicates Entry has both `Data` and `Target` fields, cannot determine // whether it is File or Symlink. ErrAmbigFileSymlink = errors.New("merkletree: unable to determine file vs symlink") // ErrBadPath indicates name in Entry contains bad path component // e.g. "." or "..". ErrBadPath = errors.New("merkletree: bad path component") )
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct { // Name is relative path from root dir. // it might not be clean path. // 'dir1/../dir2/file' will create // - 'dir1/' // - 'dir2/' // - 'dir2/file' // error if name goes out to root. Name string // Data is entry's content. `nil` for directories and symlinks. Data digest.Data // IsExecutable is true if the file is executable. // no need to set this for directory. IsExecutable bool // If the file is a symlink, then this should be set to the target of the symlink. Target string }
Entry is an entry in the tree.
type FilePath ¶
type FilePath interface { IsAbs(path string) bool Join(elem ...string) string SplitElem(path string) []string }
FilePath provides filepath functionalities.
type MerkleTree ¶
type MerkleTree struct {
// contains filtered or unexported fields
}
MerkleTree represents a merkle tree.
func New ¶
func New(filepath FilePath, rootDir string, store *digest.Store) *MerkleTree
New creates new merkle tree under rootDir with cas store.
func (*MerkleTree) RootDir ¶
func (m *MerkleTree) RootDir() string
RootDir returns root dir of merkle tree.
func (*MerkleTree) Set ¶
func (m *MerkleTree) Set(entry Entry) error
Set sets an entry. It may return ErrAbsPath/ErrAmbigFileSymlink/ErrBadPath as error.
Click to show internal directories.
Click to hide internal directories.