Skip to content

Commit

Permalink
provider: Use real Terraform version
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Sep 30, 2019
1 parent 2b75869 commit 78598b9
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ type ArmClient struct {

// getArmClient is a helper method which returns a fully instantiated
// *ArmClient based on the Config's current settings.
func getArmClient(authConfig *authentication.Config, skipProviderRegistration bool, partnerId string, disableCorrelationRequestID bool) (*ArmClient, error) {
func getArmClient(authConfig *authentication.Config, skipProviderRegistration bool, tfVersion, partnerId string, disableCorrelationRequestID bool) (*ArmClient, error) {
env, err := authentication.DetermineEnvironment(authConfig.Environment)
if err != nil {
return nil, err
Expand Down Expand Up @@ -201,6 +201,7 @@ func getArmClient(authConfig *authentication.Config, skipProviderRegistration bo
SubscriptionId: authConfig.SubscriptionID,
TenantID: authConfig.TenantID,
PartnerId: partnerId,
TerraformVersion: tfVersion,
GraphAuthorizer: graphAuth,
GraphEndpoint: graphEndpoint,
KeyVaultAuthorizer: keyVaultAuth,
Expand Down
13 changes: 7 additions & 6 deletions azurerm/internal/common/client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (
)

type ClientOptions struct {
SubscriptionId string
TenantID string
PartnerId string
SubscriptionId string
TenantID string
PartnerId string
TerraformVersion string

GraphAuthorizer autorest.Authorizer
GraphEndpoint string
Expand All @@ -33,7 +34,7 @@ type ClientOptions struct {
}

func (o ClientOptions) ConfigureClient(c *autorest.Client, authorizer autorest.Authorizer) {
setUserAgent(c, o.PartnerId)
setUserAgent(c, o.TerraformVersion, o.PartnerId)

c.Authorizer = authorizer
c.Sender = sender.BuildSender("AzureRM")
Expand All @@ -44,8 +45,8 @@ func (o ClientOptions) ConfigureClient(c *autorest.Client, authorizer autorest.A
}
}

func setUserAgent(client *autorest.Client, partnerID string) {
tfUserAgent := httpclient.UserAgentString()
func setUserAgent(client *autorest.Client, tfVersion, partnerID string) {
tfUserAgent := httpclient.TerraformUserAgent(tfVersion)

providerUserAgent := fmt.Sprintf("%s terraform-provider-azurerm/%s", tfUserAgent, version.ProviderVersion)
client.UserAgent = strings.TrimSpace(fmt.Sprintf("%s %s", client.UserAgent, providerUserAgent))
Expand Down
2 changes: 1 addition & 1 deletion azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
skipProviderRegistration := d.Get("skip_provider_registration").(bool)
disableCorrelationRequestID := d.Get("disable_correlation_request_id").(bool)

client, err := getArmClient(config, skipProviderRegistration, partnerId, disableCorrelationRequestID)
client, err := getArmClient(config, skipProviderRegistration, p.TerraformVersion, partnerId, disableCorrelationRequestID)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion azurerm/required_resource_providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestAccAzureRMEnsureRequiredResourceProvidersAreRegistered(t *testing.T) {
}

// this test intentionally checks all the RP's are registered - so this is intentional
armClient, err := getArmClient(config, true, "", true)
armClient, err := getArmClient(config, true, "0.0.0", "", true)
if err != nil {
t.Fatalf("Error building ARM Client: %+v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_container_registry_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestAccAzureRMContainerRegistryMigrateState(t *testing.T) {
return
}

client, err := getArmClient(config, false, "", true)
client, err := getArmClient(config, false, "0.0.0", "", true)
if err != nil {
t.Fatal(fmt.Errorf("Error building ARM Client: %+v", err))
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAccAzureRMDataLakeStoreFileMigrateState(t *testing.T) {
return
}

client, err := getArmClient(config, false, "", true)
client, err := getArmClient(config, false, "0.0.0", "", true)
if err != nil {
t.Fatal(fmt.Errorf("Error building ARM Client: %+v", err))
return
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_storage_blob_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAccAzureRMStorageBlobMigrateState(t *testing.T) {
return
}

client, err := getArmClient(config, false, "", true)
client, err := getArmClient(config, false, "0.0.0", "", true)
if err != nil {
t.Fatal(fmt.Errorf("Error building ARM Client: %+v", err))
return
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_storage_container_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAccAzureRMStorageContainerMigrateState(t *testing.T) {
return
}

client, err := getArmClient(config, false, "", true)
client, err := getArmClient(config, false, "0.0.0", "", true)
if err != nil {
t.Fatal(fmt.Errorf("Error building ARM Client: %+v", err))
return
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_storage_queue_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAccAzureRMStorageQueueMigrateState(t *testing.T) {
return
}

client, err := getArmClient(config, false, "", true)
client, err := getArmClient(config, false, "0.0.0", "", true)
if err != nil {
t.Fatal(fmt.Errorf("Error building ARM Client: %+v", err))
return
Expand Down

0 comments on commit 78598b9

Please sign in to comment.