From adc20b393a13b84a78082ead0528915c58b420b0 Mon Sep 17 00:00:00 2001 From: theedigerati <39467790+theedigerati@users.noreply.github.com> Date: Sun, 24 Nov 2024 16:35:43 +0100 Subject: [PATCH] add multihost validation tp kafka & mongo --- keep/providers/kafka_provider/kafka_provider.py | 7 ++++--- keep/providers/mongodb_provider/mongodb_provider.py | 7 ++++--- tests/e2e_tests/test_end_to_end.py | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/keep/providers/kafka_provider/kafka_provider.py b/keep/providers/kafka_provider/kafka_provider.py index af2a9bcac..f95fd35ed 100644 --- a/keep/providers/kafka_provider/kafka_provider.py +++ b/keep/providers/kafka_provider/kafka_provider.py @@ -14,6 +14,7 @@ from keep.providers.base.base_provider import BaseProvider from keep.providers.models.provider_config import ProviderConfig, ProviderScope from keep.providers.providers_factory import ProvidersFactory +from keep.validation.fields import NoSchemeMultiHostUrl @pydantic.dataclasses.dataclass @@ -22,12 +23,12 @@ class KafkaProviderAuthConfig: Kafka authentication configuration. """ - host: pydantic.AnyUrl = dataclasses.field( + host: NoSchemeMultiHostUrl = dataclasses.field( metadata={ "required": True, "description": "Kafka host", - "hint": "e.g. https://kafka:9092", - "validation": "any_url" + "hint": "e.g. localhost:9092 or localhost:9092,localhost:8093", + "validation": "no_scheme_multihost_url" }, ) topic: str = dataclasses.field( diff --git a/keep/providers/mongodb_provider/mongodb_provider.py b/keep/providers/mongodb_provider/mongodb_provider.py index 6cfc71abe..50252e101 100644 --- a/keep/providers/mongodb_provider/mongodb_provider.py +++ b/keep/providers/mongodb_provider/mongodb_provider.py @@ -13,16 +13,17 @@ from keep.exceptions.provider_config_exception import ProviderConfigException from keep.providers.base.base_provider import BaseProvider from keep.providers.models.provider_config import ProviderConfig, ProviderScope +from keep.validation.fields import MultiHostUrl @pydantic.dataclasses.dataclass class MongodbProviderAuthConfig: - host: pydantic.AnyUrl = dataclasses.field( + host: MultiHostUrl = dataclasses.field( metadata={ "required": True, "description": "Mongo host_uri", - "hint": "any valid mongo host_uri like mongodb://host:port, user:paassword@host:port?authSource", - "validation": "any_url", + "hint": "mongodb+srv://host:port, mongodb://host1:port1,host2:port2?authSource", + "validation": "multihost_url", } ) username: str = dataclasses.field( diff --git a/tests/e2e_tests/test_end_to_end.py b/tests/e2e_tests/test_end_to_end.py index 903f1a6c5..6b922d011 100644 --- a/tests/e2e_tests/test_end_to_end.py +++ b/tests/e2e_tests/test_end_to_end.py @@ -24,7 +24,6 @@ import os import random - # Adding a new test: # 1. Manually: # - Create a new test function.