mirror of https://github.com/databricks/cli.git
make the profile is passed test work
This commit is contained in:
parent
f0d1dc56c8
commit
080d1bf8b9
|
@ -0,0 +1,8 @@
|
|||
[someprofile]
|
||||
host = $DATABRICKS_HOST
|
||||
token = $DATABRICKS_TOKEN
|
||||
|
||||
[myprofile]
|
||||
host = $DATABRICKS_HOST
|
||||
client_id = client_id
|
||||
client_secret = client_secret
|
|
@ -1,2 +1,5 @@
|
|||
bundle:
|
||||
name: foobar
|
||||
|
||||
workspace:
|
||||
profile: someprofile
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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]"
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -68,6 +68,14 @@ Examples:
|
|||
// TODO: TODO: What happens here if a default target is resolved? When
|
||||
// no targets are defined?
|
||||
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
|
||||
|
||||
// Execute all scripts from the bundle root directory. This behavior can
|
||||
|
|
Loading…
Reference in New Issue