@@ -21,6 +21,7 @@ import (
21
21
22
22
. "github.com/onsi/ginkgo/v2"
23
23
. "github.com/onsi/gomega"
24
+ "gopkg.in/yaml.v3"
24
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25
26
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
26
27
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -52,30 +53,27 @@ func PopulateHostedTemplateVars(ctx context.Context, kc *kubeclient.KubeClient,
52
53
Expect (err ).NotTo (HaveOccurred (), "failed to get AWS cluster subnets" )
53
54
Expect (found ).To (BeTrue (), "AWS cluster has no subnets" )
54
55
55
- // find the first public subnet
56
- for _ , s := range subnets {
56
+ type awsSubnetMaps []map [string ]any
57
+ subnetMaps := make (awsSubnetMaps , len (subnets ))
58
+ for i , s := range subnets {
57
59
subnet , ok := s .(map [string ]any )
58
60
Expect (ok ).To (BeTrue (), "failed to cast subnet to map" )
59
-
60
- if isPublic , ok := subnet ["isPublic" ].(bool ); ok && isPublic {
61
- subnetID , ok := subnet ["resourceID" ].(string )
62
- Expect (ok ).To (BeTrue (), "failed to cast subnet ID to string" )
63
-
64
- subnetAZ , ok := subnet ["availabilityZone" ].(string )
65
- Expect (ok ).To (BeTrue (), "failed to cast subnet availability zone to string" )
66
-
67
- GinkgoT ().Setenv (managedcluster .EnvVarAWSSubnetID , subnetID )
68
- GinkgoT ().Setenv (managedcluster .EnvVarAWSSubnetAvailabilityZone , subnetAZ )
69
- break
61
+ subnetMaps [i ] = map [string ]any {
62
+ "isPublic" : subnet ["isPublic" ],
63
+ "availabilityZone" : subnet ["availabilityZone" ],
64
+ "id" : subnet ["resourceID" ],
70
65
}
71
66
}
72
67
68
+ subnetYaml , err := yaml .Marshal (subnetMaps )
69
+ Expect (err ).NotTo (HaveOccurred (), "failed to get marshall subnet maps" )
70
+ GinkgoT ().Setenv (managedcluster .EnvVarSubnets , string (subnetYaml ))
71
+
73
72
securityGroupID , found , err := unstructured .NestedString (
74
73
awsCluster .Object , "status" , "networkStatus" , "securityGroups" , "node" , "id" )
75
74
Expect (err ).NotTo (HaveOccurred (), "failed to get AWS cluster security group ID" )
76
75
Expect (found ).To (BeTrue (), "AWS cluster has no security group ID" )
77
76
78
77
GinkgoT ().Setenv (managedcluster .EnvVarAWSVPCID , vpcID )
79
-
80
78
GinkgoT ().Setenv (managedcluster .EnvVarAWSSecurityGroupID , securityGroupID )
81
79
}
0 commit comments