Skip to content

Commit

Permalink
Remove required validations in Hashicorp Vault conn form
Browse files Browse the repository at this point in the history
apache#30057 added a couple field validators in a new connection form for Hashicorp Vault. Behind the scenes, all connection form data is persisted upon submission. When creating a new connection that isn't Hashicrop Vault, these fields would not contain values that satisfy the validators of the fields.

Making sure these offending fields are either optional or have a default value in the Hashicorp Vault conn form.
  • Loading branch information
josh-fell committed Mar 16, 2023
1 parent 2842a0f commit 6c8e38a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions airflow/providers/hashicorp/hooks/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import BooleanField, IntegerField, StringField
from wtforms.validators import NumberRange, any_of
from wtforms.validators import NumberRange, Optional, any_of

return {
"auth_type": StringField(lazy_gettext("Auth type"), widget=BS3TextFieldWidget()),
Expand All @@ -378,6 +378,8 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:
lazy_gettext("KV engine version"),
validators=[any_of([1, 2])],
widget=BS3TextFieldWidget(),
description="Must be 1 or 2.",
default=DEFAULT_KV_ENGINE_VERSION,
),
"role_id": StringField(lazy_gettext("Role ID (deprecated)"), widget=BS3TextFieldWidget()),
"kubernetes_role": StringField(lazy_gettext("Kubernetes role"), widget=BS3TextFieldWidget()),
Expand All @@ -392,8 +394,8 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:
"radius_host": StringField(lazy_gettext("Radius host"), widget=BS3TextFieldWidget()),
"radius_port": IntegerField(
lazy_gettext("Radius port"),
validators=[NumberRange(min=0)],
widget=BS3TextFieldWidget(),
validators=[Optional(), NumberRange(min=0)],
),
"use_tls": BooleanField(lazy_gettext("Use TLS"), default=True),
}
Expand Down

0 comments on commit 6c8e38a

Please sign in to comment.