core

package
v0.0.0-...-8f74a99 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DaggerSockName = "dagger-sock"
	DaggerSockPath = "/dagger.sock"
)

Variables

View Source
var ErrHostRWDisabled = errors.New("host read/write is disabled")
View Source
var ErrInvalidCacheID = errors.New("invalid cache ID; create one using cacheVolume")

Functions

This section is empty.

Types

type CacheID

type CacheID string

CacheID is an arbitrary string typically derived from a set of token strings acting as the cache's "key" or "scope".

type CacheVolume

type CacheVolume struct {
	ID CacheID `json:"id"`
}

CacheVolume is a persistent volume with a globally scoped identifier.

func NewCache

func NewCache(keys ...string) (*CacheVolume, error)

func NewCacheFromID

func NewCacheFromID(id CacheID) (*CacheVolume, error)

func (*CacheVolume) WithKey

func (cache *CacheVolume) WithKey(key string) (*CacheVolume, error)

type Container

type Container struct {
	ID ContainerID `json:"id"`
}

Container is a content-addressed container.

func NewContainer

func NewContainer(id ContainerID, platform specs.Platform) (*Container, error)

func (*Container) Build

func (container *Container) Build(ctx context.Context, gw bkgw.Client, context *Directory, dockerfile string) (*Container, error)

func (*Container) Directory

func (container *Container) Directory(ctx context.Context, gw bkgw.Client, dirPath string) (*Directory, error)

func (*Container) Exec

func (container *Container) Exec(ctx context.Context, gw bkgw.Client, opts ContainerExecOpts) (*Container, error)

func (*Container) ExitCode

func (container *Container) ExitCode(ctx context.Context, gw bkgw.Client) (*int, error)

func (*Container) Export

func (container *Container) Export(
	ctx context.Context,
	host *Host,
	dest string,
	platformVariants []ContainerID,
	bkClient *bkclient.Client,
	solveOpts bkclient.SolveOpt,
	solveCh chan<- *bkclient.SolveStatus,
) error

func (*Container) FS

func (container *Container) FS(ctx context.Context) (*Directory, error)

func (*Container) File

func (container *Container) File(ctx context.Context, gw bkgw.Client, filePath string) (*File, error)

func (*Container) From

func (container *Container) From(ctx context.Context, gw bkgw.Client, addr string) (*Container, error)

func (*Container) ImageConfig

func (container *Container) ImageConfig(ctx context.Context) (specs.ImageConfig, error)

func (*Container) MetaFile

func (container *Container) MetaFile(ctx context.Context, gw bkgw.Client, filePath string) (*File, error)

func (*Container) Mounts

func (container *Container) Mounts(ctx context.Context) ([]string, error)

func (*Container) Platform

func (container *Container) Platform() (specs.Platform, error)

func (*Container) Publish

func (container *Container) Publish(
	ctx context.Context,
	ref string,
	platformVariants []ContainerID,
	bkClient *bkclient.Client,
	solveOpts bkclient.SolveOpt,
	solveCh chan<- *bkclient.SolveStatus,
) (string, error)

func (*Container) UpdateImageConfig

func (container *Container) UpdateImageConfig(ctx context.Context, updateFn func(specs.ImageConfig) specs.ImageConfig) (*Container, error)

func (*Container) WithFS

func (container *Container) WithFS(ctx context.Context, dir *Directory) (*Container, error)

func (*Container) WithMountedCache

func (container *Container) WithMountedCache(ctx context.Context, target string, cache CacheID, source *Directory) (*Container, error)

func (*Container) WithMountedDirectory

func (container *Container) WithMountedDirectory(ctx context.Context, target string, source *Directory) (*Container, error)

func (*Container) WithMountedFile

func (container *Container) WithMountedFile(ctx context.Context, target string, source *File) (*Container, error)

func (*Container) WithMountedSecret

func (container *Container) WithMountedSecret(ctx context.Context, target string, source *Secret) (*Container, error)

func (*Container) WithMountedTemp

func (container *Container) WithMountedTemp(ctx context.Context, target string) (*Container, error)

func (*Container) WithSecretVariable

func (container *Container) WithSecretVariable(ctx context.Context, name string, secret *Secret) (*Container, error)

func (*Container) WithoutMount

func (container *Container) WithoutMount(ctx context.Context, target string) (*Container, error)

type ContainerExecOpts

type ContainerExecOpts struct {
	// Command to run instead of the container's default command
	Args []string

	// Content to write to the command's standard input before closing
	Stdin string

	// Redirect the command's standard output to a file in the container
	RedirectStdout string

	// Redirect the command's standard error to a file in the container
	RedirectStderr string

	// Provide dagger access to the executed command
	// Do not use this option unless you trust the command being executed.
	// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM
	ExperimentalPrivilegedNesting bool
}

type ContainerID

type ContainerID string

ContainerID is an opaque value representing a content-addressed container.

type ContainerMount

type ContainerMount struct {
	// The source of the mount.
	Source *pb.Definition `json:"source,omitempty"`

	// A path beneath the source to scope the mount to.
	SourcePath string `json:"source_path,omitempty"`

	// The path of the mount within the container.
	Target string `json:"target"`

	// Persist changes to the mount under this cache ID.
	CacheID string `json:"cache_id,omitempty"`

	// How to share the cache across concurrent runs.
	CacheSharingMode string `json:"cache_sharing,omitempty"`

	// Configure the mount as a tmpfs.
	Tmpfs bool `json:"tmpfs,omitempty"`
}

ContainerMount is a mount point configured in a container.

func (ContainerMount) SourceState

func (mnt ContainerMount) SourceState() (llb.State, error)

SourceState returns the state of the source of the mount.

type ContainerMounts

type ContainerMounts []ContainerMount

func (ContainerMounts) With

type ContainerSecret

type ContainerSecret struct {
	Secret    SecretID `json:"secret"`
	EnvName   string   `json:"env,omitempty"`
	MountPath string   `json:"path,omitempty"`
}

ContainerSecret configures a secret to expose, either as an environment variable or mounted to a file path.

type CopyFilter

type CopyFilter struct {
	Exclude []string
	Include []string
}

type Directory

type Directory struct {
	ID DirectoryID `json:"id"`
}

Directory is a content-addressed directory.

func MergeDirectories

func MergeDirectories(ctx context.Context, dirs []*Directory, platform specs.Platform) (*Directory, error)

func NewDirectory

func NewDirectory(ctx context.Context, st llb.State, cwd string, platform specs.Platform) (*Directory, error)

func (*Directory) Diff

func (dir *Directory) Diff(ctx context.Context, other *Directory) (*Directory, error)

func (*Directory) Directory

func (dir *Directory) Directory(ctx context.Context, subdir string) (*Directory, error)

func (*Directory) Entries

func (dir *Directory) Entries(ctx context.Context, gw bkgw.Client, src string) ([]string, error)

func (*Directory) Export

func (dir *Directory) Export(
	ctx context.Context,
	host *Host,
	dest string,
	bkClient *bkclient.Client,
	solveOpts bkclient.SolveOpt,
	solveCh chan<- *bkclient.SolveStatus,
) error

func (*Directory) File

func (dir *Directory) File(ctx context.Context, file string) (*File, error)

func (*Directory) Stat

func (dir *Directory) Stat(ctx context.Context, gw bkgw.Client, src string) (*fstypes.Stat, error)

func (*Directory) WithDirectory

func (dir *Directory) WithDirectory(ctx context.Context, subdir string, src *Directory, filter CopyFilter) (*Directory, error)

func (*Directory) WithFile

func (dir *Directory) WithFile(ctx context.Context, subdir string, src *File) (*Directory, error)

func (*Directory) WithNewDirectory

func (dir *Directory) WithNewDirectory(ctx context.Context, gw bkgw.Client, dest string) (*Directory, error)

func (*Directory) WithNewFile

func (dir *Directory) WithNewFile(ctx context.Context, gw bkgw.Client, dest string, content []byte) (*Directory, error)

func (*Directory) Without

func (dir *Directory) Without(ctx context.Context, path string) (*Directory, error)

type DirectoryID

type DirectoryID string

DirectoryID is an opaque value representing a content-addressed directory.

func (DirectoryID) Decode

func (id DirectoryID) Decode() (*directoryIDPayload, error)

Decode returns the private payload of a DirectoryID.

NB(vito): Ideally this would not be exported, but it's currently needed for the project/ package. I left the return type private as a compromise.

type File

type File struct {
	ID FileID `json:"id"`
}

File is a content-addressed file.

func NewFile

func NewFile(ctx context.Context, st llb.State, file string, platform specs.Platform) (*File, error)

func (*File) Contents

func (file *File) Contents(ctx context.Context, gw bkgw.Client) ([]byte, error)

func (*File) Export

func (file *File) Export(
	ctx context.Context,
	host *Host,
	dest string,
	bkClient *bkclient.Client,
	solveOpts bkclient.SolveOpt,
	solveCh chan<- *bkclient.SolveStatus,
) error

func (*File) Secret

func (file *File) Secret(ctx context.Context) (*Secret, error)

func (*File) Stat

func (file *File) Stat(ctx context.Context, gw bkgw.Client) (*fstypes.Stat, error)

type FileID

type FileID string

FileID is an opaque value representing a content-addressed file.

type Host

type Host struct {
	Workdir   string
	DisableRW bool
}

func NewHost

func NewHost(workdir string, disableRW bool) *Host

func (*Host) Directory

func (host *Host) Directory(ctx context.Context, dirPath string, platform specs.Platform, filter CopyFilter) (*Directory, error)

func (*Host) Export

func (host *Host) Export(
	ctx context.Context,
	export bkclient.ExportEntry,
	dest string,
	bkClient *bkclient.Client,
	solveOpts bkclient.SolveOpt,
	solveCh chan<- *bkclient.SolveStatus,
	buildFn bkgw.BuildFunc,
) error

func (*Host) NormalizeDest

func (host *Host) NormalizeDest(dest string) (string, error)

type HostVariable

type HostVariable struct {
	Name string `json:"name"`
}

type Secret

type Secret struct {
	ID SecretID `json:"id"`
}

Secret is a content-addressed secret.

func NewSecret

func NewSecret(id SecretID) *Secret

func NewSecretFromFile

func NewSecretFromFile(fileID FileID) (*Secret, error)

func NewSecretFromHostEnv

func NewSecretFromHostEnv(name string) (*Secret, error)

func (*Secret) Plaintext

func (secret *Secret) Plaintext(ctx context.Context, gw bkgw.Client) ([]byte, error)

type SecretID

type SecretID string

SecretID is an opaque value representing a content-addressed secret.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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