This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
/
docker.go
69 lines (58 loc) · 3.01 KB
/
docker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package docker
import (
"context"
"io"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/client"
specs "github.com/opencontainers/image-spec/specs-go/v1"
)
//go:generate mockery -all -case=underscore
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
}
type FlyteDocker struct {
*client.Client
}
//go:generate enumer -type=ImagePullPolicy -trimprefix=ImagePullPolicy --json
type ImagePullPolicy int
const (
ImagePullPolicyAlways ImagePullPolicy = iota
ImagePullPolicyIfNotPresent
ImagePullPolicyNever
)
// Set implements PFlag's Value interface to attempt to set the value of the flag from string.
func (i *ImagePullPolicy) Set(val string) error {
policy, err := ImagePullPolicyString(val)
if err != nil {
return err
}
*i = policy
return nil
}
// Type implements PFlag's Value interface to return type name.
func (i ImagePullPolicy) Type() string {
return "ImagePullPolicy"
}
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.'"`
}