mirror of https://github.com/databricks/cli.git
Use env vars to read profile if databricks.yml is absent (#70)
Tested manually and by running sync_test.go integration test bricks sync works
This commit is contained in:
parent
731679cb4b
commit
6bcb33bf07
|
@ -77,7 +77,16 @@ func IsDatabricksProject() bool {
|
|||
}
|
||||
|
||||
func loadProjectConf(root string) (c Config, err error) {
|
||||
config, err := os.Open(filepath.Join(root, ConfigFile))
|
||||
configFilePath := filepath.Join(root, ConfigFile)
|
||||
|
||||
if _, err := os.Stat(configFilePath); errors.Is(err, os.ErrNotExist) {
|
||||
baseDir := filepath.Base(root)
|
||||
// If bricks config file is missing we assume the project root dir name
|
||||
// as the name of the project
|
||||
return Config{Name: baseDir}, nil
|
||||
}
|
||||
|
||||
config, err := os.Open(configFilePath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -58,7 +58,16 @@ func Initialize(ctx context.Context, root string) (context.Context, error) {
|
|||
config: &config,
|
||||
}
|
||||
|
||||
p.wsc = workspaces.New(&databricks.Config{Profile: config.Profile})
|
||||
if config.Profile == "" {
|
||||
// Bricks config doesn't define the profile to use, so go sdk will figure
|
||||
// out the auth credentials based on the enviroment.
|
||||
// eg. DATABRICKS_CONFIG_PROFILE can be used to select which profile to use or
|
||||
// DATABRICKS_HOST and DATABRICKS_TOKEN can be used to set the workspace auth creds
|
||||
p.wsc = workspaces.New()
|
||||
} else {
|
||||
p.wsc = workspaces.New(&databricks.Config{Profile: config.Profile})
|
||||
}
|
||||
|
||||
return context.WithValue(ctx, &projectKey, &p), nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue