github.com/openshift/installer@v1.4.17/pkg/asset/installconfig/ibmcloud/subnet.go (about) 1 package ibmcloud 2 3 import ( 4 "context" 5 6 "github.com/pkg/errors" 7 ) 8 9 // Subnet represents an IBM Cloud VPC Subnet 10 type Subnet struct { 11 CIDR string 12 CRN string 13 ID string 14 Name string 15 VPC string 16 Zone string 17 } 18 19 func getSubnets(ctx context.Context, client API, region string, subnetNames []string) (map[string]Subnet, error) { 20 subnets := map[string]Subnet{} 21 22 for _, name := range subnetNames { 23 results, err := client.GetSubnetByName(ctx, name, region) 24 if err != nil { 25 return nil, errors.Wrapf(err, "getting subnet %s", name) 26 } 27 28 if results.ID == nil { 29 return nil, errors.Errorf("%s has no ID", name) 30 } 31 32 if results.Ipv4CIDRBlock == nil { 33 return nil, errors.Errorf("%s has no Ipv4CIDRBlock", *results.ID) 34 } 35 36 if results.CRN == nil { 37 return nil, errors.Errorf("%s has no CRN", *results.ID) 38 } 39 40 if results.Name == nil { 41 return nil, errors.Errorf("%s has no Name", *results.ID) 42 } 43 44 if results.VPC == nil { 45 return nil, errors.Errorf("%s has no VPC", *results.ID) 46 } 47 48 if results.Zone == nil { 49 return nil, errors.Errorf("%s has no Zone", *results.ID) 50 } 51 52 subnets[*results.ID] = Subnet{ 53 CIDR: *results.Ipv4CIDRBlock, 54 CRN: *results.CRN, 55 ID: *results.ID, 56 Name: *results.Name, 57 VPC: *results.VPC.Name, 58 Zone: *results.Zone.Name, 59 } 60 } 61 62 return subnets, nil 63 }