Skip to content

Commit d11ccdd

Browse files
committed
fix: suppuort automountServiceAccountToken
fix #660 and #607 Signed-off-by: lan.tian <[email protected]>
1 parent 9de00ba commit d11ccdd

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-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
mergeMap(modified, &existing.NodeSelector, required.NodeSelector)

lib/resourcemerge/core_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,37 @@ func TestEnsurePodSpec(t *testing.T) {
4545
Containers: []corev1.Container{
4646
{Name: "test"}}},
4747
},
48+
{
49+
name: "AutomountServiceAccountToken none",
50+
existing: corev1.PodSpec{
51+
AutomountServiceAccountToken: boolPtr(false)},
52+
input: corev1.PodSpec{},
53+
54+
expectedModified: true,
55+
expected: corev1.PodSpec{},
56+
},
57+
{
58+
name: "AutomountServiceAccountToken changed",
59+
existing: corev1.PodSpec{
60+
AutomountServiceAccountToken: boolPtr(true)},
61+
input: corev1.PodSpec{
62+
AutomountServiceAccountToken: boolPtr(false)},
63+
64+
expectedModified: true,
65+
expected: corev1.PodSpec{
66+
AutomountServiceAccountToken: boolPtr(false)},
67+
},
68+
{
69+
name: "AutomountServiceAccountToken no changes",
70+
existing: corev1.PodSpec{
71+
AutomountServiceAccountToken: boolPtr(false)},
72+
input: corev1.PodSpec{
73+
AutomountServiceAccountToken: boolPtr(false)},
74+
75+
expectedModified: false,
76+
expected: corev1.PodSpec{
77+
AutomountServiceAccountToken: boolPtr(false)},
78+
},
4879
{
4980
name: "PodSecurityContext empty",
5081
existing: corev1.PodSpec{

0 commit comments

Comments
 (0)