@@ -37,7 +37,7 @@ const (
37
37
maxRespBodyLength = 10 * 1 << 10 // 10KB
38
38
)
39
39
40
- type HandlerRunner struct {
40
+ type handlerRunner struct {
41
41
httpGetter kubetypes.HTTPGetter
42
42
commandRunner kubecontainer.CommandRunner
43
43
containerManager podStatusProvider
@@ -47,15 +47,16 @@ type podStatusProvider interface {
47
47
GetPodStatus (uid types.UID , name , namespace string ) (* kubecontainer.PodStatus , error )
48
48
}
49
49
50
+ // NewHandlerRunner returns a configured lifecycle handler for a container.
50
51
func NewHandlerRunner (httpGetter kubetypes.HTTPGetter , commandRunner kubecontainer.CommandRunner , containerManager podStatusProvider ) kubecontainer.HandlerRunner {
51
- return & HandlerRunner {
52
+ return & handlerRunner {
52
53
httpGetter : httpGetter ,
53
54
commandRunner : commandRunner ,
54
55
containerManager : containerManager ,
55
56
}
56
57
}
57
58
58
- func (hr * HandlerRunner ) Run (containerID kubecontainer.ContainerID , pod * v1.Pod , container * v1.Container , handler * v1.Handler ) (string , error ) {
59
+ func (hr * handlerRunner ) Run (containerID kubecontainer.ContainerID , pod * v1.Pod , container * v1.Container , handler * v1.Handler ) (string , error ) {
59
60
switch {
60
61
case handler .Exec != nil :
61
62
var msg string
@@ -104,7 +105,7 @@ func resolvePort(portReference intstr.IntOrString, container *v1.Container) (int
104
105
return - 1 , fmt .Errorf ("couldn't find port: %v in %v" , portReference , container )
105
106
}
106
107
107
- func (hr * HandlerRunner ) runHTTPHandler (pod * v1.Pod , container * v1.Container , handler * v1.Handler ) (string , error ) {
108
+ func (hr * handlerRunner ) runHTTPHandler (pod * v1.Pod , container * v1.Container , handler * v1.Handler ) (string , error ) {
108
109
host := handler .HTTPGet .Host
109
110
if len (host ) == 0 {
110
111
status , err := hr .containerManager .GetPodStatus (pod .UID , pod .Name , pod .Namespace )
@@ -129,10 +130,10 @@ func (hr *HandlerRunner) runHTTPHandler(pod *v1.Pod, container *v1.Container, ha
129
130
}
130
131
url := fmt .Sprintf ("http://%s/%s" , net .JoinHostPort (host , strconv .Itoa (port )), handler .HTTPGet .Path )
131
132
resp , err := hr .httpGetter .Get (url )
132
- return getHttpRespBody (resp ), err
133
+ return getHTTPRespBody (resp ), err
133
134
}
134
135
135
- func getHttpRespBody (resp * http.Response ) string {
136
+ func getHTTPRespBody (resp * http.Response ) string {
136
137
if resp == nil {
137
138
return ""
138
139
}
@@ -144,6 +145,8 @@ func getHttpRespBody(resp *http.Response) string {
144
145
return ""
145
146
}
146
147
148
+ // NewAppArmorAdmitHandler returns a PodAdmitHandler which is used to evaluate
149
+ // if a pod can be admitted from the perspective of AppArmor.
147
150
func NewAppArmorAdmitHandler (validator apparmor.Validator ) PodAdmitHandler {
148
151
return & appArmorAdmitHandler {
149
152
Validator : validator ,
@@ -171,6 +174,8 @@ func (a *appArmorAdmitHandler) Admit(attrs *PodAdmitAttributes) PodAdmitResult {
171
174
}
172
175
}
173
176
177
+ // NewNoNewPrivsAdmitHandler returns a PodAdmitHandler which is used to evaluate
178
+ // if a pod can be admitted from the perspective of NoNewPrivs.
174
179
func NewNoNewPrivsAdmitHandler (runtime kubecontainer.Runtime ) PodAdmitHandler {
175
180
return & noNewPrivsAdmitHandler {
176
181
Runtime : runtime ,
@@ -236,6 +241,8 @@ func noNewPrivsRequired(pod *v1.Pod) bool {
236
241
return false
237
242
}
238
243
244
+ // NewProcMountAdmitHandler returns a PodAdmitHandler which is used to evaluate
245
+ // if a pod can be admitted from the perspective of ProcMount.
239
246
func NewProcMountAdmitHandler (runtime kubecontainer.Runtime ) PodAdmitHandler {
240
247
return & procMountAdmitHandler {
241
248
Runtime : runtime ,
0 commit comments