This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new e2ec5ef Update example on docs/howto/connection/index.rst (#10236)
e2ec5ef is described below
commit e2ec5ef665247f511075fd2ad466e6f39c694366
Author: Kamil BreguĊa <[email protected]>
AuthorDate: Sun Aug 9 12:25:15 2020 +0200
Update example on docs/howto/connection/index.rst (#10236)
* Upddate example on docs/howto/connection/index.rst
* fixup! Upddate example on docs/howto/connection/index.rst
---
airflow/cli/commands/connection_command.py | 2 +-
docs/howto/connection/index.rst | 63 ++++++++++++---------------
tests/cli/commands/test_connection_command.py | 4 +-
3 files changed, 30 insertions(+), 39 deletions(-)
diff --git a/airflow/cli/commands/connection_command.py
b/airflow/cli/commands/connection_command.py
index 6f691a9..89d81f1 100644
--- a/airflow/cli/commands/connection_command.py
+++ b/airflow/cli/commands/connection_command.py
@@ -120,7 +120,7 @@ def _format_connections(conns: List[Connection], fmt: str)
-> str:
return yaml.dump(connections_dict)
if fmt == '.json':
- return json.dumps(connections_dict)
+ return json.dumps(connections_dict, indent=2)
return json.dumps(connections_dict)
diff --git a/docs/howto/connection/index.rst b/docs/howto/connection/index.rst
index 448b09f..7f4a869 100644
--- a/docs/howto/connection/index.rst
+++ b/docs/howto/connection/index.rst
@@ -118,62 +118,53 @@ The JSON format contains an object where the key contains
the connection ID and
.. code-block:: json
{
- "CONN_A": {
- "conn_type": "mysql",
- "host": "mysql",
- "login": "root",
- "password": "plainpassword",
- "schema": "airflow",
- "port": null,
- "extra": null,
- "is_encrypted": false,
- "is_extra_encrypted": false
- },
- "CONN_B": {
- "conn_type": "druid",
- "host": "druid-broker",
- "login": null,
- "password": null,
- "schema": null,
- "port": 8082,
- "extra": "{\"endpoint\": \"druid/v2/sql\"}",
- "is_encrypted": false,
- "is_extra_encrypted": false
- }
+ "airflow_db": {
+ "conn_type": "mysql",
+ "host": "mysql",
+ "login": "root",
+ "password": "plainpassword",
+ "schema": "airflow",
+ "port": null,
+ "extra": null
+ },
+ "druid_broker_default": {
+ "conn_type": "druid",
+ "host": "druid-broker",
+ "login": null,
+ "password": null,
+ "schema": null,
+ "port": 8082,
+ "extra": "{\"endpoint\": \"druid/v2/sql\"}"
+ }
}
The YAML file structure is similar to that of a JSON. The key-value pair of
connection ID and the definitions of one or more connections. In this format,
the connection is defined as a YAML object. The following is a sample YAML file.
.. code-block:: yaml
- CONN_A:
+ airflow_db:
conn_type: mysql
- extra:
+ extra: null
host: mysql
- is_encrypted: false
- is_extra_encrypted: false
login: root
password: plainpassword
- port:
+ port: null
schema: airflow
-
- CONN_B:
+ druid_broker_default:
conn_type: druid
extra: '{"endpoint": "druid/v2/sql"}'
host: druid-broker
- is_encrypted: false
- is_extra_encrypted: false
- login:
- password:
+ login: null
+ password: null
port: 8082
- schema:
+ schema: null
You may also export connections in ``.env`` format. The key is the connection
ID, and the value describes the connection using the URI. The following is a
sample ENV file.
.. code-block:: text
- CONN_A=mysql://root:plainpassword@mysql/airflow
- CONN_B=druid://druid-broker:8082?endpoint=druid%2Fv2%2Fsql
+ airflow_db=mysql://root:plainpassword@mysql/airflow
+ druid_broker_default=druid://druid-broker:8082?endpoint=druid%2Fv2%2Fsql
.. _environment_variables_secrets_backend:
diff --git a/tests/cli/commands/test_connection_command.py
b/tests/cli/commands/test_connection_command.py
index 911f62c..fae3115 100644
--- a/tests/cli/commands/test_connection_command.py
+++ b/tests/cli/commands/test_connection_command.py
@@ -287,7 +287,7 @@ class TestCliExportConnections(unittest.TestCase):
"port": 8082,
"extra": "{\"endpoint\": \"druid/v2/sql\"}",
}
- })
+ }, indent=2)
mock_splittext.assert_called_once()
mock_file_open.assert_called_once_with(output_filepath, 'w', -1,
'UTF-8', None)
@@ -403,7 +403,7 @@ class TestCliExportConnections(unittest.TestCase):
"port": 8082,
"extra": "{\"endpoint\": \"druid/v2/sql\"}",
}
- })
+ }, indent=2)
mock_splittext.assert_not_called()
mock_file_open.assert_called_once_with(output_filepath, 'w', -1,
'UTF-8', None)
mock_file_open.return_value.write.assert_called_once_with(expected_connections)