Skip to content

Commit

Permalink
Update logging & doc for LocalFilesystem Secrets Backend (apache#12597)
Browse files Browse the repository at this point in the history
- Support towards YAML is added in PR apache#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed
  • Loading branch information
XD-DENG authored Nov 25, 2020
1 parent 663259d commit c6467ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions airflow/secrets/local_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ def _parse_secret_file(file_path: str) -> Dict[str, Any]:
ext = file_path.rsplit(".", 2)[-1].lower()

if ext not in FILE_PARSERS:
raise AirflowException("Unsupported file format. The file must have the extension .env or .json")
raise AirflowException(
"Unsupported file format. The file must have the extension .env or .json or .yaml"
)

secrets, parse_errors = FILE_PARSERS[ext](file_path)

Expand Down Expand Up @@ -223,7 +225,7 @@ def load_variables(file_path: str) -> Dict[str, str]:
"""
Load variables from a text file.
Both ``JSON`` and ``.env`` files are supported.
``JSON``, `YAML` and ``.env`` files are supported.
:param file_path: The location of the file that will be processed.
:type file_path: str
Expand Down Expand Up @@ -254,7 +256,7 @@ def load_connections_dict(file_path: str) -> Dict[str, Any]:
"""
Load connection from text file.
Both ``JSON`` and ``.env`` files are supported.
``JSON``, `YAML` and ``.env`` files are supported.
:return: A dictionary where the key contains a connection ID and the value contains a list of connections.
:rtype: Dict[str, airflow.models.connection.Connection]
Expand Down Expand Up @@ -283,7 +285,7 @@ class LocalFilesystemBackend(BaseSecretsBackend, LoggingMixin):
"""
Retrieves Connection objects and Variables from local files
Both ``JSON`` and ``.env`` files are supported.
``JSON``, `YAML` and ``.env`` files are supported.
:param variables_file_path: File location with variables data.
:type variables_file_path: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The keys ``extra`` and ``extra_dejson`` are mutually exclusive.

The JSON file must contain an object where the key contains the connection ID and the value contains
the definition of one connection. The connection can be defined as a URI (string) or JSON object.
For a guide about defining a connection as a URI, see:: :ref:`generating_connection_uri`.
For a guide about defining a connection as a URI, see :ref:`generating_connection_uri`.
For a description of the connection object parameters see :class:`~airflow.models.connection.Connection`.
The following is a sample JSON file.

Expand Down

0 comments on commit c6467ba

Please sign in to comment.