github.com/hashicorp/terraform-plugin-sdk@v1.17.2/httpclient/useragent.go (about) 1 package httpclient 2 3 import ( 4 "fmt" 5 "log" 6 "os" 7 "strings" 8 9 "github.com/hashicorp/terraform-plugin-sdk/meta" 10 ) 11 12 const uaEnvVar = "TF_APPEND_USER_AGENT" 13 14 // TerraformUserAgent returns a User-Agent header for a Terraform version string. 15 // 16 // Deprecated: This will be removed in v2 without replacement. If you need 17 // its functionality, you can copy it or reference the v1 package. 18 func TerraformUserAgent(version string) string { 19 ua := fmt.Sprintf("HashiCorp Terraform/%s (+https://www.terraform.io) Terraform Plugin SDK/%s", version, meta.SDKVersionString()) 20 21 if add := os.Getenv(uaEnvVar); add != "" { 22 add = strings.TrimSpace(add) 23 if len(add) > 0 { 24 ua += " " + add 25 log.Printf("[DEBUG] Using modified User-Agent: %s", ua) 26 } 27 } 28 29 return ua 30 }