@@ -235,41 +235,59 @@ def resolve_credentials(
235235 return credentials
236236
237237 @classmethod
238- def get_deployment_secret (cls ) -> Dict [ str , Any ] :
239- """Get deployment configuration from the deployment secret store.
238+ def get_deployment_secret (cls , key : str ) -> Any :
239+ """Get a specific key from deployment configuration in the deployment secret store.
240240
241241 Validates that the deployment secret store component is registered
242242 before attempting to fetch secrets to prevent errors. This method
243- is commonly used to retrieve environment-specific configuration.
243+ fetches only the specified key from the deployment secret, rather than
244+ the entire secret dictionary.
245+
246+ Args:
247+ key (str): The key to fetch from the deployment secret.
244248
245249 Returns:
246- Dict[str, Any]: Deployment configuration data , or empty dict if
247- component is unavailable or fetch fails .
250+ Any: The value for the specified key , or None if the key is not found
251+ or the component is unavailable.
248252
249253 Examples:
250- >>> # Get deployment configuration
251- >>> config = SecretStore.get_deployment_secret()
252- >>> if config:
253- ... print(f"Environment: {config.get('environment')}")
254- ... print(f"Region: {config.get('region')}")
255- >>> else:
256- ... print("No deployment configuration available")
257- >>> # Use in application initialization
258- >>> deployment_config = SecretStore.get_deployment_secret()
259- >>> if deployment_config.get('debug_mode'):
260- ... logging.getLogger().setLevel(logging.DEBUG)
254+ >>> # Get a specific deployment configuration value
255+ >>> auth_url = SecretStore.get_deployment_secret("ATLAN_AUTH_CLIENT_ID")
256+ >>> if auth_url:
257+ ... print(f"Auth URL: {auth_url}")
258+ >>> # Get deployment name
259+ >>> deployment_name = SecretStore.get_deployment_secret("deployment_name")
260+ >>> if deployment_name:
261+ ... print(f"Deployment: {deployment_name}")
261262 """
262263 if not is_component_registered (DEPLOYMENT_SECRET_STORE_NAME ):
263264 logger .warning (
264265 f"Deployment secret store component '{ DEPLOYMENT_SECRET_STORE_NAME } ' not registered."
265266 )
266- return {}
267+ return None
267268
268269 try :
269- return cls .get_secret (DEPLOYMENT_SECRET_PATH , DEPLOYMENT_SECRET_STORE_NAME )
270+ secret_data = cls .get_secret (
271+ DEPLOYMENT_SECRET_PATH , DEPLOYMENT_SECRET_STORE_NAME
272+ )
273+ if isinstance (secret_data , dict ) and key in secret_data :
274+ return secret_data [key ]
275+
276+ logger .debug (f"Multi-key not found, checking single-key secret for '{ key } '" )
277+ single_secret_data = cls .get_secret (key , DEPLOYMENT_SECRET_STORE_NAME )
278+ if isinstance (single_secret_data , dict ):
279+ # Handle both {key:value} and {"value": "..."} cases
280+ if key in single_secret_data :
281+ return single_secret_data [key ]
282+ elif len (single_secret_data ) == 1 :
283+ # extract single value
284+ return list (single_secret_data .values ())[0 ]
285+
286+ return None
287+
270288 except Exception as e :
271- logger .error (f"Failed to fetch deployment config: { e } " )
272- return {}
289+ logger .error (f"Failed to fetch deployment config key ' { key } ' : { e } " )
290+ return None
273291
274292 @classmethod
275293 def get_secret (
0 commit comments