Skip to content

Commit 344dd90

Browse files
committed
Fix golint failures in pkg/securitycontext
1 parent b1fea1b commit 344dd90

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ pkg/security/podsecuritypolicy/seccomp
314314
pkg/security/podsecuritypolicy/selinux
315315
pkg/security/podsecuritypolicy/user
316316
pkg/security/podsecuritypolicy/util
317-
pkg/securitycontext
318317
pkg/serviceaccount
319318
pkg/ssh
320319
pkg/util/bandwidth

pkg/securitycontext/accessors.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ func (w *podSecurityContextWrapper) SetFSGroup(v *int64) {
201201
w.podSC.FSGroup = v
202202
}
203203

204+
// ContainerSecurityContextAccessor allows reading the values of a SecurityContext object
204205
type ContainerSecurityContextAccessor interface {
205206
Capabilities() *api.Capabilities
206207
Privileged() *bool
@@ -213,6 +214,7 @@ type ContainerSecurityContextAccessor interface {
213214
AllowPrivilegeEscalation() *bool
214215
}
215216

217+
// ContainerSecurityContextMutator allows reading and writing the values of a SecurityContext object
216218
type ContainerSecurityContextMutator interface {
217219
ContainerSecurityContextAccessor
218220

@@ -228,10 +230,14 @@ type ContainerSecurityContextMutator interface {
228230
SetAllowPrivilegeEscalation(*bool)
229231
}
230232

233+
// NewContainerSecurityContextAccessor returns an accessor for the provided container security context
234+
// May be initialized with a nil SecurityContext
231235
func NewContainerSecurityContextAccessor(containerSC *api.SecurityContext) ContainerSecurityContextAccessor {
232236
return &containerSecurityContextWrapper{containerSC: containerSC}
233237
}
234238

239+
// NewContainerSecurityContextMutator returns a mutator for the provided container security context
240+
// May be initialized with a nil SecurityContext
235241
func NewContainerSecurityContextMutator(containerSC *api.SecurityContext) ContainerSecurityContextMutator {
236242
return &containerSecurityContextWrapper{containerSC: containerSC}
237243
}
@@ -365,10 +371,14 @@ func (w *containerSecurityContextWrapper) SetAllowPrivilegeEscalation(v *bool) {
365371
w.containerSC.AllowPrivilegeEscalation = v
366372
}
367373

374+
// NewEffectiveContainerSecurityContextAccessor returns an accessor for reading effective values
375+
// for the provided pod security context and container security context
368376
func NewEffectiveContainerSecurityContextAccessor(podSC PodSecurityContextAccessor, containerSC ContainerSecurityContextMutator) ContainerSecurityContextAccessor {
369377
return &effectiveContainerSecurityContextWrapper{podSC: podSC, containerSC: containerSC}
370378
}
371379

380+
// NewEffectiveContainerSecurityContextMutator returns a mutator for reading and writing effective values
381+
// for the provided pod security context and container security context
372382
func NewEffectiveContainerSecurityContextMutator(podSC PodSecurityContextAccessor, containerSC ContainerSecurityContextMutator) ContainerSecurityContextMutator {
373383
return &effectiveContainerSecurityContextWrapper{podSC: podSC, containerSC: containerSC}
374384
}

pkg/securitycontext/util.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func HasCapabilitiesRequest(container *v1.Container) bool {
4444
return len(container.SecurityContext.Capabilities.Add) > 0 || len(container.SecurityContext.Capabilities.Drop) > 0
4545
}
4646

47+
// DetermineEffectiveSecurityContext returns a synthesized SecurityContext for reading effective configurations
48+
// from the provided pod's and container's security context. Container's fields take precedence in cases where both
49+
// are set
4750
func DetermineEffectiveSecurityContext(pod *v1.Pod, container *v1.Container) *v1.SecurityContext {
4851
effectiveSc := securityContextFromPodSecurityContext(pod)
4952
containerSc := container.SecurityContext

0 commit comments

Comments
 (0)