Skip to content

Commit

Permalink
add multihost validation tp kafka & mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
theedigerati committed Nov 24, 2024
1 parent e2bd55b commit adc20b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions keep/providers/kafka_provider/kafka_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
7 changes: 4 additions & 3 deletions keep/providers/mongodb_provider/mongodb_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import os
import random

# Adding a new test:
# 1. Manually:
# - Create a new test function.
Expand Down

0 comments on commit adc20b3

Please sign in to comment.