@@ -42,7 +42,7 @@ func defaultDeployment() appsv1.Deployment {
4242 Containers : []corev1.Container {
4343 {
4444 Name : "manager" ,
45- Image : "hashicorp/hcp-terraform-operator:2.7.0" ,
45+ Image : fmt . Sprintf ( "hashicorp/hcp-terraform-operator:%s" , helmChartVersion ) ,
4646 Command : []string {"/manager" },
4747 Args : []string {
4848 "--sync-period=1h" ,
@@ -171,51 +171,6 @@ func TestDeploymentNamespace(t *testing.T) {
171171 assert .Equal (t , d , deployment )
172172}
173173
174- func TestDeploymentReplicas (t * testing.T ) {
175- options := & helm.Options {
176- SetValues : map [string ]string {
177- "replicaCount" : "5" ,
178- },
179- Version : helmChartVersion ,
180- }
181- deployment := renderDeploymentManifest (t , options )
182- d := defaultDeployment ()
183- d .Spec .Replicas = ptr .To (int32 (5 ))
184-
185- assert .Equal (t , d , deployment )
186- }
187-
188- func TestDeploymentPriorityClassName (t * testing.T ) {
189- priorityClassName := "high-priority"
190- options := & helm.Options {
191- SetValues : map [string ]string {
192- "priorityClassName" : priorityClassName ,
193- },
194- Version : helmChartVersion ,
195- }
196- deployment := renderDeploymentManifest (t , options )
197- d := defaultDeployment ()
198- d .Spec .Template .Spec .PriorityClassName = priorityClassName
199-
200- assert .Equal (t , d , deployment )
201- }
202-
203- func TestDeploymentServiceAccountName (t * testing.T ) {
204- serviceAccountName := "this"
205- options := & helm.Options {
206- SetValues : map [string ]string {
207- "serviceAccount.create" : "true" ,
208- "serviceAccount.name" : serviceAccountName ,
209- },
210- Version : helmChartVersion ,
211- }
212- deployment := renderDeploymentManifest (t , options )
213- d := defaultDeployment ()
214- d .Spec .Template .Spec .ServiceAccountName = serviceAccountName
215-
216- assert .Equal (t , d , deployment )
217- }
218-
219174func TestDeploymentImagePullSecrets (t * testing.T ) {
220175 options := & helm.Options {
221176 SetJsonValues : map [string ]string {
@@ -251,83 +206,46 @@ func TestDeploymentPodLabels(t *testing.T) {
251206 assert .Equal (t , d , deployment )
252207}
253208
254- func TestDeploymentSecurityContext (t * testing.T ) {
209+ func TestDeploymentReplicaCount (t * testing.T ) {
255210 options := & helm.Options {
256- Version : helmChartVersion ,
257211 SetValues : map [string ]string {
258- "securityContext.runAsNonRoot " : "false " ,
212+ "replicaCount " : "5 " ,
259213 },
214+ Version : helmChartVersion ,
260215 }
261216 deployment := renderDeploymentManifest (t , options )
262217 d := defaultDeployment ()
263-
264- d .Spec .Template .Spec .SecurityContext .RunAsNonRoot = ptr .To (false )
218+ d .Spec .Replicas = ptr .To (int32 (5 ))
265219
266220 assert .Equal (t , d , deployment )
267221}
268222
269- func TestDeploymentCustomCAcertificates (t * testing.T ) {
223+ func TestDeploymentSecurityContext (t * testing.T ) {
270224 options := & helm.Options {
271225 Version : helmChartVersion ,
272226 SetValues : map [string ]string {
273- "customCAcertificates " : "SGVsbG8gV29ybGQ= " ,
227+ "securityContext.runAsNonRoot " : "false " ,
274228 },
275229 }
276230 deployment := renderDeploymentManifest (t , options )
277231 d := defaultDeployment ()
278232
279- d .Spec .Template .Spec .Volumes = []corev1.Volume {
280- {
281- Name : "ca-certificates" ,
282- VolumeSource : corev1.VolumeSource {
283- ConfigMap : & corev1.ConfigMapVolumeSource {
284- LocalObjectReference : corev1.LocalObjectReference {
285- Name : fmt .Sprintf ("%s-ca-certificates" , helmReleaseName ),
286- },
287- },
288- },
289- },
290- }
291- d .Spec .Template .Spec .Containers [0 ].VolumeMounts = []corev1.VolumeMount {
292- {
293- Name : "ca-certificates" ,
294- ReadOnly : true ,
295- MountPath : "/etc/ssl/certs/custom-ca-certificates.crt" ,
296- SubPath : "ca-certificates" ,
297- },
298- }
233+ d .Spec .Template .Spec .SecurityContext .RunAsNonRoot = ptr .To (false )
299234
300235 assert .Equal (t , d , deployment )
301236}
302237
303- func TestDeploymentControllers (t * testing.T ) {
238+ func TestDeploymentPriorityClassName (t * testing.T ) {
239+ priorityClassName := "high-priority"
304240 options := & helm.Options {
305- Version : helmChartVersion ,
306241 SetValues : map [string ]string {
307- "controllers.agentPool.workers" : "5" ,
308- "controllers.agentPool.syncPeriod" : "15m" ,
309- "controllers.module.workers" : "5" ,
310- "controllers.module.syncPeriod" : "15m" ,
311- "controllers.project.workers" : "5" ,
312- "controllers.project.syncPeriod" : "15m" ,
313- "controllers.workspace.workers" : "5" ,
314- "controllers.workspace.syncPeriod" : "15m" ,
242+ "priorityClassName" : priorityClassName ,
315243 },
244+ Version : helmChartVersion ,
316245 }
317246 deployment := renderDeploymentManifest (t , options )
318247 d := defaultDeployment ()
319-
320- d .Spec .Template .Spec .Containers [0 ].Args = []string {
321- "--sync-period=1h" ,
322- "--agent-pool-workers=5" ,
323- "--agent-pool-sync-period=15m" ,
324- "--module-workers=5" ,
325- "--module-sync-period=15m" ,
326- "--project-workers=5" ,
327- "--project-sync-period=15m" ,
328- "--workspace-workers=5" ,
329- "--workspace-sync-period=15m" ,
330- }
248+ d .Spec .Template .Spec .PriorityClassName = priorityClassName
331249
332250 assert .Equal (t , d , deployment )
333251}
@@ -470,5 +388,94 @@ func TestDeploymentOperatorSkipTLSVerify(t *testing.T) {
470388 assert .Equal (t , d , deployment )
471389}
472390
391+ // KUBERBAC PROXY >>>
392+ // KUBERBAC PROXY <<<
393+
394+ func TestDeploymentControllers (t * testing.T ) {
395+ options := & helm.Options {
396+ Version : helmChartVersion ,
397+ SetValues : map [string ]string {
398+ "controllers.agentPool.workers" : "5" ,
399+ "controllers.agentPool.syncPeriod" : "15m" ,
400+ "controllers.module.workers" : "5" ,
401+ "controllers.module.syncPeriod" : "15m" ,
402+ "controllers.project.workers" : "5" ,
403+ "controllers.project.syncPeriod" : "15m" ,
404+ "controllers.workspace.workers" : "5" ,
405+ "controllers.workspace.syncPeriod" : "15m" ,
406+ },
407+ }
408+ deployment := renderDeploymentManifest (t , options )
409+ d := defaultDeployment ()
410+
411+ d .Spec .Template .Spec .Containers [0 ].Args = []string {
412+ "--sync-period=1h" ,
413+ "--agent-pool-workers=5" ,
414+ "--agent-pool-sync-period=15m" ,
415+ "--module-workers=5" ,
416+ "--module-sync-period=15m" ,
417+ "--project-workers=5" ,
418+ "--project-sync-period=15m" ,
419+ "--workspace-workers=5" ,
420+ "--workspace-sync-period=15m" ,
421+ }
422+
423+ assert .Equal (t , d , deployment )
424+ }
425+
426+ func TestDeploymentCustomCAcertificates (t * testing.T ) {
427+ options := & helm.Options {
428+ Version : helmChartVersion ,
429+ SetValues : map [string ]string {
430+ "customCAcertificates" : "SGVsbG8gV29ybGQ=" ,
431+ },
432+ }
433+ deployment := renderDeploymentManifest (t , options )
434+ d := defaultDeployment ()
435+
436+ d .Spec .Template .Spec .Volumes = []corev1.Volume {
437+ {
438+ Name : "ca-certificates" ,
439+ VolumeSource : corev1.VolumeSource {
440+ ConfigMap : & corev1.ConfigMapVolumeSource {
441+ LocalObjectReference : corev1.LocalObjectReference {
442+ Name : fmt .Sprintf ("%s-ca-certificates" , helmReleaseName ),
443+ },
444+ },
445+ },
446+ },
447+ }
448+ d .Spec .Template .Spec .Containers [0 ].VolumeMounts = []corev1.VolumeMount {
449+ {
450+ Name : "ca-certificates" ,
451+ ReadOnly : true ,
452+ MountPath : "/etc/ssl/certs/custom-ca-certificates.crt" ,
453+ SubPath : "ca-certificates" ,
454+ },
455+ }
456+
457+ assert .Equal (t , d , deployment )
458+ }
459+
460+ func TestDeploymentServiceAccountName (t * testing.T ) {
461+ serviceAccountName := "this"
462+ options := & helm.Options {
463+ SetValues : map [string ]string {
464+ "serviceAccount.create" : "true" ,
465+ "serviceAccount.name" : serviceAccountName ,
466+ },
467+ Version : helmChartVersion ,
468+ }
469+ deployment := renderDeploymentManifest (t , options )
470+ d := defaultDeployment ()
471+ d .Spec .Template .Spec .ServiceAccountName = serviceAccountName
472+
473+ assert .Equal (t , d , deployment )
474+ }
475+
476+ // RBAC >>>
477+ // RBAC <<<
478+
473479// TODO:
474480// - kubeRbacProxy.*
481+ // - RBAC
0 commit comments