github.com/openshift/installer@v1.4.17/pkg/asset/cluster/ibmcloud/ibmcloud.go (about)

     1  // Package ibmcloud extracts IBM Cloud metadata from install configurations.
     2  package ibmcloud
     3  
     4  import (
     5  	"context"
     6  
     7  	icibmcloud "github.com/openshift/installer/pkg/asset/installconfig/ibmcloud"
     8  	"github.com/openshift/installer/pkg/types"
     9  	"github.com/openshift/installer/pkg/types/ibmcloud"
    10  )
    11  
    12  // Metadata converts an install configuration to IBM Cloud metadata.
    13  func Metadata(infraID string, config *types.InstallConfig) *ibmcloud.Metadata {
    14  	meta := icibmcloud.NewMetadata(config)
    15  	accountID, _ := meta.AccountID(context.TODO())
    16  	cisCrn, _ := meta.CISInstanceCRN(context.TODO())
    17  	dnsInstance, _ := meta.DNSInstance(context.TODO())
    18  
    19  	var dnsInstanceID string
    20  	if dnsInstance != nil {
    21  		dnsInstanceID = dnsInstance.ID
    22  	}
    23  
    24  	subnets := []string{}
    25  	controlPlaneSubnets, _ := meta.ControlPlaneSubnets(context.TODO())
    26  	for id := range controlPlaneSubnets {
    27  		subnets = append(subnets, id)
    28  	}
    29  	computeSubnets, _ := meta.ComputeSubnets(context.TODO())
    30  	for id := range computeSubnets {
    31  		subnets = append(subnets, id)
    32  	}
    33  
    34  	// TODO: For now we don't care about any duplicates in 'subnets', but might need to remove any if we need to
    35  	// process the subnets data. Currently, if there is one or more subnet, we skip destroying all subnets (user-provided)
    36  
    37  	return &ibmcloud.Metadata{
    38  		AccountID:         accountID,
    39  		BaseDomain:        config.BaseDomain,
    40  		CISInstanceCRN:    cisCrn,
    41  		DNSInstanceID:     dnsInstanceID,
    42  		Region:            config.Platform.IBMCloud.Region,
    43  		ResourceGroupName: config.Platform.IBMCloud.ClusterResourceGroupName(infraID),
    44  		ServiceEndpoints:  config.Platform.IBMCloud.ServiceEndpoints,
    45  		Subnets:           subnets,
    46  		VPC:               config.Platform.IBMCloud.GetVPCName(),
    47  	}
    48  }