driver

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKubeClientConfig

func NewKubeClientConfig(kubeconfigPath, context, namespace string) clientcmd.ClientConfig

NewKubeClientConfig return a kube client config that will by default use an in cluster client config or, if not available or overriden an external client config using the default client behavior used also by kubectl.

Types

type ContainerConfig

type ContainerConfig struct {
	Cmd        []string
	Env        map[string]string
	WorkingDir string
	Image      string
	User       string
	Privileged bool
	Volumes    []Volume
}

type ContainerExec

type ContainerExec interface {
	Stdin() io.WriteCloser
	Wait(ctx context.Context) (int, error)
}

type ContainerSlice

type ContainerSlice []*DockerContainer

func (ContainerSlice) Len

func (p ContainerSlice) Len() int

func (ContainerSlice) Less

func (p ContainerSlice) Less(i, j int) bool

func (ContainerSlice) Swap

func (p ContainerSlice) Swap(i, j int)

type DockerContainer

type DockerContainer struct {
	Index int
	dockertypes.Container
}

type DockerContainerExec

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

func (*DockerContainerExec) Stdin

func (e *DockerContainerExec) Stdin() io.WriteCloser

func (*DockerContainerExec) Wait

func (e *DockerContainerExec) Wait(ctx context.Context) (int, error)

type DockerDriver

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

func NewDockerDriver

func NewDockerDriver(log zerolog.Logger, executorID, toolboxPath, initImage string, initDockerConfig *registry.DockerConfig) (*DockerDriver, error)

func (*DockerDriver) Archs

func (d *DockerDriver) Archs(ctx context.Context) ([]types.Arch, error)

func (*DockerDriver) ExecutorGroup

func (d *DockerDriver) ExecutorGroup(ctx context.Context) (string, error)

func (*DockerDriver) GetExecutors

func (d *DockerDriver) GetExecutors(ctx context.Context) ([]string, error)

func (*DockerDriver) GetPods

func (d *DockerDriver) GetPods(ctx context.Context, all bool) ([]Pod, error)

func (*DockerDriver) NewPod

func (d *DockerDriver) NewPod(ctx context.Context, podConfig *PodConfig, out io.Writer) (Pod, error)

func (*DockerDriver) Setup

func (d *DockerDriver) Setup(ctx context.Context) error

type DockerPod

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

func (*DockerPod) Exec

func (dp *DockerPod) Exec(ctx context.Context, execConfig *ExecConfig) (ContainerExec, error)

func (*DockerPod) ExecutorID

func (dp *DockerPod) ExecutorID() string

func (*DockerPod) ID

func (dp *DockerPod) ID() string

func (*DockerPod) Remove

func (dp *DockerPod) Remove(ctx context.Context) error

func (*DockerPod) Stop

func (dp *DockerPod) Stop(ctx context.Context) error

func (*DockerPod) TaskID

func (dp *DockerPod) TaskID() string

type Driver

type Driver interface {
	Setup(ctx context.Context) error
	NewPod(ctx context.Context, podConfig *PodConfig, out io.Writer) (Pod, error)
	GetPods(ctx context.Context, all bool) ([]Pod, error)
	ExecutorGroup(ctx context.Context) (string, error)
	GetExecutors(ctx context.Context) ([]string, error)
	Archs(ctx context.Context) ([]types.Arch, error)
}

Driver is a generic interface around the pod concept (a group of "containers" sharing, at least, the same network namespace) It's just tailored aroun the need of an executor and should be quite generic to work with multiple implementations. For example: * Docker containers * Kubernetes pods * A Virtual Machine on which we execute multiple processes

type ExecConfig

type ExecConfig struct {
	Cmd         []string
	Env         map[string]string
	WorkingDir  string
	User        string
	AttachStdin bool
	Stdout      io.Writer
	Stderr      io.Writer
	Tty         bool
}

type K8sContainerExec

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

func (*K8sContainerExec) Stdin

func (e *K8sContainerExec) Stdin() io.WriteCloser

func (*K8sContainerExec) Wait

func (e *K8sContainerExec) Wait(ctx context.Context) (int, error)

type K8sDriver

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

func NewK8sDriver

func NewK8sDriver(log zerolog.Logger, executorID, toolboxPath, initImage string, initDockerConfig *registry.DockerConfig) (*K8sDriver, error)

func (*K8sDriver) Archs

func (d *K8sDriver) Archs(ctx context.Context) ([]types.Arch, error)

func (*K8sDriver) ExecutorGroup

func (d *K8sDriver) ExecutorGroup(ctx context.Context) (string, error)

func (*K8sDriver) GetExecutors

func (d *K8sDriver) GetExecutors(ctx context.Context) ([]string, error)

func (*K8sDriver) GetPods

func (d *K8sDriver) GetPods(ctx context.Context, all bool) ([]Pod, error)

func (*K8sDriver) NewPod

func (d *K8sDriver) NewPod(ctx context.Context, podConfig *PodConfig, out io.Writer) (Pod, error)

func (*K8sDriver) Setup

func (d *K8sDriver) Setup(ctx context.Context) error

type K8sPod

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

func (*K8sPod) Exec

func (p *K8sPod) Exec(ctx context.Context, execConfig *ExecConfig) (ContainerExec, error)

func (*K8sPod) ExecutorID

func (p *K8sPod) ExecutorID() string

func (*K8sPod) ID

func (p *K8sPod) ID() string

func (*K8sPod) Remove

func (p *K8sPod) Remove(ctx context.Context) error

func (*K8sPod) Stop

func (p *K8sPod) Stop(ctx context.Context) error

func (*K8sPod) TaskID

func (p *K8sPod) TaskID() string

type LeaseData

type LeaseData struct {
	LeaseDurationSeconds int       `json:"leaseDurationSeconds"`
	AcquireTime          time.Time `json:"acquireTime"`
	RenewTime            time.Time `json:"renewTime"`
	HolderIdentity       string    `json:"holderIdentity"`
}

type Pod

type Pod interface {
	// ID returns the pod id
	ID() string
	// ExecutorID return the pod owner executor id
	ExecutorID() string
	// TaskID return the pod task id
	TaskID() string
	// Stop stops the pod
	Stop(ctx context.Context) error
	// Stop stops the pod
	Remove(ctx context.Context) error
	// Exec executes a command inside the first container in the Pod
	Exec(ctx context.Context, execConfig *ExecConfig) (ContainerExec, error)
}

type PodConfig

type PodConfig struct {
	ID         string
	TaskID     string
	Containers []*ContainerConfig
	Arch       types.Arch
	// The container dir where the init volume will be mounted
	InitVolumeDir string
	DockerConfig  *registry.DockerConfig
}

type Stdin

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

Stdin is a wrapped HikackedResponse implementing io.WriteCloser so users can easily close stdin. Internally it will close only the write side of the conn.

func (*Stdin) Close

func (s *Stdin) Close() error

func (*Stdin) Write

func (s *Stdin) Write(p []byte) (int, error)

type Volume added in v0.3.0

type Volume struct {
	Path string

	TmpFS *VolumeTmpFS
}

type VolumeTmpFS added in v0.3.0

type VolumeTmpFS struct {
	Size int64
}

Jump to

Keyboard shortcuts

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