-
Notifications
You must be signed in to change notification settings - Fork 239
/
containertool.go
56 lines (50 loc) · 940 Bytes
/
containertool.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
package containertools
type ContainerTool int
const (
NoneTool ContainerTool = iota
PodmanTool
DockerTool
)
func (t ContainerTool) String() (s string) {
switch t {
case NoneTool:
s = "none"
case PodmanTool:
s = "podman"
case DockerTool:
s = "docker"
}
return
}
func (t ContainerTool) CommandFactory() CommandFactory {
switch t {
case PodmanTool:
return &PodmanCommandFactory{}
case DockerTool:
return &DockerCommandFactory{}
}
return &StubCommandFactory{}
}
func NewContainerTool(s string, defaultTool ContainerTool) (t ContainerTool) {
switch s {
case "podman":
t = PodmanTool
case "docker":
t = DockerTool
case "none":
t = NoneTool
default:
t = defaultTool
}
return
}
// NewCommandContainerTool returns a tool that can be used in `exec` statements.
func NewCommandContainerTool(s string) (t ContainerTool) {
switch s {
case "docker":
t = DockerTool
default:
t = PodmanTool
}
return
}