potiuk commented on a change in pull request #12558:
URL: https://github.com/apache/airflow/pull/12558#discussion_r537778955
##########
File path: airflow/www/forms.py
##########
@@ -276,71 +230,14 @@ class ConnectionForm(DynamicForm):
port = IntegerField(lazy_gettext('Port'), validators=[Optional()],
widget=BS3TextFieldWidget())
extra = TextAreaField(lazy_gettext('Extra'),
widget=BS3TextAreaFieldWidget())
- # Used to customized the form, the forms elements get rendered
+ # You should add connection form fields in the hooks via
get_connection_form_widgets() method
+ # See for example airflow/providers/jdbc/hooks/jdbc.py
+ # It is esed to customized the form, the forms elements get rendered
# and results are stored in the extra field as json. All of these
# need to be prefixed with extra__ and then the conn_type ___ as in
# extra__{conn_type}__name. You can also hide form elements and rename
# others from the connection_form.js file
- extra__jdbc__drv_path = StringField(lazy_gettext('Driver Path'),
widget=BS3TextFieldWidget())
- extra__jdbc__drv_clsname = StringField(lazy_gettext('Driver Class'),
widget=BS3TextFieldWidget())
- extra__google_cloud_platform__project = StringField(
- lazy_gettext('Project Id'), widget=BS3TextFieldWidget()
- )
- extra__google_cloud_platform__key_path = StringField(
- lazy_gettext('Keyfile Path'), widget=BS3TextFieldWidget()
- )
- extra__google_cloud_platform__keyfile_dict = PasswordField(
- lazy_gettext('Keyfile JSON'), widget=BS3PasswordFieldWidget()
- )
- extra__google_cloud_platform__scope = StringField(
- lazy_gettext('Scopes (comma separated)'), widget=BS3TextFieldWidget()
- )
- extra__google_cloud_platform__num_retries = IntegerField(
- lazy_gettext('Number of Retries'),
- validators=[NumberRange(min=0)],
- widget=BS3TextFieldWidget(),
- default=5,
- )
- extra__grpc__auth_type = StringField(lazy_gettext('Grpc Auth Type'),
widget=BS3TextFieldWidget())
- extra__grpc__credential_pem_file = StringField(
- lazy_gettext('Credential Keyfile Path'), widget=BS3TextFieldWidget()
- )
- extra__grpc__scopes = StringField(lazy_gettext('Scopes (comma
separated)'), widget=BS3TextFieldWidget())
- extra__yandexcloud__service_account_json = PasswordField(
- lazy_gettext('Service account auth JSON'),
- widget=BS3PasswordFieldWidget(),
- description='Service account auth JSON. Looks like '
- '{"id", "...", "service_account_id": "...", "private_key": "..."}. '
- 'Will be used instead of OAuth token and SA JSON file path field if
specified.',
- )
- extra__yandexcloud__service_account_json_path = StringField(
- lazy_gettext('Service account auth JSON file path'),
- widget=BS3TextFieldWidget(),
- description='Service account auth JSON file path. File content looks
like '
- '{"id", "...", "service_account_id": "...", "private_key": "..."}. '
- 'Will be used instead of OAuth token if specified.',
- )
- extra__yandexcloud__oauth = PasswordField(
- lazy_gettext('OAuth Token'),
- widget=BS3PasswordFieldWidget(),
- description='User account OAuth token. Either this or service account
JSON must be specified.',
- )
- extra__yandexcloud__folder_id = StringField(
- lazy_gettext('Default folder ID'),
- widget=BS3TextFieldWidget(),
- description='Optional. This folder will be used to create all new
clusters and nodes by default',
- )
- extra__yandexcloud__public_ssh_key = StringField(
- lazy_gettext('Public SSH key'),
- widget=BS3TextFieldWidget(),
- description='Optional. This key will be placed to all created Compute
nodes'
- 'to let you have a root shell there',
- )
- extra__kubernetes__in_cluster = BooleanField(lazy_gettext('In cluster
configuration'))
- extra__kubernetes__kube_config_path = StringField(
- lazy_gettext('Kube config path'), widget=BS3TextFieldWidget()
- )
- extra__kubernetes__kube_config = StringField(
- lazy_gettext('Kube config (JSON format)'), widget=BS3TextFieldWidget()
- )
- extra__kubernetes__namespace = StringField(lazy_gettext('Namespace'),
widget=BS3TextFieldWidget())
+
+
+for key, value in ProvidersManager().connection_form_widgets.items():
+ setattr(ConnectionForm, key, value.field)
Review comment:
I think I found a perfect place and I also do the field cusomisation in
the same PR as they seem to be very nicely connected now.
----------------------------------------------------------------
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]