Skip to content

Commit

Permalink
[8650] Add Yandex.Cloud custom connection to 1.10 (#8791)
Browse files Browse the repository at this point in the history
Co-authored-by: peevo <[email protected]>
  • Loading branch information
2 people authored and kaxil committed Jul 1, 2020
1 parent a8d8903 commit 3b70308
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions airflow/models/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Connection(Base, LoggingMixin):
('mongo', 'MongoDB'),
('gcpcloudsql', 'Google Cloud SQL'),
('grpc', 'GRPC Connection'),
('yandexcloud', 'Yandex Cloud'),
]

def __init__(
Expand Down
4 changes: 4 additions & 0 deletions airflow/www/static/connection_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
'login': 'Username',
}
},
yandexcloud: {
hidden_fields: ['host', 'schema', 'login', 'password', 'port', 'extra'],
relabeling: {},
},
}
function connTypeChange(connectionType) {
$("div.form-group").removeClass("hide");
Expand Down
12 changes: 11 additions & 1 deletion airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -3155,14 +3160,19 @@ 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
}

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}
Expand Down

0 comments on commit 3b70308

Please sign in to comment.