docker

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FlyteSandboxConfigDir          = f.FilePathJoin(f.UserHomeDir(), ".flyte", "sandbox")
	Kubeconfig                     = f.FilePathJoin(FlyteSandboxConfigDir, "kubeconfig")
	SandboxKubeconfig              = f.FilePathJoin(f.UserHomeDir(), ".flyte", "k3s", "k3s.yaml")
	SuccessMessage                 = "Deploying Flyte..."
	FlyteSandboxClusterName        = "flyte-sandbox"
	FlyteSandboxVolumeName         = "flyte-sandbox"
	FlyteSandboxInternalDir        = "/var/lib/flyte"
	FlyteSandboxInternalConfigDir  = f.FilePathJoin(FlyteSandboxInternalDir, "config")
	FlyteSandboxInternalStorageDir = f.FilePathJoin(FlyteSandboxInternalDir, "storage")
	Environment                    = []string{"SANDBOX=1", "KUBERNETES_API_PORT=30086", "FLYTE_HOST=localhost:30081", "FLYTE_AWS_ENDPOINT=http://localhost:30084"}
	Source                         = "/root"
	K3sDir                         = "/etc/rancher/"
	Client                         Docker
	Volumes                        = []mount.Mount{
		{
			Type:   mount.TypeBind,
			Source: f.FilePathJoin(f.UserHomeDir(), ".flyte"),
			Target: K3sDir,
		},
	}
	ExecConfig = types.ExecConfig{
		AttachStderr: true,
		Tty:          true,
		WorkingDir:   "/",
		AttachStdout: true,
		Cmd:          []string{},
	}
	StdWriterPrefixLen = 8
	StartingBufLen     = 32*1024 + StdWriterPrefixLen + 1
	ExtraHosts         = []string{"host.docker.internal:host-gateway"}
)
View Source
var (
	DefaultConfig = &Config{
		Force: false,
	}
)

Config holds configuration flags for docker command.

Functions

func CopyContainerFile added in v0.6.24

func CopyContainerFile(ctx context.Context, cli Docker, source, destination, name, image string) error

CopyContainerFile try to create the container, see if the source file is there, copy it to the destination

func ExecCommend added in v0.1.29

func ExecCommend(ctx context.Context, cli Docker, containerID string, command []string) (types.IDResponse, error)

ExecCommend will execute a command in container and returns an execution id

func GetDemoPorts added in v0.5.19

func GetDemoPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error)

GetDemoPorts will return demo ports

func GetDevPorts added in v0.6.17

func GetDevPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error)

GetDevPorts will return dev cluster (minio + postgres) ports

func GetOrCreateVolume added in v0.6.28

func GetOrCreateVolume(
	ctx context.Context, cli Docker, volumeName string, dryRun bool,
) (*types.Volume, error)

func GetSandbox

func GetSandbox(ctx context.Context, cli Docker) (*types.Container, error)

GetSandbox will return sandbox container if it exist

func GetSandboxPorts

func GetSandboxPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error)

GetSandboxPorts will return sandbox ports

func InspectExecResp added in v0.1.29

func InspectExecResp(ctx context.Context, cli Docker, containerID string) error

func PrintCreateContainer added in v0.6.22

func PrintCreateContainer(volumes []mount.Mount, portBindings map[nat.Port][]nat.PortBinding, name, image string, environment []string)

PrintCreateContainer helper function to print the docker command to run

func PrintCreateVolume added in v0.6.28

func PrintCreateVolume(name string)

func PrintPullImage added in v0.6.22

func PrintPullImage(image string, pullOptions ImagePullOptions)

PrintPullImage helper function to print the sandbox pull image command

func PrintRemoveContainer added in v0.6.22

func PrintRemoveContainer(name string)

PrintRemoveContainer helper function to remove sandbox container

func PullDockerImage

func PullDockerImage(ctx context.Context, cli Docker, image string, pullPolicy ImagePullPolicy,
	imagePullOptions ImagePullOptions, dryRun bool) error

PullDockerImage will Pull docker image

func ReadLogs

func ReadLogs(ctx context.Context, cli Docker, id string) (*bufio.Scanner, error)

ReadLogs will return io scanner for reading the logs of a container

func RemoveSandbox

func RemoveSandbox(ctx context.Context, cli Docker, reader io.Reader) error

RemoveSandbox will remove sandbox container if exist

func StartContainer

func StartContainer(ctx context.Context, cli Docker, volumes []mount.Mount, exposedPorts map[nat.Port]struct{},
	portBindings map[nat.Port][]nat.PortBinding, name, image string, additionalEnvVars []string, dryRun bool) (string, error)

StartContainer will create and start docker container

func WaitForSandbox

func WaitForSandbox(reader *bufio.Scanner, message string) bool

WaitForSandbox will wait until it doesn't get success message

Types

type Config added in v0.7.3

type Config struct {
	Force bool `json:"force" pflag:",Optional. Forcefully delete existing sandbox cluster if it exists."`
}

type Docker

type Docker interface {
	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error)
	ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error
	ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
	ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error)
	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
	ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
	ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
	ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
	ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
	ImageList(ctx context.Context, listOption types.ImageListOptions) ([]types.ImageSummary, error)
	ContainerStatPath(ctx context.Context, containerID, path string) (types.ContainerPathStat, error)
	CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
	VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error)
	VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error)
	VolumeRemove(ctx context.Context, volumeID string, force bool) error
}

func GetDockerClient

func GetDockerClient() (Docker, error)

GetDockerClient will returns the docker client

type FlyteDocker

type FlyteDocker struct {
	*client.Client
}

type ImagePullOptions added in v0.6.0

type ImagePullOptions struct {
	RegistryAuth string `json:"registryAuth" pflag:",The base64 encoded credentials for the registry."`
	Platform     string `json:"platform" pflag:",Forces a specific platform's image to be pulled.'"`
}

type ImagePullPolicy added in v0.6.0

type ImagePullPolicy int
const (
	ImagePullPolicyAlways ImagePullPolicy = iota
	ImagePullPolicyIfNotPresent
	ImagePullPolicyNever
)

func ImagePullPolicyString added in v0.6.0

func ImagePullPolicyString(s string) (ImagePullPolicy, error)

ImagePullPolicyString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ImagePullPolicyValues added in v0.6.0

func ImagePullPolicyValues() []ImagePullPolicy

ImagePullPolicyValues returns all values of the enum

func (ImagePullPolicy) IsAImagePullPolicy added in v0.6.0

func (i ImagePullPolicy) IsAImagePullPolicy() bool

IsAImagePullPolicy returns "true" if the value is listed in the enum definition. "false" otherwise

func (ImagePullPolicy) MarshalJSON added in v0.6.0

func (i ImagePullPolicy) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ImagePullPolicy

func (*ImagePullPolicy) Set added in v0.6.0

func (i *ImagePullPolicy) Set(val string) error

Set implements PFlag's Value interface to attempt to set the value of the flag from string.

func (ImagePullPolicy) String added in v0.6.0

func (i ImagePullPolicy) String() string

func (ImagePullPolicy) Type added in v0.6.0

func (i ImagePullPolicy) Type() string

Type implements PFlag's Value interface to return type name.

func (*ImagePullPolicy) UnmarshalJSON added in v0.6.0

func (i *ImagePullPolicy) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ImagePullPolicy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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