-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker_config.go
101 lines (91 loc) · 2.73 KB
/
docker_config.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
89
90
91
92
93
94
95
96
97
98
99
100
101
package translator
import (
"strings"
"github.com/Shopify/go-lua"
"github.com/fsouza/go-dockerclient"
"github.com/involucro/involucro/ilog"
)
// ParseImageConfigFromLuaTable reads all keys in the currently top-most
// table from the stack and applies everything it can to a docker.Config.
// The comparison is case insensitive by design.
func ParseImageConfigFromLuaTable(l *lua.State) docker.Config {
lua.CheckType(l, -1, lua.TypeTable)
conf := docker.Config{}
l.PushNil()
for l.Next(-2) {
switch strings.ToLower(lua.CheckString(l, -2)) {
case "hostname":
conf.Hostname = lua.CheckString(l, -1)
case "domainname":
conf.Domainname = lua.CheckString(l, -1)
case "user":
conf.User = lua.CheckString(l, -1)
case "cpuset":
conf.CPUSet = lua.CheckString(l, -1)
case "stopsignal":
conf.StopSignal = lua.CheckString(l, -1)
case "image":
conf.Image = lua.CheckString(l, -1)
case "volumedriver":
conf.VolumeDriver = lua.CheckString(l, -1)
case "volumesfrom":
conf.VolumesFrom = lua.CheckString(l, -1)
case "workingdir":
conf.WorkingDir = lua.CheckString(l, -1)
case "macaddress":
conf.MacAddress = lua.CheckString(l, -1)
case "memory":
conf.Memory = int64(lua.CheckInteger(l, -1))
case "memoryswap":
conf.MemorySwap = int64(lua.CheckInteger(l, -1))
case "memoryreservation":
conf.MemoryReservation = int64(lua.CheckInteger(l, -1))
case "kernelmemory":
conf.KernelMemory = int64(lua.CheckInteger(l, -1))
case "cpushares":
conf.CPUShares = int64(lua.CheckInteger(l, -1))
case "attachstdin":
conf.AttachStdin = checkBoolean(l, -1)
case "attachstdout":
conf.AttachStdout = checkBoolean(l, -1)
case "attachstderr":
conf.AttachStderr = checkBoolean(l, -1)
case "tty":
conf.Tty = checkBoolean(l, -1)
case "openstdin":
conf.OpenStdin = checkBoolean(l, -1)
case "stdinonce":
conf.StdinOnce = checkBoolean(l, -1)
case "networkdisabled":
conf.NetworkDisabled = checkBoolean(l, -1)
case "portspecs":
conf.PortSpecs = checkStringArray(l, -1)
case "env":
conf.Env = checkStringArray(l, -1)
case "cmd":
conf.Cmd = checkStringArray(l, -1)
case "dns":
conf.DNS = checkStringArray(l, -1)
case "entrypoint":
conf.Entrypoint = checkStringArray(l, -1)
case "securityopts":
conf.SecurityOpts = checkStringArray(l, -1)
case "onbuild":
conf.OnBuild = checkStringArray(l, -1)
case "labels":
conf.Labels = checkStringMap(l, -1)
case "exposedports", "ports", "expose":
conf.ExposedPorts = parseExposedPorts(l, -1)
case "volumes":
conf.Volumes = checkStringSet(l, -1)
default:
ilog.Warn.Logf("Unrecognized setting [%s] in config, ignoring", lua.CheckString(l, -2))
}
l.Pop(1)
}
return conf
}
/*
not implemented:
Mounts []Mount
*/