server: go.chromium.org/goma/server/remoteexec/merkletree Index | Files

package merkletree

import "go.chromium.org/goma/server/remoteexec/merkletree"

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

see https://en.Wikipedia.org/wiki/Merkle_tree

Index

Package Files

merkletree.go

Variables

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")
)

type Entry Uses

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 Uses

type FilePath interface {
    IsAbs(path string) bool
    Join(elem ...string) string
    SplitElem(path string) []string
}

FilePath provides filepath functionalities.

type MerkleTree Uses

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

MerkleTree represents a merkle tree.

func New Uses

func New(filepath FilePath, rootDir string, store *digest.Store) *MerkleTree

New creates new merkle tree under rootDir with cas store.

func (*MerkleTree) Build Uses

func (m *MerkleTree) Build(ctx context.Context) (*rpb.Digest, error)

Build builds merkle tree and returns root's digest.

func (*MerkleTree) RootDir Uses

func (m *MerkleTree) RootDir() string

RootDir returns root dir of merkle tree.

func (*MerkleTree) Set Uses

func (m *MerkleTree) Set(entry Entry) error

Set sets an entry. It may return ErrAbsPath/ErrAmbigFileSymlink/ErrBadPath as error.

Package merkletree imports 9 packages (graph) and is imported by 1 packages. Updated 2019-09-21. Refresh now. Tools for package owners.