-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
env.UserHomeDir(ctx)
for parallel-friendly tests (#955)
## Changes `os.Getenv(..)` is not friendly with `libs/env`. This PR makes the relevant changes to places where we need to read user home directory. ## Tests Mainly done in #914
- Loading branch information
Showing
11 changed files
with
190 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[DEFAULT] | ||
host = https://default | ||
token = default | ||
|
||
[acc] | ||
host = https://accounts.cloud.databricks.com | ||
account_id = abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package env | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/databricks/databricks-sdk-go/config" | ||
) | ||
|
||
// NewConfigLoader creates Databricks SDK Config loader that is aware of env.Set variables: | ||
// | ||
// ctx = env.Set(ctx, "DATABRICKS_WAREHOUSE_ID", "...") | ||
// | ||
// Usage: | ||
// | ||
// &config.Config{ | ||
// Loaders: []config.Loader{ | ||
// env.NewConfigLoader(ctx), | ||
// config.ConfigAttributes, | ||
// config.ConfigFile, | ||
// }, | ||
// } | ||
func NewConfigLoader(ctx context.Context) *configLoader { | ||
return &configLoader{ | ||
ctx: ctx, | ||
} | ||
} | ||
|
||
type configLoader struct { | ||
ctx context.Context | ||
} | ||
|
||
func (le *configLoader) Name() string { | ||
return "cli-env" | ||
} | ||
|
||
func (le *configLoader) Configure(cfg *config.Config) error { | ||
for _, a := range config.ConfigAttributes { | ||
if !a.IsZero(cfg) { | ||
continue | ||
} | ||
for _, k := range a.EnvVars { | ||
v := Get(le.ctx, k) | ||
if v == "" { | ||
continue | ||
} | ||
a.Set(cfg, v) | ||
} | ||
} | ||
return nil | ||
} |
Oops, something went wrong.