@@ -59,6 +59,148 @@ func TestIntegration(t *testing.T) {
5959					},
6060				},
6161			}),
62+ 		NewTestDiff ("pod does not match if a bool pointer value is explicitly set locally (false)" ,
63+ 			& v1.Pod {
64+ 				ObjectMeta : standardObjectMeta (),
65+ 				Spec : v1.PodSpec {
66+ 					Containers : []v1.Container {
67+ 						{
68+ 							Name : "test-container" , Image : "test-image" ,
69+ 						},
70+ 					},
71+ 					Volumes : []v1.Volume {
72+ 						{
73+ 							Name : "empty" ,
74+ 							VolumeSource : v1.VolumeSource {
75+ 								EmptyDir : & v1.EmptyDirVolumeSource {},
76+ 							},
77+ 						},
78+ 					},
79+ 				},
80+ 			}).
81+ 			withLocalChange (func (i  interface {}) {
82+ 				pod  :=  i .(* v1.Pod )
83+ 				pod .Spec .AutomountServiceAccountToken  =  boolRef (false )
84+ 			}),
85+ 		NewTestMatch ("pod does match if a bool pointer value is set only remotely, since we don't set it locally (true)" ,
86+ 			& v1.Pod {
87+ 				ObjectMeta : standardObjectMeta (),
88+ 				Spec : v1.PodSpec {
89+ 					Containers : []v1.Container {
90+ 						{
91+ 							Name : "test-container" , Image : "test-image" ,
92+ 						},
93+ 					},
94+ 					Volumes : []v1.Volume {
95+ 						{
96+ 							Name : "empty" ,
97+ 							VolumeSource : v1.VolumeSource {
98+ 								EmptyDir : & v1.EmptyDirVolumeSource {},
99+ 							},
100+ 						},
101+ 					},
102+ 				},
103+ 			}).
104+ 			withRemoteChange (func (i  interface {}) {
105+ 				pod  :=  i .(* v1.Pod )
106+ 				pod .Spec .AutomountServiceAccountToken  =  boolRef (true )
107+ 			}),
108+ 		NewTestMatch ("pod does match if a bool pointer value is set only remotely, since we don't set it locally (false)" ,
109+ 			& v1.Pod {
110+ 				ObjectMeta : standardObjectMeta (),
111+ 				Spec : v1.PodSpec {
112+ 					Containers : []v1.Container {
113+ 						{
114+ 							Name : "test-container" , Image : "test-image" ,
115+ 						},
116+ 					},
117+ 					Volumes : []v1.Volume {
118+ 						{
119+ 							Name : "empty" ,
120+ 							VolumeSource : v1.VolumeSource {
121+ 								EmptyDir : & v1.EmptyDirVolumeSource {},
122+ 							},
123+ 						},
124+ 					},
125+ 				},
126+ 			}).
127+ 			withRemoteChange (func (i  interface {}) {
128+ 				pod  :=  i .(* v1.Pod )
129+ 				pod .Spec .AutomountServiceAccountToken  =  boolRef (false )
130+ 			}),
131+ 		NewTestDiff ("pod does not match if a bool pointer value is set remotely by a defaulter but a different value locally" ,
132+ 			& v1.Pod {
133+ 				ObjectMeta : standardObjectMeta (),
134+ 				Spec : v1.PodSpec {
135+ 					Containers : []v1.Container {
136+ 						{
137+ 							Name : "test-container" , Image : "test-image" ,
138+ 						},
139+ 					},
140+ 					Volumes : []v1.Volume {
141+ 						{
142+ 							Name : "empty" ,
143+ 							VolumeSource : v1.VolumeSource {
144+ 								EmptyDir : & v1.EmptyDirVolumeSource {},
145+ 							},
146+ 						},
147+ 					},
148+ 				},
149+ 			}).
150+ 			withRemoteChange (func (i  interface {}) {
151+ 				pod  :=  i .(* v1.Pod )
152+ 				pod .Spec .AutomountServiceAccountToken  =  boolRef (true )
153+ 			}).
154+ 			withLocalChange (func (i  interface {}) {
155+ 				pod  :=  i .(* v1.Pod )
156+ 				pod .Spec .AutomountServiceAccountToken  =  boolRef (false )
157+ 			}),
158+ 		NewTestDiff ("pod does not match if a bool value is set locally (true)" ,
159+ 			& v1.Pod {
160+ 				ObjectMeta : standardObjectMeta (),
161+ 				Spec : v1.PodSpec {
162+ 					Containers : []v1.Container {
163+ 						{
164+ 							Name : "test-container" , Image : "test-image" ,
165+ 						},
166+ 					},
167+ 					Volumes : []v1.Volume {
168+ 						{
169+ 							Name : "empty" ,
170+ 							VolumeSource : v1.VolumeSource {
171+ 								EmptyDir : & v1.EmptyDirVolumeSource {},
172+ 							},
173+ 						},
174+ 					},
175+ 				},
176+ 			}).
177+ 			withLocalChange (func (i  interface {}) {
178+ 				pod  :=  i .(* v1.Pod )
179+ 				pod .Spec .HostIPC  =  true 
180+ 			}),
181+ 		NewTestMatch ("pod does match if a bool pointer value is set only remotely (true)" ,
182+ 			& v1.Pod {
183+ 				ObjectMeta : standardObjectMeta (),
184+ 				Spec : v1.PodSpec {
185+ 					Containers : []v1.Container {
186+ 						{
187+ 							Name : "test-container" , Image : "test-image" ,
188+ 						},
189+ 					},
190+ 					Volumes : []v1.Volume {
191+ 						{
192+ 							Name : "empty" ,
193+ 							VolumeSource : v1.VolumeSource {
194+ 								EmptyDir : & v1.EmptyDirVolumeSource {},
195+ 							},
196+ 						},
197+ 					},
198+ 				},
199+ 			}).
200+ 			withRemoteChange (func (i  interface {}) {
201+ 				pod  :=  i .(* v1.Pod )
202+ 				pod .Spec .HostIPC  =  true 
203+ 			}),
62204		NewTestDiff ("pod does not match when a slice item gets removed" ,
63205			& v1.Pod {
64206				ObjectMeta : standardObjectMeta (),
@@ -732,20 +874,20 @@ func TestIntegration(t *testing.T) {
732874				Spec : v1.PodSpec {
733875					Containers : []v1.Container {
734876						{
735- 							Name :     "test-container" ,
736- 							Image :    "test-image" ,
877+ 							Name :  "test-container" ,
878+ 							Image : "test-image" ,
737879						},
738880					},
739881				},
740882			}).
741883			withRemoteChange (func (i  interface {}) {
742- 			pod  :=  i .(* v1.Pod )
743- 			pod .Labels  =  map [string ]string {"a" : "b" }
744- 		}).
884+ 				 pod  :=  i .(* v1.Pod )
885+ 				 pod .Labels  =  map [string ]string {"a" : "b" }
886+ 			 }).
745887			withLocalChange (func (i  interface {}) {
746888				pod  :=  i .(* v1.Pod )
747889				pod .Labels  =  map [string ]string {"c" : "d" }
748- 		}),
890+ 			 }),
749891	}
750892	runAll (t , tests )
751893}
@@ -813,3 +955,7 @@ func scopeRef(scopeType admregv1beta1.ScopeType) *admregv1beta1.ScopeType {
813955func  volumeModeRef (mode  v1.PersistentVolumeMode ) * v1.PersistentVolumeMode  {
814956	return  & mode 
815957}
958+ 
959+ func  boolRef (b  bool ) * bool  {
960+ 	return  & b 
961+ }
0 commit comments