Skip to content

Commit 61ce391

Browse files
draft implementation
1 parent ad0e9f1 commit 61ce391

File tree

4 files changed

+349
-72
lines changed

4 files changed

+349
-72
lines changed

databricks/sdk/config.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
from ._base_client import _fix_host_if_needed
1515
from .clock import Clock, RealClock
1616
from .credentials_provider import CredentialsStrategy, DefaultCredentials
17-
from .environments import (ALL_ENVS, AzureEnvironment, Cloud,
18-
DatabricksEnvironment, get_environment_for_hostname)
19-
from .oauth import (OidcEndpoints, Token, get_account_endpoints,
20-
get_azure_entra_id_workspace_endpoints,
21-
get_workspace_endpoints)
17+
from .environments import ALL_ENVS, AzureEnvironment, Cloud, DatabricksEnvironment, get_environment_for_hostname
18+
from .oauth import (
19+
OidcEndpoints,
20+
Token,
21+
get_account_endpoints,
22+
get_azure_entra_id_workspace_endpoints,
23+
get_workspace_endpoints,
24+
)
2225

2326
logger = logging.getLogger("databricks.sdk")
2427

@@ -60,10 +63,21 @@ def with_user_agent_extra(key: str, value: str):
6063
class Config:
6164
host: str = ConfigAttribute(env="DATABRICKS_HOST")
6265
account_id: str = ConfigAttribute(env="DATABRICKS_ACCOUNT_ID")
66+
67+
# PAT token.
6368
token: str = ConfigAttribute(env="DATABRICKS_TOKEN", auth="pat", sensitive=True)
69+
70+
# Audience for OIDC ID token source accepting an audience as a parameter.
71+
# For example, the GitHub action ID token source.
6472
token_audience: str = ConfigAttribute(env="DATABRICKS_TOKEN_AUDIENCE", auth="github-oidc")
73+
74+
# Environment variable for OIDC token.
75+
oidc_token_env: str = ConfigAttribute(env="DATABRICKS_OIDC_TOKEN_ENV", auth="env-oidc")
76+
oidc_token_filepath: str = ConfigAttribute(env="DATABRICKS_OIDC_TOKEN_FILE", auth="file-oidc")
77+
6578
username: str = ConfigAttribute(env="DATABRICKS_USERNAME", auth="basic")
6679
password: str = ConfigAttribute(env="DATABRICKS_PASSWORD", auth="basic", sensitive=True)
80+
6781
client_id: str = ConfigAttribute(env="DATABRICKS_CLIENT_ID", auth="oauth")
6882
client_secret: str = ConfigAttribute(env="DATABRICKS_CLIENT_SECRET", auth="oauth", sensitive=True)
6983
profile: str = ConfigAttribute(env="DATABRICKS_CONFIG_PROFILE")
@@ -194,7 +208,7 @@ def oauth_token(self) -> Token:
194208
def wrap_debug_info(self, message: str) -> str:
195209
debug_string = self.debug_string()
196210
if debug_string:
197-
message = f'{message.rstrip(".")}. {debug_string}'
211+
message = f"{message.rstrip('.')}. {debug_string}"
198212
return message
199213

200214
@staticmethod
@@ -337,9 +351,9 @@ def debug_string(self) -> str:
337351
safe = "***" if attr.sensitive else f"{value}"
338352
attrs_used.append(f"{attr.name}={safe}")
339353
if attrs_used:
340-
buf.append(f'Config: {", ".join(attrs_used)}')
354+
buf.append(f"Config: {', '.join(attrs_used)}")
341355
if envs_used:
342-
buf.append(f'Env: {", ".join(envs_used)}')
356+
buf.append(f"Env: {', '.join(envs_used)}")
343357
return ". ".join(buf)
344358

345359
def to_dict(self) -> Dict[str, any]:
@@ -481,7 +495,7 @@ def _known_file_config_loader(self):
481495
if profile not in profiles:
482496
raise ValueError(f"resolve: {config_path} has no {profile} profile configured")
483497
raw_config = profiles[profile]
484-
logger.info(f'loading {profile} profile from {config_file}: {", ".join(raw_config.keys())}')
498+
logger.info(f"loading {profile} profile from {config_file}: {', '.join(raw_config.keys())}")
485499
for k, v in raw_config.items():
486500
if k in self._inner:
487501
# don't overwrite a value previously set

0 commit comments

Comments
 (0)