@@ -838,21 +838,47 @@ func Test_ShouldSync(t *testing.T) {
838
838
cd * hivev1.ClusterDeployment
839
839
840
840
expect bool
841
- }{{ // Sync is required when status.platform is nil
842
- name : "status.platform is nil" ,
843
- cd : cdBuilder .Build (),
841
+ }{{ // Sync is not required when spec.platform.gcp is nil
842
+ name : "spec.platform.gcp is nil" ,
843
+ cd : cdBuilder .Build (),
844
+ }, { // Sync is not required when spec.platform.gcp.privateServiceConnect is nil
845
+ name : "spec.platform.gcp.privateServiceConnect" ,
846
+ cd : cdBuilder .Build (testcd .WithGCPPlatform (& hivev1gcp.Platform {})),
847
+ }, { // Sync is not required when spec.platform.gcp.privateServiceConnect.enabled is false
848
+ name : "privateServiceConnect is not enabled" ,
849
+ cd : cdBuilder .Build (testcd .WithGCPPlatform (& hivev1gcp.Platform {
850
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : false },
851
+ })),
852
+ }, { // Sync is required when status.platform is nil
853
+ name : "status.platform is nil" ,
854
+ cd : cdBuilder .Build (testcd .WithGCPPlatform (& hivev1gcp.Platform {
855
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
856
+ })),
844
857
expect : true ,
845
858
}, { // Sync is required when status.platform.gcp is nil
846
- name : "status.platform.gcp is nil" ,
847
- cd : cdBuilder .Options (testcd .WithEmptyPlatformStatus ()).Build (),
859
+ name : "status.platform.gcp is nil" ,
860
+ cd : cdBuilder .Build (
861
+ testcd .WithGCPPlatform (& hivev1gcp.Platform {
862
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
863
+ }),
864
+ testcd .WithEmptyPlatformStatus (),
865
+ ),
848
866
expect : true ,
849
867
}, { // Sync is required when status.platform.gcp.privateServiceConnect is nil
850
- name : "status.platform.aws.privateServiceConnect is nil" ,
851
- cd : cdBuilder .Options (testcd .WithGCPPlatformStatus (& hivev1gcp.PlatformStatus {})).Build (),
868
+ name : "status.platform.aws.privateServiceConnect is nil" ,
869
+ cd : cdBuilder .Build (
870
+ testcd .WithGCPPlatform (& hivev1gcp.Platform {
871
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
872
+ }),
873
+ testcd .WithGCPPlatformStatus (& hivev1gcp.PlatformStatus {}),
874
+ ),
852
875
expect : true ,
853
876
}, { // Sync is required when endpoint is empty
854
877
name : "Endpoint is empty" ,
855
- cd : cdBuilder .Options (
878
+ cd : cdBuilder .Build (
879
+ testcd .WithGCPPlatform (& hivev1gcp.Platform {
880
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
881
+ }),
856
882
testcd .WithGCPPlatformStatus (& hivev1gcp.PlatformStatus {
857
883
PrivateServiceConnect : & hivev1gcp.PrivateServiceConnectStatus {
858
884
EndpointAddress : mockAddress .SelfLink ,
@@ -861,11 +887,14 @@ func Test_ShouldSync(t *testing.T) {
861
887
ServiceAttachmentSubnet : mockSubnet .SelfLink ,
862
888
},
863
889
}),
864
- ). Build () ,
890
+ ),
865
891
expect : true ,
866
892
}, { // Sync is required when EndpointAddress is empty
867
893
name : "EndpointAddress is empty" ,
868
- cd : cdBuilder .Options (
894
+ cd : cdBuilder .Build (
895
+ testcd .WithGCPPlatform (& hivev1gcp.Platform {
896
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
897
+ }),
869
898
testcd .WithGCPPlatformStatus (& hivev1gcp.PlatformStatus {
870
899
PrivateServiceConnect : & hivev1gcp.PrivateServiceConnectStatus {
871
900
Endpoint : mockForwardingRule .SelfLink ,
@@ -874,11 +903,14 @@ func Test_ShouldSync(t *testing.T) {
874
903
ServiceAttachmentSubnet : mockSubnet .SelfLink ,
875
904
},
876
905
}),
877
- ). Build () ,
906
+ ),
878
907
expect : true ,
879
908
}, { // Sync is required when ServiceAttachment is empty
880
909
name : "ServiceAttachment is empty" ,
881
- cd : cdBuilder .Options (
910
+ cd : cdBuilder .Build (
911
+ testcd .WithGCPPlatform (& hivev1gcp.Platform {
912
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
913
+ }),
882
914
testcd .WithGCPPlatformStatus (& hivev1gcp.PlatformStatus {
883
915
PrivateServiceConnect : & hivev1gcp.PrivateServiceConnectStatus {
884
916
Endpoint : mockForwardingRule .SelfLink ,
@@ -887,11 +919,14 @@ func Test_ShouldSync(t *testing.T) {
887
919
ServiceAttachmentSubnet : mockSubnet .SelfLink ,
888
920
},
889
921
}),
890
- ). Build () ,
922
+ ),
891
923
expect : true ,
892
924
}, { // Sync is required when ServiceAttachmentFirewall is empty
893
925
name : "ServiceAttachmentFirewall is empty" ,
894
- cd : cdBuilder .Options (
926
+ cd : cdBuilder .Build (
927
+ testcd .WithGCPPlatform (& hivev1gcp.Platform {
928
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
929
+ }),
895
930
testcd .WithGCPPlatformStatus (& hivev1gcp.PlatformStatus {
896
931
PrivateServiceConnect : & hivev1gcp.PrivateServiceConnectStatus {
897
932
Endpoint : mockForwardingRule .SelfLink ,
@@ -900,11 +935,14 @@ func Test_ShouldSync(t *testing.T) {
900
935
ServiceAttachmentSubnet : mockSubnet .SelfLink ,
901
936
},
902
937
}),
903
- ). Build () ,
938
+ ),
904
939
expect : true ,
905
940
}, { // Sync is required when ServiceAttachmentSubnet is empty
906
941
name : "ServiceAttachmentSubnet is empty" ,
907
- cd : cdBuilder .Options (
942
+ cd : cdBuilder .Build (
943
+ testcd .WithGCPPlatform (& hivev1gcp.Platform {
944
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
945
+ }),
908
946
testcd .WithGCPPlatformStatus (& hivev1gcp.PlatformStatus {
909
947
PrivateServiceConnect : & hivev1gcp.PrivateServiceConnectStatus {
910
948
Endpoint : mockForwardingRule .SelfLink ,
@@ -913,11 +951,14 @@ func Test_ShouldSync(t *testing.T) {
913
951
ServiceAttachmentFirewall : mockFirewall .SelfLink ,
914
952
},
915
953
}),
916
- ). Build () ,
954
+ ),
917
955
expect : true ,
918
956
}, { // Sync is not required when hostedZoneID is set
919
957
name : "no changes required" ,
920
- cd : cdBuilder .Options (
958
+ cd : cdBuilder .Build (
959
+ testcd .WithGCPPlatform (& hivev1gcp.Platform {
960
+ PrivateServiceConnect : & hivev1gcp.PrivateServiceConnect {Enabled : true },
961
+ }),
921
962
testcd .WithGCPPlatformStatus (& hivev1gcp.PlatformStatus {
922
963
PrivateServiceConnect : & hivev1gcp.PrivateServiceConnectStatus {
923
964
Endpoint : mockForwardingRule .SelfLink ,
@@ -927,7 +968,7 @@ func Test_ShouldSync(t *testing.T) {
927
968
ServiceAttachmentSubnet : mockSubnet .SelfLink ,
928
969
},
929
970
}),
930
- ). Build () ,
971
+ ),
931
972
}}
932
973
for _ , test := range cases {
933
974
t .Run (test .name , func (t * testing.T ) {
0 commit comments