You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2020/05/09 06:00:41 UTC

[airflow] branch v1-10-test updated: [8650] Add Yandex.Cloud custom connection to 1.10 (#8791)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v1-10-test by this push:
     new 185cab5  [8650] Add Yandex.Cloud custom connection to 1.10 (#8791)
185cab5 is described below

commit 185cab52aee657eb8a95b97cf28bb87646650299
Author: peter-volkov <pe...@yandex.ru>
AuthorDate: Sat May 9 09:00:04 2020 +0300

    [8650] Add Yandex.Cloud custom connection to 1.10 (#8791)
    
    Co-authored-by: peevo <pe...@yandex-team.ru>
---
 airflow/models/connection.py          |  1 +
 airflow/www/static/connection_form.js |  4 ++++
 airflow/www/views.py                  | 12 +++++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/airflow/models/connection.py b/airflow/models/connection.py
index ee74d22..a1c2253 100644
--- a/airflow/models/connection.py
+++ b/airflow/models/connection.py
@@ -107,6 +107,7 @@ class Connection(Base, LoggingMixin):
         ('mongo', 'MongoDB'),
         ('gcpcloudsql', 'Google Cloud SQL'),
         ('grpc', 'GRPC Connection'),
+        ('yandexcloud', 'Yandex Cloud'),
     ]
 
     def __init__(
diff --git a/airflow/www/static/connection_form.js b/airflow/www/static/connection_form.js
index 8517ad2..0f668ae 100644
--- a/airflow/www/static/connection_form.js
+++ b/airflow/www/static/connection_form.js
@@ -70,6 +70,10 @@
             'login': 'Username',
           }
         },
+        yandexcloud: {
+            hidden_fields: ['host', 'schema', 'login', 'password', 'port', 'extra'],
+            relabeling: {},
+        },
       }
       function connTypeChange(connectionType) {
         $("div.form-group").removeClass("hide");
diff --git a/airflow/www/views.py b/airflow/www/views.py
index dc1a455..3a4fef5 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -3120,6 +3120,11 @@ class ConnectionModelView(wwwutils.SuperUserMixin, AirflowModelView):
         'extra__grpc__auth_type',
         'extra__grpc__credentials_pem_file',
         'extra__grpc__scopes',
+        'extra__yandexcloud__service_account_json',
+        'extra__yandexcloud__service_account_json_path',
+        'extra__yandexcloud__oauth',
+        'extra__yandexcloud__public_ssh_key',
+        'extra__yandexcloud__folder_id',
     )
     verbose_name = "Connection"
     verbose_name_plural = "Connections"
@@ -3155,6 +3160,11 @@ class ConnectionModelView(wwwutils.SuperUserMixin, AirflowModelView):
         'extra__grpc__auth_type': StringField('Grpc Auth Type'),
         'extra__grpc__credentials_pem_file': StringField('Credential Keyfile Path'),
         'extra__grpc__scopes': StringField('Scopes (comma separated)'),
+        'extra__yandexcloud__service_account_json': PasswordField('Service account auth JSON'),
+        'extra__yandexcloud__service_account_json_path': StringField('Service account auth JSON file path'),
+        'extra__yandexcloud__oauth': PasswordField('OAuth Token'),
+        'extra__yandexcloud__public_ssh_key': StringField('Public SSH key'),
+        'extra__yandexcloud__folder_id': StringField('Default folder ID'),
     }
     form_choices = {
         'conn_type': Connection._types
@@ -3162,7 +3172,7 @@ class ConnectionModelView(wwwutils.SuperUserMixin, AirflowModelView):
 
     def on_model_change(self, form, model, is_created):
         formdata = form.data
-        if formdata['conn_type'] in ['jdbc', 'google_cloud_platform', 'gprc']:
+        if formdata['conn_type'] in ['jdbc', 'google_cloud_platform', 'gprc', 'yandexcloud']:
             extra = {
                 key: formdata[key]
                 for key in self.form_extra_fields.keys() if key in formdata}