Skip to content

Commit

Permalink
Merge pull request #587 from jeffreyCline/master
Browse files Browse the repository at this point in the history
Updated the way user agent string gets assigned.
  • Loading branch information
tombuildsstuff authored Nov 30, 2017
2 parents 2f817ea + 1436023 commit 07ae076
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,16 @@ func withRequestLogging() autorest.SendDecorator {
}

func setUserAgent(client *autorest.Client) {
version := terraform.VersionString()
client.UserAgent = fmt.Sprintf("HashiCorp-Terraform-v%s", version)
tfVersion := fmt.Sprintf("HashiCorp-Terraform-v%s", terraform.VersionString())

// append the CloudShell version to the user agent
// if the user agent already has a value append the Terraform user agent string
if curUserAgent := client.UserAgent; curUserAgent != "" {
client.UserAgent = fmt.Sprintf("%s;%s", curUserAgent, tfVersion)
} else {
client.UserAgent = tfVersion
}

// append the CloudShell version to the user agent if it exists
if azureAgent := os.Getenv("AZURE_HTTP_USER_AGENT"); azureAgent != "" {
client.UserAgent = fmt.Sprintf("%s;%s", client.UserAgent, azureAgent)
}
Expand Down

0 comments on commit 07ae076

Please sign in to comment.