diff --git a/bundle/deploy/terraform/init.go b/bundle/deploy/terraform/init.go index d480242c..e7f720d0 100644 --- a/bundle/deploy/terraform/init.go +++ b/bundle/deploy/terraform/init.go @@ -15,6 +15,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/internal/tf/schema" + "github.com/databricks/cli/internal/build" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" @@ -219,8 +220,10 @@ func setProxyEnvVars(ctx context.Context, environ map[string]string, b *bundle.B } func setUserAgentExtraEnvVar(environ map[string]string, b *bundle.Bundle) error { - var products []string - + // Add "cli" to the user agent in set by the Databricks Terraform provider. + // This will allow us to attribute downstream requests made by the Databricks + // Terraform provider to the CLI. + products := []string{fmt.Sprintf("cli/%s", build.GetInfo().Version)} if experimental := b.Config.Experimental; experimental != nil { if experimental.PyDABs.Enabled { products = append(products, "databricks-pydabs/0.0.0") diff --git a/bundle/deploy/terraform/init_test.go b/bundle/deploy/terraform/init_test.go index aa9b2f77..94e47dbc 100644 --- a/bundle/deploy/terraform/init_test.go +++ b/bundle/deploy/terraform/init_test.go @@ -262,10 +262,9 @@ func TestSetUserAgentExtraEnvVar(t *testing.T) { env := make(map[string]string, 0) err := setUserAgentExtraEnvVar(env, b) - require.NoError(t, err) assert.Equal(t, map[string]string{ - "DATABRICKS_USER_AGENT_EXTRA": "databricks-pydabs/0.0.0", + "DATABRICKS_USER_AGENT_EXTRA": "cli/0.0.0-dev databricks-pydabs/0.0.0", }, env) }