daggerkit

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package daggerkit provides adapters to convert real Dagger types to interfaces, mirroring the root module's internal/daggerkit/adapter.go.

Package daggerkit provides interfaces for Dagger types to enable mocking in provider unit tests. Scoped-down copy of the root module's internal/daggerkit, kept local to providers/rust (its own Go module) so this module gains no dependency on the root module — see internalimport_test.go's D5 guard, which is extended (not disabled) to permit this module's own internal/daggerkit while still forbidding a reach into the root's internal/**.

Deliberately narrower than the root's surface: only the DaggerClient methods and chained Container/Directory/File/Host/CacheVolume methods providers/rust's capability implementations actually call are present.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaggerAdapter

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

DaggerAdapter adapts a real *dagger.Client to DaggerClient.

func (*DaggerAdapter) CacheVolume

func (a *DaggerAdapter) CacheVolume(name string) DaggerCacheVolume

func (*DaggerAdapter) Container

func (a *DaggerAdapter) Container() DaggerContainer

func (*DaggerAdapter) Host

func (a *DaggerAdapter) Host() DaggerHost

type DaggerCacheVolume

type DaggerCacheVolume interface {
}

DaggerCacheVolume interface abstracts the dagger.CacheVolume to enable mocking. No methods: every provider in this module only ever passes a CacheVolume opaquely into WithMountedCache.

type DaggerCacheVolumeAdapter

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

DaggerCacheVolumeAdapter adapts a real *dagger.CacheVolume to DaggerCacheVolume.

type DaggerClient

type DaggerClient interface {
	Container() DaggerContainer
	Host() DaggerHost
	CacheVolume(string) DaggerCacheVolume
}

DaggerClient interface abstracts the dagger.Client to enable mocking.

func NewDaggerAdapter

func NewDaggerAdapter(client *dagger.Client) DaggerClient

NewDaggerAdapter creates a new adapter for a real Dagger client.

type DaggerContainer

type DaggerContainer interface {
	From(string) DaggerContainer
	WithMountedDirectory(string, DaggerDirectory) DaggerContainer
	WithMountedCache(string, DaggerCacheVolume) DaggerContainer
	WithWorkdir(string) DaggerContainer
	WithExec([]string) DaggerContainer
	WithNewFile(string, string) DaggerContainer
	WithDirectory(string, DaggerDirectory) DaggerContainer
	WithEntrypoint([]string) DaggerContainer
	// WithRegistryAuth and WithUnixSocket take *dagger.Secret/*dagger.Socket
	// directly rather than a wrapping interface, same rationale as
	// DaggerHost.UnixSocket above.
	WithRegistryAuth(string, string, *dagger.Secret) DaggerContainer
	WithUnixSocket(string, *dagger.Socket) DaggerContainer
	WithEnvVariable(string, string) DaggerContainer
	// WithExposedPort, AsService and WithServiceBinding exist for the
	// Docker-in-Docker sidecar pattern (see providers/rust/dockerdaemon.go):
	// a privileged dockerd container is exposed as a DaggerService and bound
	// into the caller's container under a network alias, giving
	// testcontainers-rs a real, routable Docker daemon instead of a mounted
	// host socket (which Dagger's own container sandboxing model makes
	// unreachable for sibling-container networking — see dockerdaemon.go's
	// doc comment for the full root cause).
	WithExposedPort(int) DaggerContainer
	// AsService runs args as the service's live process, with Dagger's
	// InsecureRootCapabilities (needed to start dockerd itself). Args must
	// be passed here rather than via a prior WithExec: WithExec's semantics
	// are "run to completion and snapshot the result," which a daemon that
	// runs forever never does — see dockerdaemon.go's dockerdCommand comment.
	AsService([]string) DaggerService
	WithServiceBinding(string, DaggerService) DaggerContainer
	File(string) DaggerFile
	Directory(string) DaggerDirectory
	Sync(context.Context) (DaggerContainer, error)
	Stdout(context.Context) (string, error)
	Stderr(context.Context) (string, error)
	Publish(context.Context, string) (string, error)
}

DaggerContainer interface abstracts the dagger.Container to enable mocking.

type DaggerContainerAdapter

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

DaggerContainerAdapter adapts a real *dagger.Container to DaggerContainer.

func (*DaggerContainerAdapter) AsService added in v1.1.0

func (a *DaggerContainerAdapter) AsService(args []string) DaggerService

func (*DaggerContainerAdapter) Directory

func (a *DaggerContainerAdapter) Directory(path string) DaggerDirectory

func (*DaggerContainerAdapter) File

func (*DaggerContainerAdapter) From

func (*DaggerContainerAdapter) Publish

func (a *DaggerContainerAdapter) Publish(ctx context.Context, address string) (string, error)

func (*DaggerContainerAdapter) Stderr

func (*DaggerContainerAdapter) Stdout

func (*DaggerContainerAdapter) Sync

func (*DaggerContainerAdapter) WithDirectory

func (a *DaggerContainerAdapter) WithDirectory(path string, dir DaggerDirectory) DaggerContainer

func (*DaggerContainerAdapter) WithEntrypoint

func (a *DaggerContainerAdapter) WithEntrypoint(args []string) DaggerContainer

func (*DaggerContainerAdapter) WithEnvVariable added in v1.1.0

func (a *DaggerContainerAdapter) WithEnvVariable(name, value string) DaggerContainer

func (*DaggerContainerAdapter) WithExec

func (a *DaggerContainerAdapter) WithExec(args []string) DaggerContainer

func (*DaggerContainerAdapter) WithExposedPort added in v1.1.0

func (a *DaggerContainerAdapter) WithExposedPort(port int) DaggerContainer

func (*DaggerContainerAdapter) WithMountedCache

func (a *DaggerContainerAdapter) WithMountedCache(path string, cache DaggerCacheVolume) DaggerContainer

func (*DaggerContainerAdapter) WithMountedDirectory

func (a *DaggerContainerAdapter) WithMountedDirectory(path string, dir DaggerDirectory) DaggerContainer

func (*DaggerContainerAdapter) WithNewFile

func (a *DaggerContainerAdapter) WithNewFile(path, contents string) DaggerContainer

func (*DaggerContainerAdapter) WithRegistryAuth

func (a *DaggerContainerAdapter) WithRegistryAuth(address, username string, secret *dagger.Secret) DaggerContainer

func (*DaggerContainerAdapter) WithServiceBinding added in v1.1.0

func (a *DaggerContainerAdapter) WithServiceBinding(alias string, svc DaggerService) DaggerContainer

func (*DaggerContainerAdapter) WithUnixSocket

func (a *DaggerContainerAdapter) WithUnixSocket(path string, socket *dagger.Socket) DaggerContainer

func (*DaggerContainerAdapter) WithWorkdir

func (a *DaggerContainerAdapter) WithWorkdir(path string) DaggerContainer

type DaggerDirectory

type DaggerDirectory interface {
	File(string) DaggerFile
	// GetRealDirectory returns the underlying real Dagger directory (only
	// for adapters) — needed to unwrap RustBuilder.Build's returned
	// Directory back to the concrete *dagger.Directory its public signature
	// promises.
	GetRealDirectory() *dagger.Directory
}

DaggerDirectory interface abstracts the dagger.Directory to enable mocking.

func NewDaggerDirectoryAdapter

func NewDaggerDirectoryAdapter(directory *dagger.Directory) DaggerDirectory

NewDaggerDirectoryAdapter wraps a real *dagger.Directory as a DaggerDirectory, needed to feed a caller-supplied concrete Directory (e.g. a provider's public Build(source *dagger.Directory) parameter) into interface-typed methods such as DaggerContainer.WithMountedDirectory.

type DaggerDirectoryAdapter

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

DaggerDirectoryAdapter adapts a real *dagger.Directory to DaggerDirectory.

func (*DaggerDirectoryAdapter) File

func (*DaggerDirectoryAdapter) GetRealDirectory

func (a *DaggerDirectoryAdapter) GetRealDirectory() *dagger.Directory

GetRealDirectory returns the underlying real Dagger directory for use with shared functions.

type DaggerFile

type DaggerFile interface {
	Contents(context.Context) (string, error)
	// GetRealFile returns the underlying real Dagger file (only for
	// adapters) — needed by every Tester in this module, each of which
	// returns its report as a *dagger.File.
	GetRealFile() *dagger.File
}

DaggerFile interface abstracts the dagger.File to enable mocking.

type DaggerFileAdapter

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

DaggerFileAdapter adapts a real *dagger.File to DaggerFile.

func (*DaggerFileAdapter) Contents

func (a *DaggerFileAdapter) Contents(ctx context.Context) (string, error)

func (*DaggerFileAdapter) GetRealFile

func (a *DaggerFileAdapter) GetRealFile() *dagger.File

GetRealFile returns the underlying real Dagger file for use with shared functions.

type DaggerHost

type DaggerHost interface {
	// UnixSocket returns *dagger.Socket directly rather than a wrapping
	// interface: callers only ever pass it through opaquely to
	// DaggerContainer.WithUnixSocket, never call a method on it.
	UnixSocket(string) *dagger.Socket
}

DaggerHost interface abstracts the dagger.Host to enable mocking.

type DaggerHostAdapter

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

DaggerHostAdapter adapts a real *dagger.Host to DaggerHost.

func (*DaggerHostAdapter) UnixSocket

func (a *DaggerHostAdapter) UnixSocket(path string) *dagger.Socket

type DaggerService added in v1.1.0

type DaggerService interface {
}

DaggerService interface abstracts the dagger.Service to enable mocking. No methods: every provider in this module only ever passes a Service opaquely into WithServiceBinding (e.g. a Docker-in-Docker daemon container turned into a service via AsService).

type DaggerServiceAdapter added in v1.1.0

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

DaggerServiceAdapter adapts a real *dagger.Service to DaggerService.

type MockDaggerCacheVolume

type MockDaggerCacheVolume struct {
	mock.Mock
}

MockDaggerCacheVolume implements DaggerCacheVolume using testify's mock package.

type MockDaggerClient

type MockDaggerClient struct {
	mock.Mock
}

MockDaggerClient implements DaggerClient using testify's mock package.

func (*MockDaggerClient) CacheVolume

func (m *MockDaggerClient) CacheVolume(name string) DaggerCacheVolume

func (*MockDaggerClient) Container

func (m *MockDaggerClient) Container() DaggerContainer

func (*MockDaggerClient) Host

func (m *MockDaggerClient) Host() DaggerHost

type MockDaggerContainer

type MockDaggerContainer struct {
	mock.Mock
}

MockDaggerContainer implements DaggerContainer using testify's mock package.

func (*MockDaggerContainer) AsService added in v1.1.0

func (m *MockDaggerContainer) AsService(serviceArgs []string) DaggerService

func (*MockDaggerContainer) Directory

func (m *MockDaggerContainer) Directory(path string) DaggerDirectory

func (*MockDaggerContainer) File

func (m *MockDaggerContainer) File(path string) DaggerFile

func (*MockDaggerContainer) From

func (*MockDaggerContainer) Publish

func (m *MockDaggerContainer) Publish(ctx context.Context, address string) (string, error)

func (*MockDaggerContainer) Stderr

func (m *MockDaggerContainer) Stderr(ctx context.Context) (string, error)

func (*MockDaggerContainer) Stdout

func (m *MockDaggerContainer) Stdout(ctx context.Context) (string, error)

func (*MockDaggerContainer) Sync

func (*MockDaggerContainer) WithDirectory

func (m *MockDaggerContainer) WithDirectory(path string, dir DaggerDirectory) DaggerContainer

func (*MockDaggerContainer) WithEntrypoint

func (m *MockDaggerContainer) WithEntrypoint(execArgs []string) DaggerContainer

func (*MockDaggerContainer) WithEnvVariable added in v1.1.0

func (m *MockDaggerContainer) WithEnvVariable(name, value string) DaggerContainer

func (*MockDaggerContainer) WithExec

func (m *MockDaggerContainer) WithExec(execArgs []string) DaggerContainer

func (*MockDaggerContainer) WithExposedPort added in v1.1.0

func (m *MockDaggerContainer) WithExposedPort(port int) DaggerContainer

func (*MockDaggerContainer) WithMountedCache

func (m *MockDaggerContainer) WithMountedCache(path string, cache DaggerCacheVolume) DaggerContainer

func (*MockDaggerContainer) WithMountedDirectory

func (m *MockDaggerContainer) WithMountedDirectory(path string, dir DaggerDirectory) DaggerContainer

func (*MockDaggerContainer) WithNewFile

func (m *MockDaggerContainer) WithNewFile(path, contents string) DaggerContainer

func (*MockDaggerContainer) WithRegistryAuth

func (m *MockDaggerContainer) WithRegistryAuth(address, username string, secret *dagger.Secret) DaggerContainer

func (*MockDaggerContainer) WithServiceBinding added in v1.1.0

func (m *MockDaggerContainer) WithServiceBinding(alias string, svc DaggerService) DaggerContainer

func (*MockDaggerContainer) WithUnixSocket

func (m *MockDaggerContainer) WithUnixSocket(path string, socket *dagger.Socket) DaggerContainer

func (*MockDaggerContainer) WithWorkdir

func (m *MockDaggerContainer) WithWorkdir(path string) DaggerContainer

type MockDaggerDirectory

type MockDaggerDirectory struct {
	mock.Mock
}

MockDaggerDirectory implements DaggerDirectory using testify's mock package.

func (*MockDaggerDirectory) File

func (m *MockDaggerDirectory) File(path string) DaggerFile

func (*MockDaggerDirectory) GetRealDirectory

func (m *MockDaggerDirectory) GetRealDirectory() *dagger.Directory

type MockDaggerFile

type MockDaggerFile struct {
	mock.Mock
}

MockDaggerFile implements DaggerFile using testify's mock package.

func (*MockDaggerFile) Contents

func (m *MockDaggerFile) Contents(ctx context.Context) (string, error)

func (*MockDaggerFile) GetRealFile

func (m *MockDaggerFile) GetRealFile() *dagger.File

type MockDaggerHost

type MockDaggerHost struct {
	mock.Mock
}

MockDaggerHost implements DaggerHost using testify's mock package.

func (*MockDaggerHost) UnixSocket

func (m *MockDaggerHost) UnixSocket(path string) *dagger.Socket

type MockDaggerService added in v1.1.0

type MockDaggerService struct {
	mock.Mock
}

MockDaggerService implements DaggerService using testify's mock package.

Jump to

Keyboard shortcuts

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