mirror of https://github.com/databricks/cli.git
Fix host based auth conflicting with DEFAULT profile (#309)
## Changes Consider the following host based configuration: ``` bundle: name: job_with_file_task workspace: host: https://e2-dogfood.staging.cloud.databricks.com/ ``` If you have a DEFAULT profile, then this host is ignored. The solution proposed here is to remove the profile config loader if host is explicitly specified in the bundle config. This does come with a cost, namely that if a `DATABRICKS_CONFIG_PROFILE` env var will be ignored, which maybe goes against unified auth spec The ideal solution here is probably to make a change to go-SDK to not select DEFAULT profile if host is not empty ## Tests <!-- How is this tested? -->
This commit is contained in:
parent
d7ac265536
commit
6feaed4990
|
@ -88,16 +88,20 @@ func (w *Workspace) Client() (*databricks.WorkspaceClient, error) {
|
||||||
AzureLoginAppID: w.AzureLoginAppID,
|
AzureLoginAppID: w.AzureLoginAppID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HACKY fix to not used host based auth when the profile is already set
|
||||||
|
profile := os.Getenv("DATABRICKS_CONFIG_PROFILE")
|
||||||
|
|
||||||
// If only the host is configured, we try and unambiguously match it to
|
// If only the host is configured, we try and unambiguously match it to
|
||||||
// a profile in the user's databrickscfg file. Override the default loaders.
|
// a profile in the user's databrickscfg file. Override the default loaders.
|
||||||
cfg.Loaders = []config.Loader{
|
if w.Host != "" && w.Profile == "" && profile == "" {
|
||||||
// Defaults.
|
cfg.Loaders = []config.Loader{
|
||||||
config.ConfigAttributes,
|
// Load auth creds from env vars
|
||||||
config.ConfigFile,
|
config.ConfigAttributes,
|
||||||
|
|
||||||
// Our loader that resolves a profile from the host alone.
|
// Our loader that resolves a profile from the host alone.
|
||||||
// This only kicks in if the above loaders don't configure auth.
|
// This only kicks in if the above loaders don't configure auth.
|
||||||
databrickscfg.ResolveProfileFromHost,
|
databrickscfg.ResolveProfileFromHost,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return databricks.NewWorkspaceClient(&cfg)
|
return databricks.NewWorkspaceClient(&cfg)
|
||||||
|
|
Loading…
Reference in New Issue