@@ -14,6 +14,7 @@ import (
14
14
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
15
15
16
16
"github.com/d2iq-labs/capi-runtime-extensions/common/pkg/capi/clustertopology/patches/matchers"
17
+ "github.com/d2iq-labs/capi-runtime-extensions/common/pkg/capi/clustertopology/patches/selectors"
17
18
)
18
19
19
20
func TestMatchesSelector (t * testing.T ) {
@@ -478,6 +479,74 @@ func TestMatchesSelector(t *testing.T) {
478
479
},
479
480
},
480
481
match : false ,
482
+ }, {
483
+ name : "Match InfrastructureWorkerMachineTemplates" ,
484
+ obj : & unstructured.Unstructured {
485
+ Object : map [string ]interface {}{
486
+ "apiVersion" : "infrastructure.cluster.x-k8s.io/v1beta1" ,
487
+ "kind" : "DockerMachineTemplate" ,
488
+ },
489
+ },
490
+ holderRef : & runtimehooksv1.HolderReference {
491
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
492
+ Kind : "MachineDeployment" ,
493
+ Name : "docker-quick-start-md-0" ,
494
+ Namespace : "default" ,
495
+ FieldPath : "spec.template.spec.infrastructureRef" ,
496
+ },
497
+ selector : selectors .InfrastructureWorkerMachineTemplates ("v1beta1" , "DockerMachineTemplate" ),
498
+ match : true ,
499
+ }, {
500
+ name : "Match InfrastructureControlPlaneMachines" ,
501
+ obj : & unstructured.Unstructured {
502
+ Object : map [string ]interface {}{
503
+ "apiVersion" : "infrastructure.cluster.x-k8s.io/v1beta1" ,
504
+ "kind" : "DockerMachineTemplate" ,
505
+ },
506
+ },
507
+ holderRef : & runtimehooksv1.HolderReference {
508
+ APIVersion : "controlplane.cluster.x-k8s.io/v1beta1" ,
509
+ Kind : "KubeadmControlPlane" ,
510
+ Name : "docker-quick-start" ,
511
+ Namespace : "default" ,
512
+ FieldPath : "spec.machineTemplate.infrastructureRef" ,
513
+ },
514
+ selector : selectors .InfrastructureControlPlaneMachines ("v1beta1" , "DockerMachineTemplate" ),
515
+ match : true ,
516
+ }, {
517
+ name : "Don't match InfrastructureControlPlaneMachines for a MachineDeployment holderRef" ,
518
+ obj : & unstructured.Unstructured {
519
+ Object : map [string ]interface {}{
520
+ "apiVersion" : "infrastructure.cluster.x-k8s.io/v1beta1" ,
521
+ "kind" : "DockerMachineTemplate" ,
522
+ },
523
+ },
524
+ holderRef : & runtimehooksv1.HolderReference {
525
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
526
+ Kind : "MachineDeployment" ,
527
+ Name : "docker-quick-start-md-0" ,
528
+ Namespace : "default" ,
529
+ FieldPath : "spec.template.spec.infrastructureRef" ,
530
+ },
531
+ selector : selectors .InfrastructureControlPlaneMachines ("v1beta1" , "DockerMachineTemplate" ),
532
+ match : false ,
533
+ }, {
534
+ name : "Don't match InfrastructureWorkerMachineTemplates for a KubeadmControlPlane holderRef" ,
535
+ obj : & unstructured.Unstructured {
536
+ Object : map [string ]interface {}{
537
+ "apiVersion" : "infrastructure.cluster.x-k8s.io/v1beta1" ,
538
+ "kind" : "DockerMachineTemplate" ,
539
+ },
540
+ },
541
+ holderRef : & runtimehooksv1.HolderReference {
542
+ APIVersion : "controlplane.cluster.x-k8s.io/v1beta1" ,
543
+ Kind : "KubeadmControlPlane" ,
544
+ Name : "docker-quick-start" ,
545
+ Namespace : "default" ,
546
+ FieldPath : "spec.machineTemplate.infrastructureRef" ,
547
+ },
548
+ selector : selectors .InfrastructureWorkerMachineTemplates ("v1beta1" , "DockerMachineTemplate" ),
549
+ match : false ,
481
550
}}
482
551
for idx := range tests {
483
552
tt := tests [idx ]
0 commit comments