mirror of https://github.com/databricks/cli.git
PythonMutator: update instrumentation (#2124)
## Changes Update instrumentation for PythonMutator to handle `experimental/python` config. ## Tests Unit tests
This commit is contained in:
parent
d525ff67be
commit
f8f804fe17
|
@ -232,7 +232,11 @@ func setUserAgentExtraEnvVar(environ map[string]string, b *bundle.Bundle) error
|
||||||
// Terraform provider to the CLI.
|
// Terraform provider to the CLI.
|
||||||
products := []string{"cli/" + build.GetInfo().Version}
|
products := []string{"cli/" + build.GetInfo().Version}
|
||||||
if experimental := b.Config.Experimental; experimental != nil {
|
if experimental := b.Config.Experimental; experimental != nil {
|
||||||
if experimental.PyDABs.Enabled {
|
hasPython := experimental.Python.Resources != nil || experimental.Python.Mutators != nil
|
||||||
|
|
||||||
|
if hasPython {
|
||||||
|
products = append(products, "databricks-pydabs/0.7.0")
|
||||||
|
} else if experimental.PyDABs.Enabled {
|
||||||
products = append(products, "databricks-pydabs/0.0.0")
|
products = append(products, "databricks-pydabs/0.0.0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ func TestSetProxyEnvVars(t *testing.T) {
|
||||||
assert.ElementsMatch(t, []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}, maps.Keys(env))
|
assert.ElementsMatch(t, []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}, maps.Keys(env))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetUserAgentExtraEnvVar(t *testing.T) {
|
func TestSetUserAgentExtraEnvVar_PyDABs(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
BundleRootPath: t.TempDir(),
|
BundleRootPath: t.TempDir(),
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -268,6 +268,26 @@ func TestSetUserAgentExtraEnvVar(t *testing.T) {
|
||||||
}, env)
|
}, env)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSetUserAgentExtraEnvVar_Python(t *testing.T) {
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
BundleRootPath: t.TempDir(),
|
||||||
|
Config: config.Root{
|
||||||
|
Experimental: &config.Experimental{
|
||||||
|
Python: config.Python{
|
||||||
|
Resources: []string{"my_project.resources:load_resources"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
env := make(map[string]string, 0)
|
||||||
|
err := setUserAgentExtraEnvVar(env, b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, map[string]string{
|
||||||
|
"DATABRICKS_USER_AGENT_EXTRA": "cli/0.0.0-dev databricks-pydabs/0.7.0",
|
||||||
|
}, env)
|
||||||
|
}
|
||||||
|
|
||||||
func TestInheritEnvVars(t *testing.T) {
|
func TestInheritEnvVars(t *testing.T) {
|
||||||
t.Setenv("HOME", "/home/testuser")
|
t.Setenv("HOME", "/home/testuser")
|
||||||
t.Setenv("PATH", "/foo:/bar")
|
t.Setenv("PATH", "/foo:/bar")
|
||||||
|
|
Loading…
Reference in New Issue