Skip to content

Commit f340c40

Browse files
Merge pull request #1264 from tchap/reconcile-automountServiceAccountToken
OCPBUGS-60568: lib/resourcemerge: Add support for automountServiceAccountToken
2 parents 85a076c + 30036c8 commit f340c40

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

lib/resourcemerge/core.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func ensurePodSpec(modified *bool, existing *corev1.PodSpec, required corev1.Pod
4545
}
4646
}
4747

48+
setBoolPtr(modified, &existing.AutomountServiceAccountToken, required.AutomountServiceAccountToken)
4849
setStringIfSet(modified, &existing.ServiceAccountName, required.ServiceAccountName)
4950
setBool(modified, &existing.HostNetwork, required.HostNetwork)
5051
setBoolPtr(modified, &existing.HostUsers, required.HostUsers)

lib/resourcemerge/core_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,56 @@ func TestEnsurePodSpec(t *testing.T) {
5656
HostUsers: boolPtr(false),
5757
},
5858
},
59+
{
60+
name: "automountServiceAccountToken is set",
61+
existing: corev1.PodSpec{},
62+
input: corev1.PodSpec{
63+
AutomountServiceAccountToken: boolPtr(false),
64+
},
65+
66+
expectedModified: true,
67+
expected: corev1.PodSpec{
68+
AutomountServiceAccountToken: boolPtr(false),
69+
},
70+
},
71+
{
72+
name: "automountServiceAccountToken is unset",
73+
existing: corev1.PodSpec{
74+
AutomountServiceAccountToken: boolPtr(false),
75+
},
76+
input: corev1.PodSpec{},
77+
78+
expectedModified: true,
79+
expected: corev1.PodSpec{},
80+
},
81+
{
82+
name: "automountServiceAccountToken is changed",
83+
existing: corev1.PodSpec{
84+
AutomountServiceAccountToken: boolPtr(true),
85+
},
86+
input: corev1.PodSpec{
87+
AutomountServiceAccountToken: boolPtr(false),
88+
},
89+
90+
expectedModified: true,
91+
expected: corev1.PodSpec{
92+
AutomountServiceAccountToken: boolPtr(false),
93+
},
94+
},
95+
{
96+
name: "automountServiceAccountToken is unchanged",
97+
existing: corev1.PodSpec{
98+
AutomountServiceAccountToken: boolPtr(false),
99+
},
100+
input: corev1.PodSpec{
101+
AutomountServiceAccountToken: boolPtr(false),
102+
},
103+
104+
expectedModified: false,
105+
expected: corev1.PodSpec{
106+
AutomountServiceAccountToken: boolPtr(false),
107+
},
108+
},
59109
{
60110
name: "PodSecurityContext empty",
61111
existing: corev1.PodSpec{

0 commit comments

Comments
 (0)