Skip to content

Commit 4dbe9c8

Browse files
authored
Merge pull request #1836 from marquiz/devel/e2e-ptr
test/e2e: use ptr.To to get pointer to bool
2 parents bbd4ac8 + 8a6853f commit 4dbe9c8

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

test/e2e/utils/pod/pod.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ type SpecOption func(spec *corev1.PodSpec)
120120

121121
// NFDMaster provide NFD master pod definition
122122
func NFDMaster(opts ...SpecOption) *corev1.Pod {
123-
yes := true
124-
no := false
125123
p := &corev1.Pod{
126124
ObjectMeta: metav1.ObjectMeta{
127125
GenerateName: "nfd-master-",
@@ -147,10 +145,10 @@ func NFDMaster(opts ...SpecOption) *corev1.Pod {
147145
Capabilities: &corev1.Capabilities{
148146
Drop: []corev1.Capability{"ALL"},
149147
},
150-
Privileged: &no,
151-
RunAsNonRoot: &yes,
152-
ReadOnlyRootFilesystem: &yes,
153-
AllowPrivilegeEscalation: &no,
148+
Privileged: ptr.To[bool](false),
149+
RunAsNonRoot: ptr.To[bool](true),
150+
ReadOnlyRootFilesystem: ptr.To[bool](true),
151+
AllowPrivilegeEscalation: ptr.To[bool](false),
154152
SeccompProfile: &corev1.SeccompProfile{
155153
Type: corev1.SeccompProfileTypeRuntimeDefault,
156154
},
@@ -252,8 +250,6 @@ func SpecWithConfigMap(name, mountPath string) SpecOption {
252250
}
253251

254252
func nfdWorkerSpec(opts ...SpecOption) *corev1.PodSpec {
255-
yes := true
256-
no := false
257253
p := &corev1.PodSpec{
258254
Containers: []corev1.Container{
259255
{
@@ -291,10 +287,10 @@ func nfdWorkerSpec(opts ...SpecOption) *corev1.PodSpec {
291287
Capabilities: &corev1.Capabilities{
292288
Drop: []corev1.Capability{"ALL"},
293289
},
294-
Privileged: &no,
295-
RunAsNonRoot: &yes,
296-
ReadOnlyRootFilesystem: &yes,
297-
AllowPrivilegeEscalation: &no,
290+
Privileged: ptr.To[bool](false),
291+
RunAsNonRoot: ptr.To[bool](true),
292+
ReadOnlyRootFilesystem: ptr.To[bool](true),
293+
AllowPrivilegeEscalation: ptr.To[bool](false),
298294
SeccompProfile: &corev1.SeccompProfile{
299295
Type: corev1.SeccompProfileTypeRuntimeDefault,
300296
},
@@ -372,8 +368,6 @@ func nfdWorkerSpec(opts ...SpecOption) *corev1.PodSpec {
372368
}
373369

374370
func NFDGCSpec(opts ...SpecOption) *corev1.PodSpec {
375-
yes := true
376-
no := false
377371
p := &corev1.PodSpec{
378372
Containers: []corev1.Container{
379373
{
@@ -384,10 +378,10 @@ func NFDGCSpec(opts ...SpecOption) *corev1.PodSpec {
384378
Capabilities: &corev1.Capabilities{
385379
Drop: []corev1.Capability{"ALL"},
386380
},
387-
Privileged: &no,
388-
RunAsNonRoot: &yes,
389-
ReadOnlyRootFilesystem: &yes,
390-
AllowPrivilegeEscalation: &no,
381+
Privileged: ptr.To[bool](false),
382+
RunAsNonRoot: ptr.To[bool](true),
383+
ReadOnlyRootFilesystem: ptr.To[bool](true),
384+
AllowPrivilegeEscalation: ptr.To[bool](false),
391385
SeccompProfile: &corev1.SeccompProfile{
392386
Type: corev1.SeccompProfileTypeRuntimeDefault,
393387
},

0 commit comments

Comments
 (0)