feat: filter parameters from DB API (#21248)

This commit is contained in:
Beto Dealmeida
2022-09-02 11:50:04 -07:00
committed by GitHub
parent 99a4f05069
commit 34a79add04
29 changed files with 445 additions and 82 deletions

View File

@@ -43,6 +43,8 @@ class ValidateDatabaseParametersCommand(BaseCommand):
self._model: Optional[Database] = None
def run(self) -> None:
self.validate()
engine = self._properties["engine"]
driver = self._properties.get("driver")
@@ -71,7 +73,15 @@ class ValidateDatabaseParametersCommand(BaseCommand):
event_logger.log_with_context(action="validation_error", engine=engine)
raise InvalidParametersError(errors)
serialized_encrypted_extra = self._properties.get("encrypted_extra", "{}")
serialized_encrypted_extra = self._properties.get(
"masked_encrypted_extra",
"{}",
)
if self._model:
serialized_encrypted_extra = engine_spec.unmask_encrypted_extra(
self._model.encrypted_extra,
serialized_encrypted_extra,
)
try:
encrypted_extra = json.loads(serialized_encrypted_extra)
except json.decoder.JSONDecodeError:
@@ -119,6 +129,6 @@ class ValidateDatabaseParametersCommand(BaseCommand):
)
def validate(self) -> None:
database_name = self._properties.get("database_name")
if database_name is not None:
self._model = DatabaseDAO.get_database_by_name(database_name)
database_id = self._properties.get("id")
if database_id is not None:
self._model = DatabaseDAO.find_by_id(database_id)