@@ -108,15 +108,16 @@ func TestClusterClassReconciler_reconcile(t *testing.T) {
108
108
WithVariables (
109
109
clusterv1.ClusterClassVariable {
110
110
Name : "hdd" ,
111
- Required : true ,
111
+ Required : ptr . To ( true ) ,
112
112
Schema : clusterv1.VariableSchema {
113
113
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
114
114
Type : "string" ,
115
115
},
116
116
},
117
117
},
118
118
clusterv1.ClusterClassVariable {
119
- Name : "cpu" ,
119
+ Name : "cpu" ,
120
+ Required : ptr .To (false ),
120
121
Schema : clusterv1.VariableSchema {
121
122
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
122
123
Type : "integer" ,
@@ -198,8 +199,11 @@ func assertStatusVariables(actualClusterClass *clusterv1.ClusterClass) error {
198
199
if statusVarDefinition .From != clusterv1 .VariableDefinitionFromInline {
199
200
return errors .Errorf ("ClusterClass status variable %s from field does not match. Expected %s. Got %s" , statusVar .Name , clusterv1 .VariableDefinitionFromInline , statusVarDefinition .From )
200
201
}
201
- if specVar .Required != statusVarDefinition .Required {
202
- return errors .Errorf ("ClusterClass status variable %s required field does not match. Expecte %v. Got %v" , specVar .Name , statusVarDefinition .Required , statusVarDefinition .Required )
202
+ if specVar .Required == nil || statusVarDefinition .Required == nil {
203
+ return errors .Errorf ("ClusterClass spec or status variable %s is nil, expected both to be set" , specVar .Name )
204
+ }
205
+ if * specVar .Required != * statusVarDefinition .Required {
206
+ return errors .Errorf ("ClusterClass status variable %s required field does not match. Expected %v. Got %v" , specVar .Name , statusVarDefinition .Required , statusVarDefinition .Required )
203
207
}
204
208
if ! cmp .Equal (specVar .Schema , statusVarDefinition .Schema ) {
205
209
return errors .Errorf ("ClusterClass status variable %s schema does not match. Expected %v. Got %v" , specVar .Name , specVar .Schema , statusVarDefinition .Schema )
@@ -421,7 +425,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
421
425
WithVariables (
422
426
[]clusterv1.ClusterClassVariable {
423
427
{
424
- Name : "cpu" ,
428
+ Name : "cpu" ,
429
+ Required : ptr .To (true ),
425
430
Schema : clusterv1.VariableSchema {
426
431
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
427
432
Type : "integer" ,
@@ -450,7 +455,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
450
455
},
451
456
},
452
457
{
453
- Name : "memory" ,
458
+ Name : "memory" ,
459
+ Required : ptr .To (false ),
454
460
Schema : clusterv1.VariableSchema {
455
461
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
456
462
Type : "string" ,
@@ -479,7 +485,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
479
485
Name : "cpu" ,
480
486
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
481
487
{
482
- From : clusterv1 .VariableDefinitionFromInline ,
488
+ From : clusterv1 .VariableDefinitionFromInline ,
489
+ Required : ptr .To (true ),
483
490
Schema : clusterv1.VariableSchema {
484
491
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
485
492
Type : "integer" ,
@@ -514,7 +521,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
514
521
Name : "memory" ,
515
522
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
516
523
{
517
- From : clusterv1 .VariableDefinitionFromInline ,
524
+ From : clusterv1 .VariableDefinitionFromInline ,
525
+ Required : ptr .To (false ),
518
526
Schema : clusterv1.VariableSchema {
519
527
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
520
528
Type : "string" ,
@@ -550,6 +558,7 @@ func TestReconciler_reconcileVariables(t *testing.T) {
550
558
{
551
559
Name : "cpu" ,
552
560
// Note: This schema must be exactly equal to the one in clusterClassWithInlineVariables to avoid conflicts.
561
+ Required : true ,
553
562
Schema : clusterv1beta1.VariableSchema {
554
563
OpenAPIV3Schema : clusterv1beta1.JSONSchemaProps {
555
564
Type : "integer" ,
@@ -578,7 +587,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
578
587
},
579
588
},
580
589
{
581
- Name : "memory" ,
590
+ Name : "memory" ,
591
+ Required : false ,
582
592
Schema : clusterv1beta1.VariableSchema {
583
593
OpenAPIV3Schema : clusterv1beta1.JSONSchemaProps {
584
594
Type : "string" ,
@@ -621,7 +631,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
621
631
DefinitionsConflict : ptr .To (false ),
622
632
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
623
633
{
624
- From : clusterv1 .VariableDefinitionFromInline ,
634
+ From : clusterv1 .VariableDefinitionFromInline ,
635
+ Required : ptr .To (true ),
625
636
Schema : clusterv1.VariableSchema {
626
637
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
627
638
Type : "integer" ,
@@ -650,7 +661,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
650
661
},
651
662
},
652
663
{
653
- From : "patch1" ,
664
+ From : "patch1" ,
665
+ Required : ptr .To (true ),
654
666
Schema : clusterv1.VariableSchema {
655
667
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
656
668
Type : "integer" ,
@@ -685,7 +697,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
685
697
DefinitionsConflict : ptr .To (false ),
686
698
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
687
699
{
688
- From : "patch1" ,
700
+ From : "patch1" ,
701
+ Required : ptr .To (false ),
689
702
Schema : clusterv1.VariableSchema {
690
703
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
691
704
Type : "string" ,
@@ -715,7 +728,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
715
728
DefinitionsConflict : ptr .To (false ),
716
729
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
717
730
{
718
- From : clusterv1 .VariableDefinitionFromInline ,
731
+ From : clusterv1 .VariableDefinitionFromInline ,
732
+ Required : ptr .To (false ),
719
733
Schema : clusterv1.VariableSchema {
720
734
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
721
735
Type : "string" ,
@@ -727,7 +741,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
727
741
},
728
742
},
729
743
{
730
- From : "patch1" ,
744
+ From : "patch1" ,
745
+ Required : ptr .To (false ),
731
746
Schema : clusterv1.VariableSchema {
732
747
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
733
748
Type : "string" ,
@@ -861,7 +876,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
861
876
DefinitionsConflict : ptr .To (false ),
862
877
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
863
878
{
864
- From : "patch1" ,
879
+ From : "patch1" ,
880
+ Required : ptr .To (false ),
865
881
Schema : clusterv1.VariableSchema {
866
882
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
867
883
Type : "string" ,
@@ -875,7 +891,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
875
891
DefinitionsConflict : ptr .To (false ),
876
892
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
877
893
{
878
- From : "patch1" ,
894
+ From : "patch1" ,
895
+ Required : ptr .To (false ),
879
896
Schema : clusterv1.VariableSchema {
880
897
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
881
898
Type : "object" ,
@@ -899,7 +916,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
899
916
DefinitionsConflict : ptr .To (false ),
900
917
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
901
918
{
902
- From : "patch1" ,
919
+ From : "patch1" ,
920
+ Required : ptr .To (false ),
903
921
Schema : clusterv1.VariableSchema {
904
922
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
905
923
Type : "string" ,
@@ -929,7 +947,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
929
947
DefinitionsConflict : ptr .To (false ),
930
948
Definitions : []clusterv1.ClusterClassStatusVariableDefinition {
931
949
{
932
- From : "patch1" ,
950
+ From : "patch1" ,
951
+ Required : ptr .To (false ),
933
952
Schema : clusterv1.VariableSchema {
934
953
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
935
954
Type : "string" ,
0 commit comments