Set BRICKS_CLI_PATH only if it cannot be derived from $PATH (#298)

## Changes

Related to #237.

Output of `bricks auth env` now doesn't include `BRICKS_CLI_PATH` if it
can be found in $PATH.

## Tests

Verified manually.
This commit is contained in:
Pieter Noordhuis 2023-04-03 16:23:53 +02:00 committed by GitHub
parent b4a30c641c
commit f26806be8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package config
import (
"os"
"path/filepath"
"github.com/databricks/bricks/libs/databrickscfg"
"github.com/databricks/databricks-sdk-go"
@ -103,5 +104,11 @@ func (w *Workspace) Client() (*databricks.WorkspaceClient, error) {
}
func init() {
os.Setenv("BRICKS_CLI_PATH", os.Args[0])
arg0 := os.Args[0]
// Configure BRICKS_CLI_PATH only if our caller intends to use this specific version of this binary.
// Otherwise, if it is equal to its basename, processes can find it in $PATH.
if arg0 != filepath.Base(arg0) {
os.Setenv("BRICKS_CLI_PATH", arg0)
}
}