make the profile is passed test work

This commit is contained in:
Shreyas Goenka 2025-03-03 18:13:56 +01:00
parent f0d1dc56c8
commit 080d1bf8b9
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
6 changed files with 76 additions and 2 deletions

View File

@ -0,0 +1,8 @@
[someprofile]
host = $DATABRICKS_HOST
token = $DATABRICKS_TOKEN
[myprofile]
host = $DATABRICKS_HOST
client_id = client_id
client_secret = client_secret

View File

@ -1,2 +1,5 @@
bundle: bundle:
name: foobar name: foobar
workspace:
profile: someprofile

View File

@ -0,0 +1,32 @@
{
"headers": {
"Authorization": [
"Bearer [DATABRICKS_TOKEN]"
]
},
"method": "GET",
"path": "/api/2.0/preview/scim/v2/Me"
}
{
"method": "GET",
"path": "/oidc/.well-known/oauth-authorization-server"
}
{
"headers": {
"Authorization": [
"Basic [ENCODED_AUTH]"
]
},
"method": "POST",
"path": "/oidc/v1/token",
"raw_body": "grant_type=client_credentials\u0026scope=all-apis"
}
{
"headers": {
"Authorization": [
"Bearer oauth-token"
]
},
"method": "GET",
"path": "/api/2.0/preview/scim/v2/Me"
}

View File

@ -1,3 +1,12 @@
script: line 64: syntax error near unexpected token `)'
Exit code: 2 >>> [CLI] bundle exec -- databricks current-user me
{
"id":"[USERID]",
"userName":"[USERNAME]"
}
>>> [CLI] bundle exec --profile myprofile -- databricks current-user me
{
"id":"[USERID]",
"userName":"[USERNAME]"
}

View File

@ -0,0 +1,14 @@
# Replace placeholder with an actual host URL
envsubst < databricks.yml > out.yml && mv out.yml databricks.yml
envsubst < .databrickscfg > out && mv out .databrickscfg
export DATABRICKS_CONFIG_FILE=.databrickscfg
# Credentials will be picked up from .databrickscfg. Unset existing credentials.
unset DATABRICKS_HOST
unset DATABRICKS_TOKEN
# This should use the profile configured in the bundle, i.e. PAT auth
trace $CLI bundle exec -- databricks current-user me
# This should use myprofile, which uses oauth.
trace $CLI bundle exec --profile myprofile -- databricks current-user me

View File

@ -68,6 +68,14 @@ Examples:
// TODO: TODO: What happens here if a default target is resolved? When // TODO: TODO: What happens here if a default target is resolved? When
// no targets are defined? // no targets are defined?
env = append(env, "DATABRICKS_BUNDLE_TARGET="+b.Config.Bundle.Target) env = append(env, "DATABRICKS_BUNDLE_TARGET="+b.Config.Bundle.Target)
// If the bundle has a profile, explicitly pass it to the child command.
// This is unnecessary for tools that follow the unified authentication spec.
// However, because the CLI can read the profile from the bundle itself, we
// need to pass it explicitly.
if b.Config.Workspace.Profile != "" {
env = append(env, "DATABRICKS_CONFIG_PROFILE="+b.Config.Workspace.Profile)
}
childCmd.Env = env childCmd.Env = env
// Execute all scripts from the bundle root directory. This behavior can // Execute all scripts from the bundle root directory. This behavior can