-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
88 lines (75 loc) · 2.27 KB
/
options.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package docker
import (
"fmt"
"io"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
commonModel "github.com/hckops/hckctl/pkg/common/model"
)
type ContainerConfigOpts struct {
ImageName string
Hostname string
Env []ContainerEnv
Ports []ContainerPort
Tty bool
Entrypoint []string
Cmd []string
Labels commonModel.Labels
}
type ContainerHostConfigOpts struct {
NetworkMode string
PortConfig *ContainerPortConfigOpts
Volumes []ContainerVolume
}
type ContainerPortConfigOpts struct {
Ports []ContainerPort
OnPortBindCallback func(port ContainerPort)
}
type ImagePullOpts struct {
ImageName string
Platform *ocispec.Platform
OnImagePullCallback func()
}
func (o *ImagePullOpts) PlatformString() string {
return fmt.Sprintf("%s/%s", o.Platform.OS, o.Platform.Architecture)
}
type ImageRemoveOpts struct {
OnImageRemoveCallback func(imageId string)
OnImageRemoveErrorCallback func(imageId string, err error)
}
type ContainerCreateOpts struct {
ContainerName string
ContainerConfig *container.Config
HostConfig *container.HostConfig
NetworkingConfig *network.NetworkingConfig
Platform *ocispec.Platform
WaitStatus bool
CaptureInterrupt bool
OnContainerInterruptCallback func(containerId string)
OnContainerCreateCallback func(containerId string) error
OnContainerWaitCallback func(containerId string) error
OnContainerStatusCallback func(status string)
OnContainerStartCallback func()
}
type ContainerRestartOpts struct {
ContainerId string
OnRestartCallback func(string)
}
type ContainerExecOpts struct {
ContainerId string
Commands []string
InStream io.ReadCloser
OutStream io.Writer
ErrStream io.Writer
IsTty bool
OnContainerExecCallback func()
OnStreamCloseCallback func()
OnStreamErrorCallback func(error)
}
type ContainerLogsOpts struct {
ContainerId string
OutStream io.Writer
OnStreamCloseCallback func()
OnStreamErrorCallback func(error)
}