Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Nov 2, 2018
1 parent 37bf820 commit 925061f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
8 changes: 5 additions & 3 deletions azurerm/helpers/authentication/auth_method_msi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}

Expand Down
5 changes: 4 additions & 1 deletion azurerm/helpers/authentication/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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")

Expand Down
12 changes: 5 additions & 7 deletions azurerm/helpers/authentication/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions azurerm/helpers/resourceproviders/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 925061f

Please sign in to comment.