luci: go.chromium.org/luci/common/isolated Index | Files

package isolated

import "go.chromium.org/luci/common/isolated"

Package isolated defines the isolated common code shared by the client and server.

Index

Package Files

algo.go doc.go isolated.go utils.go

Constants

const Algorithm = "sha-1"

Algorithm is the value for Algo.

const IsolatedFormatVersion = "1.4"

IsolatedFormatVersion is version of *.isolated file format. Put into JSON.

func GetCompressor Uses

func GetCompressor(out io.Writer) (io.WriteCloser, error)

GetCompressor returns a fresh instance of the compression algorithm.

It must be closed after use.

It is currently hardcoded to RFC 1950 (zlib).

func GetDecompressor Uses

func GetDecompressor(in io.Reader) (io.ReadCloser, error)

GetDecompressor returns a fresh instance of the decompression algorithm.

It must be closed after use.

It is currently hardcoded to RFC 1950 (zlib).

func GetHash Uses

func GetHash() hash.Hash

GetHash returns a fresh instance of the hashing algorithm to be used to calculate the HexDigest.

It is currently hardcoded to sha-1.

func HashFile Uses

func HashFile(path string) (isolateservice.HandlersEndpointsV1Digest, error)

HashFile hashes a file and returns a HandlersEndpointsV1Digest out of it.

type File Uses

type File struct {
    Digest HexDigest `json:"h,omitempty"`
    Link   *string   `json:"l,omitempty"`
    Mode   *int      `json:"m,omitempty"`
    Size   *int64    `json:"s,omitempty"`
    Type   FileType  `json:"t,omitempty"`
}

File describes a single file referenced by content in a .isolated file.

For regular files, the Digest, Mode, and Size fields should be set, and the Type field should be set for non-basic files. For symbolic links, only the Link field should be set.

func BasicFile Uses

func BasicFile(d HexDigest, mode int, size int64) File

BasicFile returns a File populated for a basic file.

func SymLink(link string) File

SymLink returns a File populated for a symbolic link.

func TarFile Uses

func TarFile(d HexDigest, mode int, size int64) File

TarFile returns a file populated for a tar archive file.

type FileType Uses

type FileType string

FileType describes the type of file being isolated.

const (
    // Basic represents normal files. It is the default type.
    Basic FileType = "basic"

    // ArArchive represents an ar archive containing a large number of small files.
    ArArchive FileType = "ar"

    // TarArchive represents a tar archive containing a large number of small files.
    TarArchive FileType = "tar"
)

type HexDigest Uses

type HexDigest string

HexDigest is the hash of a file that is hex-encoded. Only lower case letters are accepted.

func Hash Uses

func Hash(src io.Reader) (HexDigest, error)

Hash hashes a reader and returns a HexDigest from it.

func HashBytes Uses

func HashBytes(content []byte) HexDigest

HashBytes hashes content and returns a HexDigest from it.

func Sum Uses

func Sum(h hash.Hash) HexDigest

Sum is a shortcut to get a HexDigest from a hash.Hash.

func (HexDigest) Validate Uses

func (d HexDigest) Validate() bool

Validate returns true if the hash is valid.

type HexDigests Uses

type HexDigests []HexDigest

HexDigests is a slice of HexDigest that implements sort.Interface.

func (HexDigests) Len Uses

func (h HexDigests) Len() int

func (HexDigests) Less Uses

func (h HexDigests) Less(i, j int) bool

func (HexDigests) Swap Uses

func (h HexDigests) Swap(i, j int)

type Isolated Uses

type Isolated struct {
    Algo        string          `json:"algo"` // Must be "sha-1"
    Command     []string        `json:"command,omitempty"`
    Files       map[string]File `json:"files,omitempty"`
    Includes    HexDigests      `json:"includes,omitempty"`
    ReadOnly    *ReadOnlyValue  `json:"read_only,omitempty"`
    RelativeCwd string          `json:"relative_cwd,omitempty"`
    Version     string          `json:"version"`
}

Isolated is the data from a JSON serialized .isolated file.

func New Uses

func New() *Isolated

New returns a new Isolated with the default Algo and Version.

type ReadOnlyValue Uses

type ReadOnlyValue int

ReadOnlyValue defines permissions on isolated files.

const (
    // Writeable means that both files and directories are writeable. This should
    // not be used.
    Writeable ReadOnlyValue = 0
    // FilesReadOnly means that files are read only but directories are
    // writeable. This permits the process executed to create temporary files in
    // the current directory. This is the recommended value and this is the
    // default value.
    FilesReadOnly ReadOnlyValue = 1
    // DirsReadOnly means that both files and directories are read-only. This
    // enforces strict no-junk policy that the process cannot create files in the
    // temporary mapped directory.
    DirsReadOnly ReadOnlyValue = 2
)

Package isolated imports 7 packages (graph) and is imported by 24 packages. Updated 2018-10-19. Refresh now. Tools for package owners.