kaxil commented on a change in pull request #10559:
URL: https://github.com/apache/airflow/pull/10559#discussion_r477255782
##########
File path: airflow/secrets/__init__.py
##########
@@ -22,102 +22,12 @@
* Metastore database
* AWS SSM Parameter store
"""
-__all__ = ['BaseSecretsBackend', 'get_connections', 'get_variable',
'get_custom_secret_backend']
+__all__ = ['BaseSecretsBackend', 'DEFAULT_SECRETS_SEARCH_PATH',
'SECRETS_CONFIG_SECTION']
-import json
-from json import JSONDecodeError
-from typing import TYPE_CHECKING, List, Optional
-
-from airflow.configuration import conf
-from airflow.exceptions import AirflowNotFoundException
from airflow.secrets.base_secrets import BaseSecretsBackend
-from airflow.utils.module_loading import import_string
-
-if TYPE_CHECKING:
- from airflow.models.connection import Connection
-
-CONFIG_SECTION = "secrets"
+SECRETS_CONFIG_SECTION = "secrets"
Review comment:
```suggestion
```
##########
File path: airflow/secrets/__init__.py
##########
@@ -22,102 +22,12 @@
* Metastore database
* AWS SSM Parameter store
"""
-__all__ = ['BaseSecretsBackend', 'get_connections', 'get_variable',
'get_custom_secret_backend']
+__all__ = ['BaseSecretsBackend', 'DEFAULT_SECRETS_SEARCH_PATH',
'SECRETS_CONFIG_SECTION']
Review comment:
```suggestion
__all__ = ['BaseSecretsBackend', 'DEFAULT_SECRETS_SEARCH_PATH']
```
##########
File path: airflow/configuration.py
##########
@@ -951,3 +953,52 @@ def set(*args, **kwargs): # noqa pylint:
disable=redefined-builtin
stacklevel=2
)
return conf.set(*args, **kwargs)
+
+
+def ensure_secrets_loaded() -> List[BaseSecretsBackend]:
+ """
+ Ensure that all secrets backends are loaded.
+ If the secrets_backend_list contains only 2 default backends, reload it.
+ """
+ # Check if the secrets_backend_list contains only 2 default backends
+ if len(secrets_backend_list) == 2:
+ return initialize_secrets_backends()
+ return secrets_backend_list
+
+
+def get_custom_secret_backend() -> Optional[BaseSecretsBackend]:
+ """Get Secret Backend if defined in airflow.cfg"""
+ secrets_backend_cls = conf.getimport(section='secrets', key='backend')
+
+ if secrets_backend_cls:
+ try:
+ alternative_secrets_config_dict = json.loads(
+ conf.get(section=SECRETS_CONFIG_SECTION, key='backend_kwargs',
fallback='{}')
Review comment:
```suggestion
conf.get(section='secrets', key='backend_kwargs',
fallback='{}')
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]