forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
container_rich_mode.go
53 lines (41 loc) · 963 Bytes
/
container_rich_mode.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
package mgr
import (
"fmt"
"github.com/alibaba/pouch/apis/types"
)
const (
richModeEnv = "rich_mode=true"
richModeLaunchEnv = "rich_mode_launch_manner"
//for ali internal
interRichModeEnv = "ali_run_mode=common_vm"
)
func richContainerModeEnv(c *Container) []string {
var (
ret = []string{}
setRichMode = false
richMode = ""
)
envs := c.Config.Env
//if set inter_rich_mode_env, you can also run in rich container mode
for _, e := range envs {
if e == interRichModeEnv {
setRichMode = true
richMode = types.ContainerConfigRichModeSystemd
break
}
}
if c.Config.Rich {
setRichMode = true
}
if c.Config.RichMode != "" {
richMode = c.Config.RichMode
}
//if not set rich mode manner, default set dumb-init
if richMode == "" {
richMode = types.ContainerConfigRichModeDumbInit
}
if setRichMode {
ret = append(ret, richModeEnv, fmt.Sprintf("%s=%s", richModeLaunchEnv, richMode))
}
return ret
}