feat(ingest): support __from_env__ special server value (#11569)

This commit is contained in:
Harshal Sheth 2024-10-09 13:08:38 -07:00 committed by GitHub
parent 50929ce212
commit e5643d56c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -84,6 +84,13 @@ def _get_config_from_env() -> Tuple[Optional[str], Optional[str]]:
return url or host, token
def require_config_from_env() -> Tuple[str, Optional[str]]:
host, token = _get_config_from_env()
if host is None:
raise MissingConfigError("No GMS host was provided in env variables.")
return host, token
def load_client_config() -> DatahubClientConfig:
gms_host_env, gms_token_env = _get_config_from_env()
if gms_host_env:

View File

@ -76,6 +76,12 @@ class DataHubRestEmitter(Closeable, Emitter):
):
if not gms_server:
raise ConfigurationError("gms server is required")
if gms_server == "__from_env__" and token is None:
# HACK: similar to what we do with system auth, we transparently
# inject the config in here. Ideally this should be done in the
# config loader or by the caller, but it gets the job done for now.
gms_server, token = config_utils.require_config_from_env()
self._gms_server = fixup_gms_url(gms_server)
self._token = token
self.server_config: Dict[str, Any] = {}