core

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 60 Imported by: 1

Documentation

Index

Constants

View Source
const DetachGracePeriod = 10 * time.Second

DetachGracePeriod is an arbitrary amount of time between when a service is no longer actively used and before it is detached. This is to avoid repeated stopping and re-starting of the same service in rapid succession.

View Source
const (
	ShimEnableTTYEnvVar = "_DAGGER_ENABLE_TTY"
)

Variables

View Source
var ErrCacheMapRecursiveCall = fmt.Errorf("recursive call detected")
View Source
var ErrContainerNoExec = errors.New("no command has been executed")
View Source
var ErrInvalidCacheVolumeID = errors.New("invalid cache ID; create one using cacheVolume")
View Source
var SeenCacheKeys = new(sync.Map)

Functions

func AddEnv added in v0.6.0

func AddEnv(env []string, name, value string) []string

AddEnv adds or updates an environment variable in 'env'.

func LoadModuleConfig added in v0.9.0

func LoadModuleConfig(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	sourceDir *Directory,
	configPath string,
) (string, *modules.Config, error)

Load the module config from the module from the given diretory at the given path

func LoadModuleConfigFromFile added in v0.9.0

func LoadModuleConfigFromFile(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	configFile *File,
) (*modules.Config, error)

Load the module config as parsed from the given File

func LookupEnv added in v0.6.0

func LookupEnv(env []string, name string) (string, bool)

LookupEnv returns the value of an environment variable.

func WalkEnv added in v0.6.0

func WalkEnv(env []string, fn func(string, string, string))

WalkEnv iterates over all environment variables with parsed key and value, and original string.

Types

type AliasSet added in v0.3.13

type AliasSet []string

func (AliasSet) String added in v0.3.13

func (set AliasSet) String() string

func (AliasSet) Union added in v0.8.5

func (set AliasSet) Union(other AliasSet) AliasSet

func (AliasSet) With added in v0.3.13

func (set AliasSet) With(alias string) AliasSet

type BuildArg added in v0.3.8

type BuildArg struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type CacheMap added in v0.8.0

type CacheMap[K comparable, T any] struct {
	// contains filtered or unexported fields
}

func NewCacheMap added in v0.8.0

func NewCacheMap[K comparable, T any]() *CacheMap[K, T]

func (*CacheMap[K, T]) Get added in v0.9.4

func (m *CacheMap[K, T]) Get(ctx context.Context, key K) (T, error)

func (*CacheMap[K, T]) GetOrInitialize added in v0.8.0

func (m *CacheMap[K, T]) GetOrInitialize(ctx context.Context, key K, fn func(ctx context.Context) (T, error)) (T, error)

type CacheSharingMode added in v0.3.12

type CacheSharingMode string

CacheSharingMode is a string deriving from CacheSharingMode enum it can take values: SHARED, PRIVATE, LOCKED

const (
	CacheSharingModeShared  CacheSharingMode = "SHARED"
	CacheSharingModePrivate CacheSharingMode = "PRIVATE"
	CacheSharingModeLocked  CacheSharingMode = "LOCKED"
)

func (CacheSharingMode) MarshalJSON added in v0.9.0

func (mode CacheSharingMode) MarshalJSON() ([]byte, error)

CacheSharingMode marshals to its lowercased value.

NB: as far as I can recall this is purely for ~*aesthetic*~. GraphQL consts are so shouty!

func (*CacheSharingMode) UnmarshalJSON added in v0.9.0

func (mode *CacheSharingMode) UnmarshalJSON(payload []byte) error

CacheSharingMode marshals to its lowercased value.

NB: as far as I can recall this is purely for ~*aesthetic*~. GraphQL consts are so shouty!

type CacheVolume

type CacheVolume struct {
	Keys []string `json:"keys"`
}

CacheVolume is a persistent volume with a globally scoped identifier.

func NewCache

func NewCache(keys ...string) *CacheVolume

func (*CacheVolume) Clone added in v0.5.1

func (cache *CacheVolume) Clone() *CacheVolume

func (*CacheVolume) Digest added in v0.8.8

func (cache *CacheVolume) Digest() (digest.Digest, error)

func (*CacheVolume) ID

func (cache *CacheVolume) ID() (CacheVolumeID, error)

func (*CacheVolume) Sum added in v0.5.1

func (cache *CacheVolume) Sum() string

Sum returns a checksum of the cache tokens suitable for use as a cache key.

func (*CacheVolume) WithKey

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

type CacheVolumeID added in v0.9.0

type CacheVolumeID = resourceid.ID[CacheVolume]

type CallInput added in v0.8.8

type CallInput struct {
	Name  string `json:"name"`
	Value any    `json:"value"`
}

func (*CallInput) Digest added in v0.9.4

func (callInput *CallInput) Digest() (digest.Digest, error)

type Container

type Container struct {
	// The container's root filesystem.
	FS *pb.Definition `json:"fs"`

	// Image configuration (env, workdir, etc)
	Config specs.ImageConfig `json:"cfg"`

	// List of GPU devices that will be exposed to the container
	EnabledGPUs []string `json:"enabledGPUs,omitempty"`

	// Pipeline
	Pipeline pipeline.Path `json:"pipeline"`

	// Mount points configured for the container.
	Mounts ContainerMounts `json:"mounts,omitempty"`

	// Meta is the /dagger filesystem. It will be null if nothing has run yet.
	Meta *pb.Definition `json:"meta,omitempty"`

	// The platform of the container's rootfs.
	Platform specs.Platform `json:"platform,omitempty"`

	// Secrets to expose to the container.
	Secrets []ContainerSecret `json:"secret_env,omitempty"`

	// Sockets to expose to the container.
	Sockets []ContainerSocket `json:"sockets,omitempty"`

	// Image reference
	ImageRef string `json:"image_ref,omitempty"`

	// Ports to expose from the container.
	Ports []Port `json:"ports,omitempty"`

	// Services to start before running the container.
	Services ServiceBindings `json:"services,omitempty"`

	// Focused indicates whether subsequent operations will be
	// focused, i.e. shown more prominently in the UI.
	Focused bool `json:"focused"`
}

Container is a content-addressed container.

func NewContainer added in v0.3.3

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

func (*Container) AsTarball added in v0.9.0

func (container *Container) AsTarball(
	ctx context.Context,
	bk *buildkit.Client,
	engineHostPlatform specs.Platform,
	svcs *Services,
	platformVariants []ContainerID,
	forcedCompression ImageLayerCompression,
	mediaTypes ImageMediaTypes,
) (*File, error)

func (*Container) Build

func (container *Container) Build(
	ctx context.Context,
	contextDir *Directory,
	dockerfile string,
	buildArgs []BuildArg,
	target string,
	secrets []SecretID,
	bk *buildkit.Client,
	svcs *Services,
	buildCache *CacheMap[uint64, *Container],
) (*Container, error)

func (*Container) Clone added in v0.5.1

func (container *Container) Clone() *Container

Clone returns a deep copy of the container suitable for modifying in a WithXXX method.

func (*Container) Digest added in v0.5.2

func (container *Container) Digest() (digest.Digest, error)

Digest returns the container's content hash.

func (*Container) Directory

func (container *Container) Directory(ctx context.Context, bk *buildkit.Client, svcs *Services, dirPath string) (*Directory, error)

func (*Container) Evaluate added in v0.3.13

func (container *Container) Evaluate(ctx context.Context, bk *buildkit.Client, svcs *Services) (*buildkit.Result, error)

func (*Container) Export added in v0.3.3

func (container *Container) Export(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	dest string,
	platformVariants []ContainerID,
	forcedCompression ImageLayerCompression,
	mediaTypes ImageMediaTypes,
) error

func (*Container) FSState added in v0.5.1

func (container *Container) FSState() (llb.State, error)

FSState returns the container's root filesystem mount state. If there is none (as with an empty container ID), it returns scratch.

func (*Container) File

func (container *Container) File(ctx context.Context, bk *buildkit.Client, svcs *Services, filePath string) (*File, error)

func (*Container) From

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

func (*Container) ID

func (container *Container) ID() (ContainerID, error)

ID marshals the container into a content-addressed ID.

func (*Container) ImageConfig

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

func (*Container) ImageRefOrErr added in v0.5.1

func (container *Container) ImageRefOrErr(ctx context.Context, bk *buildkit.Client) (string, error)

func (*Container) Import added in v0.5.0

func (container *Container) Import(
	ctx context.Context,
	source FileID,
	tag string,
	bk *buildkit.Client,
	host *Host,
	svcs *Services,
	importCache *CacheMap[uint64, *specs.Descriptor],
	store content.Store,
	lm *leaseutil.Manager,
) (*Container, error)

func (*Container) MetaFileContents added in v0.3.5

func (container *Container) MetaFileContents(ctx context.Context, bk *buildkit.Client, svcs *Services, progSock string, filePath string) (string, error)

func (*Container) MetaState added in v0.5.1

func (container *Container) MetaState() (*llb.State, error)

MetaState returns the container's metadata mount state. If the container has yet to run, it returns nil.

func (*Container) MountTargets added in v0.5.1

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

func (*Container) PBDefinitions added in v0.8.8

func (container *Container) PBDefinitions() ([]*pb.Definition, error)

func (*Container) PipelinePath added in v0.5.2

func (container *Container) PipelinePath() pipeline.Path

PipelinePath returns the container's pipeline path.

func (*Container) Publish

func (container *Container) Publish(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	ref string,
	platformVariants []ContainerID,
	forcedCompression ImageLayerCompression,
	mediaTypes ImageMediaTypes,
) (string, error)

func (*Container) RootFS added in v0.3.5

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

func (*Container) Service added in v0.8.5

func (container *Container) Service(ctx context.Context, bk *buildkit.Client, progSock string) (*Service, error)

func (*Container) ShellEndpoint added in v0.8.8

func (container *Container) ShellEndpoint(bk *buildkit.Client, progSock string, svcs *Services) (string, http.Handler, error)

func (*Container) UpdateImageConfig

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

func (*Container) WithDirectory added in v0.3.7

func (container *Container) WithDirectory(ctx context.Context, bk *buildkit.Client, subdir string, src *Directory, filter CopyFilter, owner string) (*Container, error)

func (*Container) WithExec added in v0.3.13

func (container *Container) WithExec(ctx context.Context, bk *buildkit.Client, progSock string, defaultPlatform specs.Platform, opts ContainerExecOpts) (*Container, error)

func (*Container) WithExposedPort added in v0.3.13

func (container *Container) WithExposedPort(port Port) (*Container, error)

func (*Container) WithFile added in v0.3.7

func (container *Container) WithFile(ctx context.Context, bk *buildkit.Client, destPath string, src *File, permissions fs.FileMode, owner string) (*Container, error)

func (*Container) WithGPU added in v0.9.2

func (container *Container) WithGPU(ctx context.Context, gpuOpts ContainerGPUOpts) (*Container, error)

func (*Container) WithMountedCache

func (container *Container) WithMountedCache(ctx context.Context, bk *buildkit.Client, target string, cache *CacheVolume, source *Directory, sharingMode CacheSharingMode, owner string) (*Container, error)

func (*Container) WithMountedDirectory

func (container *Container) WithMountedDirectory(ctx context.Context, bk *buildkit.Client, target string, dir *Directory, owner string, readonly bool) (*Container, error)

func (*Container) WithMountedFile

func (container *Container) WithMountedFile(ctx context.Context, bk *buildkit.Client, target string, file *File, owner string, readonly bool) (*Container, error)

func (*Container) WithMountedSecret

func (container *Container) WithMountedSecret(ctx context.Context, bk *buildkit.Client, target string, source *Secret, owner string, mode *int) (*Container, error)

func (*Container) WithMountedTemp

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

func (*Container) WithNewFile added in v0.3.7

func (container *Container) WithNewFile(ctx context.Context, bk *buildkit.Client, dest string, content []byte, permissions fs.FileMode, owner string) (*Container, error)

func (*Container) WithPipeline added in v0.5.1

func (container *Container) WithPipeline(ctx context.Context, name, description string, labels []pipeline.Label) (*Container, error)

func (*Container) WithRootFS added in v0.3.5

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

func (*Container) WithSecretVariable

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

func (*Container) WithServiceBinding added in v0.5.0

func (container *Container) WithServiceBinding(ctx context.Context, svcs *Services, svc *Service, alias string) (*Container, error)

func (*Container) WithUnixSocket added in v0.3.7

func (container *Container) WithUnixSocket(ctx context.Context, bk *buildkit.Client, target string, source *socket.Socket, owner string) (*Container, error)

func (*Container) WithoutExposedPort added in v0.3.13

func (container *Container) WithoutExposedPort(port int, protocol NetworkProtocol) (*Container, error)

func (*Container) WithoutMount

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

func (*Container) WithoutUnixSocket added in v0.3.7

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

type ContainerExecOpts

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

	// If the container has an entrypoint, ignore it for this exec rather than
	// calling it with args.
	SkipEntrypoint bool

	// 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

	// Grant the process all root capabilities
	InsecureRootCapabilities bool

	// (Internal-only) If this exec is for a module function, this digest will be set in the
	// grpc context metadata for any api requests back to the engine. It's used by the API
	// server to determine which schema to serve and other module context metadata.
	ModuleCallerDigest digest.Digest

	// (Internal-only) Used for module function execs to trigger the nested api client to
	// be connected back to the same session.
	NestedInSameSession bool
}

type ContainerGPUOpts added in v0.9.2

type ContainerGPUOpts struct {
	Devices []string `json:"devices"`
}

type ContainerID

type ContainerID = resourceid.ID[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.
	CacheVolumeID string `json:"cache_volume_id,omitempty"`

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

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

	// Configure the mount as read-only.
	Readonly bool `json:"readonly,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 added in v0.3.3

type ContainerMounts []ContainerMount

func (ContainerMounts) With added in v0.3.3

type ContainerSecret

type ContainerSecret struct {
	Secret    SecretID   `json:"secret"`
	EnvName   string     `json:"env,omitempty"`
	MountPath string     `json:"path,omitempty"`
	Owner     *Ownership `json:"owner,omitempty"`
	Mode      *int       `json:"mode,omitempty"`
}

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

type ContainerSocket added in v0.3.7

type ContainerSocket struct {
	SocketID socket.ID  `json:"socket"`
	UnixPath string     `json:"unix_path,omitempty"`
	Owner    *Ownership `json:"owner,omitempty"`
}

ContainerSocket configures a socket to expose, currently as a Unix socket, but potentially as a TCP or UDP address in the future.

type CopyFilter added in v0.3.3

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

type Directory

type Directory struct {
	LLB      *pb.Definition `json:"llb"`
	Dir      string         `json:"dir"`
	Platform specs.Platform `json:"platform"`
	Pipeline pipeline.Path  `json:"pipeline"`

	// Services necessary to provision the directory.
	Services ServiceBindings `json:"services,omitempty"`
}

Directory is a content-addressed directory.

func NewDirectory

func NewDirectory(ctx context.Context, def *pb.Definition, dir string, pipeline pipeline.Path, platform specs.Platform, services ServiceBindings) *Directory

func NewDirectorySt added in v0.5.2

func NewDirectorySt(ctx context.Context, st llb.State, dir string, pipeline pipeline.Path, platform specs.Platform, services ServiceBindings) (*Directory, error)

func NewScratchDirectory added in v0.6.3

func NewScratchDirectory(pipeline pipeline.Path, platform specs.Platform) *Directory

func (*Directory) Clone added in v0.5.1

func (dir *Directory) Clone() *Directory

Clone returns a deep copy of the container suitable for modifying in a WithXXX method.

func (*Directory) Diff

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

func (*Directory) Digest added in v0.5.2

func (dir *Directory) Digest() (digest.Digest, error)

Digest returns the directory's content hash.

func (*Directory) Directory

func (dir *Directory) Directory(ctx context.Context, bk *buildkit.Client, svcs *Services, subdir string) (*Directory, error)

func (*Directory) Entries

func (dir *Directory) Entries(ctx context.Context, bk *buildkit.Client, svcs *Services, src string) ([]string, error)

func (*Directory) Evaluate added in v0.6.4

func (dir *Directory) Evaluate(ctx context.Context, bk *buildkit.Client, svcs *Services) (*buildkit.Result, error)

func (*Directory) Export added in v0.3.3

func (dir *Directory) Export(
	ctx context.Context,
	bk *buildkit.Client,
	host *Host,
	svcs *Services,
	destPath string,
) (rerr error)

func (*Directory) File

func (dir *Directory) File(ctx context.Context, bk *buildkit.Client, svcs *Services, file string) (*File, error)

func (*Directory) Glob added in v0.9.1

func (dir *Directory) Glob(ctx context.Context, bk *buildkit.Client, svcs *Services, src string, pattern string) ([]string, error)

Glob returns a list of files that matches the given pattern.

Note(TomChv): Instead of handling the recursive manually, we could update cacheutil.ReadDir so it will only mount and unmount the filesystem one time. However, this requires to maintain buildkit code and is not mandatory for now until we hit performances issues.

func (*Directory) ID

func (dir *Directory) ID() (DirectoryID, error)

func (*Directory) PBDefinitions added in v0.8.8

func (dir *Directory) PBDefinitions() ([]*pb.Definition, error)

func (*Directory) PipelinePath added in v0.5.2

func (dir *Directory) PipelinePath() pipeline.Path

func (*Directory) Root added in v0.5.1

func (dir *Directory) Root() (*Directory, error)

Root removes any relative path from the directory.

func (*Directory) SetState added in v0.5.1

func (dir *Directory) SetState(ctx context.Context, st llb.State) error

func (*Directory) Stat

func (dir *Directory) Stat(ctx context.Context, bk *buildkit.Client, svcs *Services, src string) (*fstypes.Stat, error)

func (*Directory) State added in v0.5.1

func (dir *Directory) State() (llb.State, error)

func (*Directory) StateWithSourcePath added in v0.5.1

func (dir *Directory) StateWithSourcePath() (llb.State, error)

func (*Directory) WithDirectory

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

func (*Directory) WithFile added in v0.3.3

func (dir *Directory) WithFile(ctx context.Context, destPath string, src *File, permissions fs.FileMode, owner *Ownership) (*Directory, error)

func (*Directory) WithNewDirectory added in v0.3.3

func (dir *Directory) WithNewDirectory(ctx context.Context, dest string, permissions fs.FileMode) (*Directory, error)

func (*Directory) WithNewFile

func (dir *Directory) WithNewFile(ctx context.Context, dest string, content []byte, permissions fs.FileMode, ownership *Ownership) (*Directory, error)

func (*Directory) WithPipeline added in v0.5.1

func (dir *Directory) WithPipeline(ctx context.Context, name, description string, labels []pipeline.Label) (*Directory, error)

func (*Directory) WithTimestamps added in v0.3.8

func (dir *Directory) WithTimestamps(ctx context.Context, unix int) (*Directory, error)

func (*Directory) Without

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

type DirectoryID

type DirectoryID = resourceid.ID[Directory]

type FieldTypeDef added in v0.8.8

type FieldTypeDef struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	TypeDef     *TypeDef `json:"typeDef"`

	// The original name of the object as provided by the SDK that defined it, used
	// when invoking the SDK so it doesn't need to think as hard about case conversions
	OriginalName string `json:"originalName,omitempty"`
}

func (FieldTypeDef) Clone added in v0.8.8

func (typeDef FieldTypeDef) Clone() *FieldTypeDef

type File

type File struct {
	LLB      *pb.Definition `json:"llb"`
	File     string         `json:"file"`
	Pipeline pipeline.Path  `json:"pipeline"`
	Platform specs.Platform `json:"platform"`

	// Services necessary to provision the file.
	Services ServiceBindings `json:"services,omitempty"`
}

File is a content-addressed file.

func NewFile

func NewFile(ctx context.Context, def *pb.Definition, file string, pipeline pipeline.Path, platform specs.Platform, services ServiceBindings) *File

func NewFileSt added in v0.5.2

func NewFileSt(ctx context.Context, st llb.State, dir string, pipeline pipeline.Path, platform specs.Platform, services ServiceBindings) (*File, error)

func NewFileWithContents added in v0.9.2

func NewFileWithContents(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	name string,
	content []byte,
	permissions fs.FileMode,
	ownership *Ownership,
	pipeline pipeline.Path,
	platform specs.Platform,
) (*File, error)

func (*File) Clone added in v0.5.1

func (file *File) Clone() *File

Clone returns a deep copy of the container suitable for modifying in a WithXXX method.

func (*File) Contents

func (file *File) Contents(ctx context.Context, bk *buildkit.Client, svcs *Services) ([]byte, error)

Contents handles file content retrieval

func (*File) Digest added in v0.5.2

func (file *File) Digest() (digest.Digest, error)

Digest returns the file's content hash.

func (*File) Evaluate added in v0.6.4

func (file *File) Evaluate(ctx context.Context, bk *buildkit.Client, svcs *Services) error

func (*File) Export added in v0.3.3

func (file *File) Export(
	ctx context.Context,
	bk *buildkit.Client,
	host *Host,
	svcs *Services,
	dest string,
	allowParentDirPath bool,
) error

func (*File) ID

func (file *File) ID() (FileID, error)

ID marshals the file into a content-addressed ID.

func (*File) Open added in v0.5.0

func (file *File) Open(ctx context.Context, host *Host, bk *buildkit.Client, svcs *Services) (io.ReadCloser, error)

func (*File) PBDefinitions added in v0.8.8

func (file *File) PBDefinitions() ([]*pb.Definition, error)

func (*File) PipelinePath added in v0.5.2

func (file *File) PipelinePath() pipeline.Path

func (*File) Stat

func (file *File) Stat(ctx context.Context, bk *buildkit.Client, svcs *Services) (*fstypes.Stat, error)

func (*File) State added in v0.5.1

func (file *File) State() (llb.State, error)

func (*File) WithTimestamps added in v0.3.8

func (file *File) WithTimestamps(ctx context.Context, unix int) (*File, error)

type FileID

type FileID = resourceid.ID[File]

type Function added in v0.8.8

type Function struct {
	// Name is the standardized name of the function (lowerCamelCase), as used for the resolver in the graphql schema
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Args        []*FunctionArg `json:"args"`
	ReturnType  *TypeDef       `json:"returnType"`

	// OriginalName of the parent object
	ParentOriginalName string `json:"parentOriginalName,omitempty"`

	// The original name of the function as provided by the SDK that defined it, used
	// when invoking the SDK so it doesn't need to think as hard about case conversions
	OriginalName string `json:"originalName,omitempty"`
}

func NewFunction added in v0.8.8

func NewFunction(name string, returnType *TypeDef) *Function

func (Function) Clone added in v0.8.8

func (fn Function) Clone() *Function

func (*Function) Digest added in v0.8.8

func (fn *Function) Digest() (digest.Digest, error)

func (*Function) ID added in v0.8.8

func (fn *Function) ID() (FunctionID, error)

func (*Function) WithArg added in v0.8.8

func (fn *Function) WithArg(name string, typeDef *TypeDef, desc string, defaultValue any) *Function

func (*Function) WithDescription added in v0.8.8

func (fn *Function) WithDescription(desc string) *Function

type FunctionArg added in v0.8.8

type FunctionArg struct {
	// Name is the standardized name of the argument (lowerCamelCase), as used for the resolver in the graphql schema
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	TypeDef      *TypeDef `json:"typeDef"`
	DefaultValue any      `json:"defaultValue"`

	// The original name of the argument as provided by the SDK that defined it.
	OriginalName string `json:"originalName,omitempty"`
}

func (FunctionArg) Clone added in v0.8.8

func (arg FunctionArg) Clone() *FunctionArg

func (*FunctionArg) ID added in v0.9.4

func (arg *FunctionArg) ID() (FunctionArgID, error)

type FunctionArgID added in v0.9.4

type FunctionArgID = resourceid.ID[FunctionArg]

type FunctionCall added in v0.8.8

type FunctionCall struct {
	Name       string       `json:"name"`
	ParentName string       `json:"parentName"`
	Parent     any          `json:"parent"`
	InputArgs  []*CallInput `json:"inputArgs"`
}

func (*FunctionCall) Digest added in v0.8.8

func (fnCall *FunctionCall) Digest() (digest.Digest, error)

type FunctionID added in v0.8.8

type FunctionID = resourceid.ID[Function]

type GeneratedCode added in v0.8.8

type GeneratedCode struct {
	Code              *Directory `json:"code"`
	VCSIgnoredPaths   []string   `json:"vcsIgnoredPaths,omitempty"`
	VCSGeneratedPaths []string   `json:"vcsGeneratedPaths,omitempty"`
}

func NewGeneratedCode added in v0.9.0

func NewGeneratedCode(code *Directory) *GeneratedCode

func (GeneratedCode) Clone added in v0.8.8

func (code GeneratedCode) Clone() *GeneratedCode

func (*GeneratedCode) Digest added in v0.8.8

func (code *GeneratedCode) Digest() (digest.Digest, error)

func (*GeneratedCode) ID added in v0.8.8

func (code *GeneratedCode) ID() (GeneratedCodeID, error)

func (*GeneratedCode) WithVCSGeneratedPaths added in v0.8.8

func (code *GeneratedCode) WithVCSGeneratedPaths(paths []string) *GeneratedCode

func (*GeneratedCode) WithVCSIgnoredPaths added in v0.8.8

func (code *GeneratedCode) WithVCSIgnoredPaths(paths []string) *GeneratedCode

type GeneratedCodeID added in v0.8.8

type GeneratedCodeID = resourceid.ID[GeneratedCode]

type GitRef added in v0.9.1

type GitRef struct {
	Ref  string         `json:"ref"`
	Repo *GitRepository `json:"repository"`
}

func (*GitRef) Commit added in v0.9.1

func (ref *GitRef) Commit(ctx context.Context, bk *buildkit.Client) (string, error)

func (*GitRef) ID added in v0.9.4

func (ref *GitRef) ID() (GitRefID, error)

func (*GitRef) Tree added in v0.9.1

func (ref *GitRef) Tree(ctx context.Context, bk *buildkit.Client) (*Directory, error)

type GitRefID added in v0.9.4

type GitRefID = resourceid.ID[GitRef]

type GitRepository added in v0.9.4

type GitRepository struct {
	URL string `json:"url"`

	KeepGitDir bool `json:"keepGitDir"`

	SSHKnownHosts string    `json:"sshKnownHosts"`
	SSHAuthSocket socket.ID `json:"sshAuthSocket"`

	Services ServiceBindings `json:"services"`
	Pipeline pipeline.Path   `json:"pipeline"`
	Platform specs.Platform  `json:"platform,omitempty"`
}

func (*GitRepository) ID added in v0.9.4

func (repo *GitRepository) ID() (GitRepositoryID, error)

type GitRepositoryID added in v0.9.4

type GitRepositoryID = resourceid.ID[GitRepository]

type HasPBDefinitions added in v0.8.8

type HasPBDefinitions interface {
	PBDefinitions() ([]*pb.Definition, error)
}

type Host added in v0.3.3

type Host struct {
}

func NewHost added in v0.3.3

func NewHost() *Host

func (*Host) Directory added in v0.3.3

func (host *Host) Directory(
	ctx context.Context,
	bk *buildkit.Client,
	dirPath string,
	p pipeline.Path,
	pipelineNamePrefix string,
	platform specs.Platform,
	filter CopyFilter,
) (*Directory, error)

func (*Host) File added in v0.6.2

func (host *Host) File(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	path string,
	p pipeline.Path,
	platform specs.Platform,
) (*File, error)

func (*Host) Socket added in v0.3.7

func (host *Host) Socket(ctx context.Context, sockPath string) (*socket.Socket, error)

type ImageLayerCompression added in v0.5.3

type ImageLayerCompression string
const (
	CompressionGzip         ImageLayerCompression = "Gzip"
	CompressionZstd         ImageLayerCompression = "Zstd"
	CompressionEStarGZ      ImageLayerCompression = "EStarGZ"
	CompressionUncompressed ImageLayerCompression = "Uncompressed"
)

type ImageMediaTypes added in v0.6.4

type ImageMediaTypes string
const (
	OCIMediaTypes    ImageMediaTypes = "OCIMediaTypes"
	DockerMediaTypes ImageMediaTypes = "DockerMediaTypes"
)

type ListTypeDef added in v0.8.8

type ListTypeDef struct {
	ElementTypeDef *TypeDef `json:"elementTypeDef"`
}

func (ListTypeDef) Clone added in v0.8.8

func (typeDef ListTypeDef) Clone() *ListTypeDef

type Module added in v0.8.8

type Module struct {
	// The module's source code root directory
	SourceDirectory *Directory `json:"sourceDirectory"`

	// If set, the subdir of the SourceDirectory that contains the module's source code
	SourceDirectorySubpath string `json:"sourceDirectorySubpath"`

	// The name of the module
	Name string `json:"name"`

	// The doc string of the module, if any
	Description string `json:"description"`

	// Dependencies as configured by the module
	DependencyConfig []string `json:"dependencyConfig"`

	// The module's objects
	Objects []*TypeDef `json:"objects,omitempty"`

	// The module's SDK, as set in the module config file
	SDK string `json:"sdk,omitempty"`
}

func ModuleFromConfig added in v0.9.4

func ModuleFromConfig(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	sourceDir *Directory,
	configPath string,
) (*Module, error)

ModuleFromConfig creates a Module from a dagger.json config file.

func ModuleFromRef added in v0.9.4

func ModuleFromRef(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	pipeline pipeline.Path,
	platform ocispecs.Platform,
	parentSrcDir *Directory,
	parentSrcSubpath string,
	moduleRefStr string,
) (*Module, error)

Load the module metadata from the given module reference. parentSrcDir and parentSrcSubpath are used to resolve local module refs if needed (i.e. this is a local dep of another module)

func (*Module) BaseDigest added in v0.9.2

func (mod *Module) BaseDigest() (digest.Digest, error)

BaseDigest gives a digest after unsetting Objects, which is useful as a digest of the "base" Module that's stable before+after loading TypeDefs

func (Module) Clone added in v0.8.8

func (mod Module) Clone() *Module

func (*Module) Digest added in v0.8.8

func (mod *Module) Digest() (digest.Digest, error)

func (*Module) ID added in v0.8.8

func (mod *Module) ID() (ModuleID, error)

func (*Module) PBDefinitions added in v0.8.8

func (mod *Module) PBDefinitions() ([]*pb.Definition, error)

func (*Module) WithObject added in v0.8.8

func (mod *Module) WithObject(def *TypeDef) (*Module, error)

type ModuleID added in v0.8.8

type ModuleID = resourceid.ID[Module]

type NetworkProtocol added in v0.3.13

type NetworkProtocol string

NetworkProtocol is a string deriving from NetworkProtocol enum

const (
	NetworkProtocolTCP NetworkProtocol = "TCP"
	NetworkProtocolUDP NetworkProtocol = "UDP"
)

func (NetworkProtocol) EnumName added in v0.8.5

func (proto NetworkProtocol) EnumName() string

func (NetworkProtocol) Network added in v0.3.13

func (proto NetworkProtocol) Network() string

Network returns the value appropriate for the "network" argument to Go net.Dial, and for appending to the port number to form the key for the ExposedPorts object in the OCI image config.

type ObjectTypeDef added in v0.8.8

type ObjectTypeDef struct {
	// Name is the standardized name of the object (CamelCase), as used for the object in the graphql schema
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Fields      []*FieldTypeDef `json:"fields"`
	Functions   []*Function     `json:"functions"`
	Constructor *Function       `json:"constructor"`

	// The original name of the object as provided by the SDK that defined it, used
	// when invoking the SDK so it doesn't need to think as hard about case conversions
	OriginalName string `json:"originalName,omitempty"`
}

func NewObjectTypeDef added in v0.9.1

func NewObjectTypeDef(name, description string) *ObjectTypeDef

func (ObjectTypeDef) Clone added in v0.8.8

func (typeDef ObjectTypeDef) Clone() *ObjectTypeDef

func (ObjectTypeDef) FieldByName added in v0.8.8

func (typeDef ObjectTypeDef) FieldByName(name string) (*FieldTypeDef, bool)

func (ObjectTypeDef) FunctionByName added in v0.8.8

func (typeDef ObjectTypeDef) FunctionByName(name string) (*Function, bool)

type Ownership added in v0.5.1

type Ownership struct {
	UID int `json:"uid"`
	GID int `json:"gid"`
}

Ownership contains a UID/GID pair resolved from a user/group name or ID pair provided via the API. It primarily exists to distinguish an unspecified ownership from UID/GID 0 (root) ownership.

func (Ownership) Opt added in v0.5.1

func (owner Ownership) Opt() llb.ChownOption

type Port added in v0.8.5

type Port struct {
	Port        int             `json:"port"`
	Protocol    NetworkProtocol `json:"protocol"`
	Description *string         `json:"description,omitempty"`
}

Port configures a port to exposed from a container or service.

type PortForward added in v0.9.0

type PortForward struct {
	Frontend int             `json:"frontend"`
	Backend  int             `json:"backend"`
	Protocol NetworkProtocol `json:"protocol"`
}

func (PortForward) FrontendOrBackendPort added in v0.9.0

func (pf PortForward) FrontendOrBackendPort() int

type Query added in v0.3.10

type Query struct {
	// Pipeline
	Pipeline pipeline.Path `json:"pipeline"`
}

func (*Query) PipelinePath added in v0.4.0

func (query *Query) PipelinePath() pipeline.Path

type RunningService added in v0.8.5

type RunningService struct {
	// Service is the service that has been started.
	Service *Service

	// Key is the unique identifier for the service.
	Key ServiceKey

	// Host is the hostname used to reach the service.
	Host string

	// Ports lists the ports bound by the service.
	//
	// For a Container service, this is simply the list of exposed ports.
	//
	// For a TunnelService, this lists the configured port forwards with any
	// empty or 0 frontend ports resolved to their randomly selected host port.
	//
	// For a HostService, this lists the configured port forwards with any empty
	// or 0 frontend ports set to the same as the backend port.
	Ports []Port

	// Stop forcibly stops the service. It is normally called after all clients
	// have detached, but may also be called manually by the user.
	Stop func(context.Context) error

	// Block until the service has exited or the provided context is canceled.
	Wait func(context.Context) error
}

RunningService represents a service that is actively running.

type Secret

type Secret struct {
	// Name specifies the arbitrary name/id of the secret.
	Name string `json:"name,omitempty"`
}

Secret is a content-addressed secret.

func NewDynamicSecret added in v0.5.1

func NewDynamicSecret(name string) *Secret

func (*Secret) Clone added in v0.5.1

func (secret *Secret) Clone() *Secret

func (*Secret) Digest added in v0.8.8

func (secret *Secret) Digest() (digest.Digest, error)

func (*Secret) ID

func (secret *Secret) ID() (SecretID, error)

type SecretID

type SecretID = resourceid.ID[Secret]

type SecretStore added in v0.8.0

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

func NewSecretStore added in v0.8.0

func NewSecretStore() *SecretStore

func (*SecretStore) AddSecret added in v0.8.0

func (store *SecretStore) AddSecret(_ context.Context, name string, plaintext []byte) (SecretID, error)

AddSecret adds the secret identified by user defined name with its plaintext value to the secret store.

func (*SecretStore) GetSecret added in v0.8.0

func (store *SecretStore) GetSecret(ctx context.Context, idOrName string) ([]byte, error)

GetSecret returns the plaintext secret value.

Its argument may either be the user defined name originally specified within a SecretID, or a full SecretID value.

A user defined name will be received when secrets are used in a Dockerfile build.

In all other cases, a SecretID is expected.

type SecretToScrubInfo added in v0.3.13

type SecretToScrubInfo struct {
	// Envs stores environment variable names that we need to scrub.
	Envs []string `json:"envs,omitempty"`

	// Files stores secret file paths that we need to scrub.
	Files []string `json:"files,omitempty"`
}

SecretToScrubInfo stores the info to access secrets and scrub them from outputs.

type Service added in v0.3.13

type Service struct {
	// Container is the container to run as a service.
	Container *Container `json:"container"`

	// TunnelUpstream is the service that this service is tunnelling to.
	TunnelUpstream *Service `json:"upstream,omitempty"`
	// TunnelPorts configures the port forwarding rules for the tunnel.
	TunnelPorts []PortForward `json:"tunnel_ports,omitempty"`

	// HostUpstream is the host address (i.e. hostname or IP) for the reverse
	// tunnel to request through the host.
	HostUpstream string `json:"reverse_tunnel_upstream_addr,omitempty"`
	// HostPorts configures the port forwarding rules for the host.
	HostPorts []PortForward `json:"host_ports,omitempty"`
}

func NewContainerService added in v0.8.5

func NewContainerService(ctr *Container) *Service

func NewHostService added in v0.9.0

func NewHostService(upstream string, ports []PortForward) *Service

func NewTunnelService added in v0.9.0

func NewTunnelService(upstream *Service, ports []PortForward) *Service

func (*Service) Clone added in v0.8.5

func (svc *Service) Clone() *Service

Clone returns a deep copy of the container suitable for modifying in a WithXXX method.

func (*Service) Digest added in v0.8.5

func (svc *Service) Digest() (digest.Digest, error)

Digest returns the service's content hash.

func (*Service) Endpoint added in v0.8.5

func (svc *Service) Endpoint(ctx context.Context, svcs *Services, port int, scheme string) (string, error)

func (*Service) Hostname added in v0.8.5

func (svc *Service) Hostname(ctx context.Context, svcs *Services) (string, error)

func (*Service) ID added in v0.8.5

func (svc *Service) ID() (ServiceID, error)

ID marshals the service into a content-addressed ID.

func (*Service) PipelinePath added in v0.8.5

func (svc *Service) PipelinePath() pipeline.Path

PipelinePath returns the service's pipeline path.

func (*Service) Ports added in v0.8.5

func (svc *Service) Ports(ctx context.Context, svcs *Services) ([]Port, error)

func (*Service) Start added in v0.8.5

func (svc *Service) Start(
	ctx context.Context,
	bk *buildkit.Client,
	svcs *Services,
	interactive bool,
	forwardStdin func(io.Writer, bkgw.ContainerProcess),
	forwardStdout func(io.Reader),
	forwardStderr func(io.Reader),
) (running *RunningService, err error)

type ServiceBinding added in v0.8.5

type ServiceBinding struct {
	Service  *Service `json:"service"`
	Hostname string   `json:"hostname"`
	Aliases  AliasSet `json:"aliases"`
}

type ServiceBindings added in v0.3.13

type ServiceBindings []ServiceBinding

func (*ServiceBindings) Merge added in v0.3.13

func (bndp *ServiceBindings) Merge(other ServiceBindings)

type ServiceID added in v0.8.5

type ServiceID = resourceid.ID[Service]

type ServiceKey added in v0.8.5

type ServiceKey struct {
	Digest   digest.Digest
	ClientID string
}

ServiceKey is a unique identifier for a service.

type Services added in v0.8.5

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

Services manages the lifecycle of services, ensuring the same service only runs once per client.

func NewServices added in v0.8.5

func NewServices(bk *buildkit.Client) *Services

NewServices returns a new Services.

func (*Services) Detach added in v0.8.5

func (ss *Services) Detach(ctx context.Context, svc *RunningService) error

Detach detaches from the given service. If the service is not running, it is a no-op. If the service is running, it is stopped if there are no other clients using it.

func (*Services) Get added in v0.8.5

func (ss *Services) Get(ctx context.Context, svc Startable) (*RunningService, error)

Get returns the running service for the given service. If the service is starting, it waits for it and either returns the running service or an error if it failed to start. If the service is not running or starting, an error is returned.

func (*Services) Start added in v0.8.5

func (ss *Services) Start(ctx context.Context, svc Startable) (*RunningService, error)

Start starts the given service, returning the running service. If the service is already running, it is returned immediately. If the service is already starting, it waits for it to finish and returns the running service. If the service failed to start, it tries again.

func (*Services) StartBindings added in v0.8.5

func (ss *Services) StartBindings(ctx context.Context, bk *buildkit.Client, bindings ServiceBindings) (_ func(), _ []*RunningService, err error)

StartBindings starts each of the bound services in parallel and returns a function that will detach from all of them after 10 seconds.

func (*Services) Stop added in v0.8.5

func (ss *Services) Stop(ctx context.Context, bk *buildkit.Client, svc *Service) error

Stop stops the given service. If the service is not running, it is a no-op.

func (*Services) StopClientServices added in v0.8.5

func (ss *Services) StopClientServices(ctx context.Context, client *engine.ClientMetadata) error

StopClientServices stops all of the services being run by the given client. It is called when a client is closing.

type Startable added in v0.8.5

type Startable interface {
	Digest() (digest.Digest, error)

	Start(
		ctx context.Context,
		bk *buildkit.Client,
		svcs *Services,
		interactive bool,
		forwardStdin func(io.Writer, bkgw.ContainerProcess),
		forwardStdout func(io.Reader),
		forwardStderr func(io.Reader),
	) (*RunningService, error)
}

type TypeDef added in v0.8.8

type TypeDef struct {
	Kind     TypeDefKind    `json:"kind"`
	Optional bool           `json:"optional"`
	AsList   *ListTypeDef   `json:"asList"`
	AsObject *ObjectTypeDef `json:"asObject"`
}

func (TypeDef) Clone added in v0.8.8

func (typeDef TypeDef) Clone() *TypeDef

func (*TypeDef) Digest added in v0.8.8

func (typeDef *TypeDef) Digest() (digest.Digest, error)

func (*TypeDef) ID added in v0.8.8

func (typeDef *TypeDef) ID() (TypeDefID, error)

func (*TypeDef) Underlying added in v0.9.4

func (typeDef *TypeDef) Underlying() *TypeDef

func (*TypeDef) WithKind added in v0.8.8

func (typeDef *TypeDef) WithKind(kind TypeDefKind) *TypeDef

func (*TypeDef) WithListOf added in v0.8.8

func (typeDef *TypeDef) WithListOf(elem *TypeDef) *TypeDef

func (*TypeDef) WithObject added in v0.8.8

func (typeDef *TypeDef) WithObject(name, desc string) *TypeDef

func (*TypeDef) WithObjectConstructor added in v0.9.4

func (typeDef *TypeDef) WithObjectConstructor(fn *Function) (*TypeDef, error)

func (*TypeDef) WithObjectField added in v0.8.8

func (typeDef *TypeDef) WithObjectField(name string, fieldType *TypeDef, desc string) (*TypeDef, error)

func (*TypeDef) WithObjectFunction added in v0.8.8

func (typeDef *TypeDef) WithObjectFunction(fn *Function) (*TypeDef, error)

func (*TypeDef) WithOptional added in v0.8.8

func (typeDef *TypeDef) WithOptional(optional bool) *TypeDef

type TypeDefID added in v0.8.8

type TypeDefID = resourceid.ID[TypeDef]

type TypeDefKind added in v0.8.8

type TypeDefKind string
const (
	TypeDefKindString  TypeDefKind = "StringKind"
	TypeDefKindInteger TypeDefKind = "IntegerKind"
	TypeDefKindBoolean TypeDefKind = "BooleanKind"
	TypeDefKindList    TypeDefKind = "ListKind"
	TypeDefKindObject  TypeDefKind = "ObjectKind"
	TypeDefKindVoid    TypeDefKind = "VoidKind"
)

func (TypeDefKind) String added in v0.8.8

func (k TypeDefKind) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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