workspace

package
v0.0.0-...-f1c34e1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DockerVolumeWorkspaceImage = "sourcegraph/src-batch-change-volume-workspace"

DockerVolumeWorkspaceImage is the Docker image we'll run our unzip and git commands in. This needs to match the name defined in .github/workflows/docker.yml.

Functions

func NewCreator

func NewCreator(ctx context.Context, preference, cacheDir, tempDir string, images map[string]docker.Image) (Creator, CreatorType)

Types

type Creator

type Creator interface {
	// Create creates a new workspace for the given repository and archive file.
	Create(ctx context.Context, repo *graphql.Repository, steps []batcheslib.Step, archive repozip.Archive) (Workspace, error)
}

Creator implementations are used to create workspaces, which manage per-changeset persistent storage when executing batch change steps and are responsible for ultimately generating a diff.

func NewExecutorWorkspaceCreator

func NewExecutorWorkspaceCreator(tempDir, repoDir string) Creator

type CreatorType

type CreatorType int
const (
	CreatorTypeBind CreatorType = iota
	CreatorTypeVolume
)

func BestCreatorType

func BestCreatorType(ctx context.Context, images map[string]docker.Image) CreatorType

BestCreatorType determines the correct workspace creator type to use based on the environment and batch change to be executed.

type Workspace

type Workspace interface {
	// DockerRunOpts provides the options that should be given to `docker run`
	// in order to use this workspace. Generally, this will be a set of mount
	// options.
	DockerRunOpts(ctx context.Context, target string) ([]string, error)

	// WorkDir allows workspaces to specify the working directory that should be
	// used when running Docker. If no specific working directory is needed,
	// then the function should return nil.
	WorkDir() *string

	// Close is called once, after all steps have been executed and the diff has
	// been calculated and stored outside the workspace. Implementations should
	// delete the workspace when Close is called.
	Close(ctx context.Context) error

	// Diff should return the total diff for the workspace. This may be called
	// multiple times in the life of a workspace.
	Diff(ctx context.Context) ([]byte, error)

	// ApplyDiff applies the given diff to the current workspace. Used when replaying
	// a cache entry onto the workspace.
	ApplyDiff(ctx context.Context, diff []byte) error
}

Workspace implementations manage per-changeset storage when executing batch change steps.

Jump to

Keyboard shortcuts

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