@@ -22,6 +22,21 @@ import (
2222 "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/akscluster"
2323)
2424
25+ const (
26+ test127001 = "127.0.0.1"
27+ testAzure = "azure"
28+ testEastus = "eastus"
29+ testEnable = "enable"
30+ testName = "name"
31+ testResourceGroup = "resource-group"
32+ testSubId = "sub-id"
33+ testTestCluster = "test-cluster"
34+ testTestCred = "test-cred"
35+ testVal = "val"
36+
37+ test127002 = "127.0.0.2"
38+ )
39+
2540func dataDiffFrom (t * testing.T , original map [string ]any , updated map [string ]any ) * schema.ResourceData {
2641 originalData := schema .TestResourceDataRaw (t , akscluster .ClusterSchema , original )
2742 originalData .SetId ("test-uid" )
@@ -36,10 +51,10 @@ func dataDiffFrom(t *testing.T, original map[string]any, updated map[string]any)
3651
3752func expectedFullName () * models.VmwareTanzuManageV1alpha1AksclusterFullName {
3853 return & models.VmwareTanzuManageV1alpha1AksclusterFullName {
39- CredentialName : "test-cred" ,
40- SubscriptionID : "sub-id" ,
41- ResourceGroupName : "resource-group" ,
42- Name : "test-cluster" ,
54+ CredentialName : testTestCred ,
55+ SubscriptionID : testSubId ,
56+ ResourceGroupName : testResourceGroup ,
57+ Name : testTestCluster ,
4358 }
4459}
4560
@@ -89,18 +104,18 @@ func enableCSI(c *models.VmwareTanzuManageV1alpha1AksCluster) {
89104func aTestCluster (w ... clusterWither ) * models.VmwareTanzuManageV1alpha1AksCluster {
90105 c := & models.VmwareTanzuManageV1alpha1AksCluster {
91106 FullName : & models.VmwareTanzuManageV1alpha1AksclusterFullName {
92- CredentialName : "test-cred" ,
93- ResourceGroupName : "resource-group" ,
94- SubscriptionID : "sub-id" ,
95- Name : "test-cluster" ,
107+ CredentialName : testTestCred ,
108+ ResourceGroupName : testResourceGroup ,
109+ SubscriptionID : testSubId ,
110+ Name : testTestCluster ,
96111 },
97112 Meta : & objectmetamodel.VmwareTanzuCoreV1alpha1ObjectMeta {
98113 UID : "test-uid" ,
99114 },
100115 Spec : & models.VmwareTanzuManageV1alpha1AksclusterSpec {
101116 ClusterGroupName : "my-cluster-group" ,
102117 Config : & models.VmwareTanzuManageV1alpha1AksclusterClusterConfig {
103- Location : "eastus" ,
118+ Location : testEastus ,
104119 Version : "1.26.0" ,
105120 NodeResourceGroupName : "my-node-group" ,
106121 DiskEncryptionSetID : "disk-encryption-set-id" ,
@@ -120,7 +135,7 @@ func aTestCluster(w ...clusterWither) *models.VmwareTanzuManageV1alpha1AksCluste
120135 EnableRbac : true ,
121136 },
122137 APIServerAccessConfig : & models.VmwareTanzuManageV1alpha1AksclusterAPIServerAccessConfig {
123- AuthorizedIPRanges : []string {"127.0.0.1" , "127.0.0.2" },
138+ AuthorizedIPRanges : []string {test127001 , test127002 },
124139 EnablePrivateCluster : true ,
125140 },
126141 LinuxConfig : & models.VmwareTanzuManageV1alpha1AksclusterLinuxConfig {
@@ -129,10 +144,10 @@ func aTestCluster(w ...clusterWither) *models.VmwareTanzuManageV1alpha1AksCluste
129144 },
130145 NetworkConfig : & models.VmwareTanzuManageV1alpha1AksclusterNetworkConfig {
131146 DNSPrefix : "net-prefix" ,
132- DNSServiceIP : "127.0.0.1" ,
133- DockerBridgeCidr : "127.0.0.2" ,
147+ DNSServiceIP : test127001 ,
148+ DockerBridgeCidr : test127002 ,
134149 LoadBalancerSku : "load-balancer" ,
135- NetworkPlugin : "azure" ,
150+ NetworkPlugin : testAzure ,
136151 NetworkPolicy : "policy" ,
137152 ServiceCidrs : []string {"127.0.0.4" },
138153 },
@@ -261,7 +276,7 @@ func withNodepools(nps []any) mapWither {
261276
262277func withName (name string ) mapWither {
263278 return func (m map [string ]any ) {
264- m ["name" ] = name
279+ m [testName ] = name
265280 }
266281}
267282
@@ -307,24 +322,24 @@ func withPodSubnetID(podSubnetID string) mapWither {
307322
308323func aTestClusterDataMap (w ... mapWither ) map [string ]any {
309324 m := map [string ]any {
310- "credential_name" : "test-cred" ,
311- "subscription_id" : "sub-id" ,
312- "resource_group" : "resource-group" ,
313- "name" : "test-cluster" ,
325+ "credential_name" : testTestCred ,
326+ "subscription_id" : testSubId ,
327+ "resource_group" : testResourceGroup ,
328+ testName : testTestCluster ,
314329 "spec" : []any {map [string ]any {
315330 "cluster_group" : "my-cluster-group" ,
316331 "proxy" : "my-proxy" ,
317332 "config" : []any {map [string ]any {
318- "location" : "eastus" ,
333+ "location" : testEastus ,
319334 "kubernetes_version" : "1.26.0" ,
320335 "node_resource_group_name" : "my-node-group" ,
321336 "disk_encryption_set" : "disk-encryption-set-id" ,
322337 "tags" : map [string ]any {
323338 "custom-tag" : "tag-data" ,
324339 },
325340 "sku" : []any {map [string ]any {
326- "name" : "BASIC" ,
327- "tier" : "FREE" ,
341+ testName : "BASIC" ,
342+ "tier" : "FREE" ,
328343 }},
329344 "access_config" : []any {map [string ]any {
330345 "enable_rbac" : true ,
@@ -337,7 +352,7 @@ func aTestClusterDataMap(w ...mapWither) map[string]any {
337352 }},
338353 }},
339354 "api_server_access_config" : []any {map [string ]any {
340- "authorized_ip_ranges" : []any {"127.0.0.1" , "127.0.0.2" },
355+ "authorized_ip_ranges" : []any {test127001 , test127002 },
341356 "enable_private_cluster" : true ,
342357 }},
343358 "linux_config" : []any {map [string ]any {
@@ -346,11 +361,11 @@ func aTestClusterDataMap(w ...mapWither) map[string]any {
346361 }},
347362 "network_config" : []any {map [string ]any {
348363 "load_balancer_sku" : "load-balancer" ,
349- "network_plugin" : "azure" ,
364+ "network_plugin" : testAzure ,
350365 "network_plugin_mode" : "" ,
351366 "network_policy" : "policy" ,
352- "dns_service_ip" : "127.0.0.1" ,
353- "docker_bridge_cidr" : "127.0.0.2" ,
367+ "dns_service_ip" : test127001 ,
368+ "docker_bridge_cidr" : test127002 ,
354369 "pod_cidr" : nil ,
355370 "service_cidr" : []any {"127.0.0.4" },
356371 "dns_prefix" : "net-prefix" ,
@@ -363,16 +378,16 @@ func aTestClusterDataMap(w ...mapWither) map[string]any {
363378 }},
364379 "addon_config" : []any {map [string ]any {
365380 "azure_keyvault_secrets_provider_addon_config" : []any {map [string ]any {
366- "enable" : true ,
381+ testEnable : true ,
367382 "enable_secret_rotation" : true ,
368383 "rotation_poll_interval" : "5m" ,
369384 }},
370385 "monitor_addon_config" : []any {map [string ]any {
371- "enable" : true ,
386+ testEnable : true ,
372387 "log_analytics_workspace_id" : "workspace-id" ,
373388 }},
374389 "azure_policy_addon_config" : []any {map [string ]any {
375- "enable" : true ,
390+ testEnable : true ,
376391 }},
377392 }},
378393 "auto_upgrade_config" : []any {map [string ]any {
@@ -457,7 +472,7 @@ func aTestNodePool(w ...nodepoolWither) *models.VmwareTanzuManageV1alpha1Aksclus
457472 },
458473 EnableNodePublicIP : true ,
459474 MaxPods : 110 ,
460- NodeLabels : map [string ]string {"label" : "val" },
475+ NodeLabels : map [string ]string {"label" : testVal },
461476 NodeTaints : []* models.VmwareTanzuManageV1alpha1AksclusterNodepoolTaint {{
462477 Effect : models .VmwareTanzuManageV1alpha1AksclusterNodepoolTaintEffectNOSCHEDULE .Pointer (),
463478 Key : "tkey" ,
@@ -466,7 +481,7 @@ func aTestNodePool(w ...nodepoolWither) *models.VmwareTanzuManageV1alpha1Aksclus
466481 OsDiskSizeGb : 30 ,
467482 OsDiskType : models .VmwareTanzuManageV1alpha1AksclusterNodepoolOsDiskTypeEPHEMERAL .Pointer (),
468483 OsType : models .VmwareTanzuManageV1alpha1AksclusterNodepoolOsTypeLINUX .Pointer (),
469- Tags : map [string ]string {"tmc.node.tag" : "val" },
484+ Tags : map [string ]string {"tmc.node.tag" : testVal },
470485 UpgradeConfig : & models.VmwareTanzuManageV1alpha1AksclusterNodepoolUpgradeConfig {
471486 MaxSurge : "50%" ,
472487 },
@@ -484,7 +499,7 @@ func aTestNodePool(w ...nodepoolWither) *models.VmwareTanzuManageV1alpha1Aksclus
484499
485500func aTestNodepoolDataMap (w ... mapWither ) map [string ]any {
486501 m := map [string ]any {
487- "name" : "system-np" ,
502+ testName : "system-np" ,
488503 "spec" : []any {map [string ]any {
489504 "mode" : "SYSTEM" ,
490505 "node_image_version" : "v1" ,
@@ -509,10 +524,10 @@ func aTestNodepoolDataMap(w ...mapWither) map[string]any {
509524 },
510525 "vnet_subnet_id" : "vnet-1/subnets/subnet-1" ,
511526 "pod_subnet_id" : "vnet-1/subnets/subnet-2" ,
512- "node_labels" : map [string ]any {"label" : "val" },
513- "tags" : map [string ]any {"tmc.node.tag" : "val" },
527+ "node_labels" : map [string ]any {"label" : testVal },
528+ "tags" : map [string ]any {"tmc.node.tag" : testVal },
514529 "auto_scaling_config" : []any {map [string ]any {
515- "enable" : true ,
530+ testEnable : true ,
516531 "min_count" : 1 ,
517532 "max_count" : 10 ,
518533 }},
0 commit comments