diff --git a/azurerm/helpers/authentication/auth_method_msi_test.go b/azurerm/helpers/authentication/auth_method_msi_test.go index 57ce56ebb5eb..728feba9c600 100644 --- a/azurerm/helpers/authentication/auth_method_msi_test.go +++ b/azurerm/helpers/authentication/auth_method_msi_test.go @@ -30,9 +30,11 @@ func TestManagedServiceIdentity_validate(t *testing.T) { ExpectError: true, }, { - Description: "Missing MSI Endpoint", - Config: managedServiceIdentityAuth{}, - ExpectError: true, + Description: "Valid Configuration", + Config: managedServiceIdentityAuth{ + endpoint: "https://some-location", + }, + ExpectError: false, }, } diff --git a/azurerm/helpers/authentication/builder.go b/azurerm/helpers/authentication/builder.go index 72dc7b829875..12ea623674eb 100644 --- a/azurerm/helpers/authentication/builder.go +++ b/azurerm/helpers/authentication/builder.go @@ -5,6 +5,8 @@ import ( "log" ) +// Builder supports all of the possible Authentication values and feature toggles +// required to build a working Config for Authentication purposes. type Builder struct { // Core ClientID string @@ -29,6 +31,8 @@ type Builder struct { ClientSecret string } +// Build takes the configuration from the Builder and builds up a validated Config +// for authenticating with Azure func (b Builder) Build() (*Config, error) { config := Config{ ClientID: b.ClientID, @@ -63,7 +67,6 @@ func (b Builder) Build() (*Config, error) { return config.validate() } - // note: this includes CloudShell if b.SupportsAzureCliCloudShellParsing { log.Printf("[DEBUG] Parsing credentials from the Azure CLI for Authentication") diff --git a/azurerm/helpers/authentication/config.go b/azurerm/helpers/authentication/config.go index a070f2d5fdb1..d9b606baac02 100644 --- a/azurerm/helpers/authentication/config.go +++ b/azurerm/helpers/authentication/config.go @@ -8,18 +8,16 @@ import ( // Config is the configuration structure used to instantiate a // new Azure management client. type Config struct { - // Core - ClientID string - SubscriptionID string - TenantID string - Environment string - - // temporarily public feature flags + ClientID string + SubscriptionID string + TenantID string + Environment string AuthenticatedAsAServicePrincipal bool authMethod authMethod } +// GetAuthorizationToken returns an authorization token for the authentication method defined in the Config func (c Config) GetAuthorizationToken(oauthConfig *adal.OAuthConfig, endpoint string) (*autorest.BearerAuthorizer, error) { return c.authMethod.getAuthorizationToken(oauthConfig, endpoint) } diff --git a/azurerm/helpers/resourceproviders/registration.go b/azurerm/helpers/resourceproviders/registration.go index 04a81f6c1710..ff9802b5cb64 100644 --- a/azurerm/helpers/resourceproviders/registration.go +++ b/azurerm/helpers/resourceproviders/registration.go @@ -10,6 +10,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" ) +// DetermineResourceProvidersRequiringRegistration determines which Resource Providers require registration to be able to be used func DetermineResourceProvidersRequiringRegistration(availableResourceProviders []resources.Provider, requiredResourceProviders map[string]struct{}) map[string]struct{} { providers := requiredResourceProviders @@ -28,6 +29,7 @@ func DetermineResourceProvidersRequiringRegistration(availableResourceProviders return providers } +// RegisterForSubscription registers the specified Resource Providers in the current Subscription func RegisterForSubscription(ctx context.Context, client resources.ProvidersClient, providersToRegister map[string]struct{}) error { var err error var wg sync.WaitGroup