2016-06-22 19:04:13 -04:00
|
|
|
package arm
|
|
|
|
|
2016-06-30 19:51:52 -04:00
|
|
|
// Method to resolve information about the user so that a client can be
|
|
|
|
// constructed to communicated with Azure.
|
|
|
|
//
|
|
|
|
// The following data are resolved.
|
|
|
|
//
|
|
|
|
// 1. TenantID
|
|
|
|
|
2016-06-22 19:04:13 -04:00
|
|
|
import (
|
|
|
|
"github.com/Azure/go-autorest/autorest/azure"
|
|
|
|
"github.com/mitchellh/packer/builder/azure/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
type configRetriever struct {
|
|
|
|
// test seams
|
|
|
|
findTenantID func(azure.Environment, string) (string, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newConfigRetriever() configRetriever {
|
2016-06-30 19:51:52 -04:00
|
|
|
return configRetriever{
|
|
|
|
common.FindTenantID,
|
|
|
|
}
|
2016-06-22 19:04:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cr configRetriever) FillParameters(c *Config) error {
|
|
|
|
if c.TenantID == "" {
|
|
|
|
tenantID, err := cr.findTenantID(*c.cloudEnvironment, c.SubscriptionID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
c.TenantID = tenantID
|
|
|
|
}
|
2016-06-30 19:51:52 -04:00
|
|
|
|
2016-06-22 19:04:13 -04:00
|
|
|
return nil
|
|
|
|
}
|