github.phpd.cn/hashicorp/packer@v1.3.2/builder/azure/arm/config_retriever.go (about)

     1  package arm
     2  
     3  // Method to resolve information about the user so that a client can be
     4  // constructed to communicated with Azure.
     5  //
     6  // The following data are resolved.
     7  //
     8  // 1. TenantID
     9  
    10  import (
    11  	"github.com/Azure/go-autorest/autorest/azure"
    12  	"github.com/hashicorp/packer/builder/azure/common"
    13  )
    14  
    15  type configRetriever struct {
    16  	// test seams
    17  	findTenantID func(azure.Environment, string) (string, error)
    18  }
    19  
    20  func newConfigRetriever() configRetriever {
    21  	return configRetriever{
    22  		common.FindTenantID,
    23  	}
    24  }
    25  
    26  func (cr configRetriever) FillParameters(c *Config) error {
    27  	if c.TenantID == "" {
    28  		tenantID, err := cr.findTenantID(*c.cloudEnvironment, c.SubscriptionID)
    29  		if err != nil {
    30  			return err
    31  		}
    32  		c.TenantID = tenantID
    33  	}
    34  
    35  	return nil
    36  }