tool

package
v0.0.0-...-50b93e0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Overview

Package tool in this file provides functions that can be embedded into a go binary such that the binary now supports the various operations the remotetool supports (e.g., show_action, upload_blob, etc). A canonical usage of this library is the remotetool binary.

Package tool provides implementation of the debugging related operations supported by go/cmd/remotetool package.

Index

Constants

This section is empty.

Variables

View Source
var RemoteToolOperations = map[OpType]func(ctx context.Context, c *Client){
	// contains filtered or unexported fields
}

RemoteToolOperations maps each supported operation to a function that performs the operation.

View Source
var SupportedOps = []OpType{
	downloadActionResult,
	showAction,
	downloadAction,
	downloadBlob,
	downloadDir,
	executeAction,
	checkDeterminism,
	uploadBlob,
	uploadDir,
}

SupportedOps denote the list of operations supported by this remotetool.

Functions

func RegisterFlags

func RegisterFlags()

RegisterFlags registers the flags necessary for the embedded tool to work.

func ValidateFlags

func ValidateFlags()

ValidateFlags validates the command line flags associated with this embedded remote tool.

Types

type Client

type Client struct {
	GrpcClient *rc.Client
}

Client is a remote execution client.

func (*Client) CheckDeterminism

func (c *Client) CheckDeterminism(ctx context.Context, actionDigest, actionRoot string, attempts int) error

CheckDeterminism executes the action the given number of times and compares output digests, reporting failure if a mismatch is detected.

func (*Client) DownloadAction

func (c *Client) DownloadAction(ctx context.Context, actionDigest, outputPath string, overwrite bool) error

DownloadAction parses and downloads an action to the given directory. The output directory will have the following:

  1. ac.textproto: the action proto file in text format.
  2. cmd.textproto: the command proto file in text format.
  3. input/: the input tree root directory with all files under it.
  4. input_node_properties.txtproto: all the NodeProperties defined on the input tree, as an InputSpec proto file in text format. Will be omitted if no NodeProperties are defined.

func (*Client) DownloadActionResult

func (c *Client) DownloadActionResult(ctx context.Context, actionDigest, pathPrefix string) error

DownloadActionResult downloads the action result of the given action digest if it exists in the remote cache.

func (*Client) DownloadBlob

func (c *Client) DownloadBlob(ctx context.Context, blobDigest, path string) (string, error)

DownloadBlob downloads a blob from the remote cache into the specified path. If the path is empty, it writes the contents to stdout instead.

func (*Client) DownloadDirectory

func (c *Client) DownloadDirectory(ctx context.Context, rootDigest, path string) error

DownloadDirectory downloads a an input root from the remote cache into the specified path.

func (*Client) ExecuteAction

func (c *Client) ExecuteAction(ctx context.Context, actionDigest, actionRoot, outDir string, oe outerr.OutErr) (*command.Metadata, error)

ExecuteAction executes an action in a canonical structure remotely. The structure is the same as that produced by DownloadAction. top level >

> ac.textproto (Action text proto)
> cmd.textproto (Command text proto)
> input_node_properties.textproto (InputSpec text proto, optional)
> input (Input root)
  > inputs...

func (*Client) ShowAction

func (c *Client) ShowAction(ctx context.Context, actionDigest string) (string, error)

ShowAction parses and displays an action with its corresponding command.

func (*Client) UploadBlob

func (c *Client) UploadBlob(ctx context.Context, path string) error

UploadBlob uploads a blob from the specified path into the remote cache.

func (*Client) UploadBlobV2

func (c *Client) UploadBlobV2(ctx context.Context, path string) error

UploadBlobV2 uploads a blob from the specified path into the remote cache using newer cas implementation.

func (*Client) UploadDirectory

func (c *Client) UploadDirectory(ctx context.Context, path string) (*UploadStats, error)

UploadDirectory uploads a directory from the specified path as a Merkle-tree to the remote cache.

type OpType

type OpType string

OpType denotes the type of operation to perform.

type UploadStats

type UploadStats struct {
	rc.TreeStats
	RootDigest       digest.Digest
	CountBlobs       int64
	CountCacheMisses int64
	BytesTransferred int64
	BytesCacheMisses int64
	Error            string
}

UploadStats contains various metadata of a directory upload.

Jump to

Keyboard shortcuts

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