provider

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DockerProviderName       = "docker"
	DockerDefaultNetworkName = "imagetest"
)

Variables

View Source
var (
	ErrNetworkNotFound = errors.New("network not found")
	DefaultLabels      = map[string]string{
		"dev.chainguard.imagetest": "true",
	}
)

Functions

This section is empty.

Types

type ContainerRequest

type ContainerRequest struct {
	Ref        name.Reference
	Entrypoint []string
	User       string // uid:gid
	Env        Env
	Cmd        []string
	Networks   []string
	Privileged bool
	Files      []File
	// An abstraction over common memory/cpu/disk resources requests and limits
	Resources ContainerResourcesRequest
}

type ContainerResourcesRequest added in v0.0.7

type ContainerResourcesRequest struct {
	CpuRequest resource.Quantity
	CpuLimit   resource.Quantity

	MemoryRequest resource.Quantity
	MemoryLimit   resource.Quantity
}

type DockerClient added in v0.0.13

type DockerClient struct {
	*client.Client
	// contains filtered or unexported fields
}

DockerClient is a wrapper around the Docker client that provides a mutex to ensure the unsafe operations can be done safely.

func NewDockerClient added in v0.0.13

func NewDockerClient() (*DockerClient, error)

type DockerNetworkRequest added in v0.0.11

type DockerNetworkRequest struct {
	types.NetworkCreate
	Name string
}

type DockerProvider

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

func NewDocker

func NewDocker(name string, cli *DockerClient, req DockerRequest) *DockerProvider

NewDocker creates a new DockerProvider with the given client.

func (*DockerProvider) CreateNetwork added in v0.0.11

func (p *DockerProvider) CreateNetwork(ctx context.Context, name string) (string, error)

CreateNetwork creates a user defined bridge network with the given name only if it doesn't exist.

func (*DockerProvider) Exec

func (p *DockerProvider) Exec(ctx context.Context, config ExecConfig) (io.Reader, error)

Exec implements Provider.

func (*DockerProvider) GetNetwork added in v0.0.13

func (p *DockerProvider) GetNetwork(ctx context.Context, name string) (string, error)

func (*DockerProvider) Start

func (p *DockerProvider) Start(ctx context.Context) error

Start implements Provider.

func (*DockerProvider) Teardown

func (p *DockerProvider) Teardown(ctx context.Context) error

Teardown implements Provider.

type DockerRequest

type DockerRequest struct {
	ContainerRequest
	Mounts []mount.Mount
	// ManagedVolumes is the list of volumes that should be torn down when the
	// provider finishes execution
	ManagedVolumes []mount.Mount
}

type Env

type Env map[string]string

func (Env) ToSlice

func (e Env) ToSlice() []string

type ExecConfig added in v0.0.3

type ExecConfig struct {
	// The command to be executed in the provider
	Command string

	// The working directory to be used to execute the command
	WorkingDir string
}

type File

type File struct {
	Contents io.Reader
	Target   string
	Mode     int64
}

type Provider

type Provider interface {
	Start(ctx context.Context) error
	Teardown(ctx context.Context) error
	Exec(ctx context.Context, config ExecConfig) (io.Reader, error)
}

Jump to

Keyboard shortcuts

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