Skip to content

Commit

Permalink
[sink.kafka] Make config more consistent with others. (#44)
Browse files Browse the repository at this point in the history
Our newer sinks are using `ssl: bool` and `verify_ssl: bool`, use it
here.
  • Loading branch information
nhairs authored Oct 18, 2024
1 parent ca258ad commit 97cd3c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Use a `.kafka:Kafka` Sink.
- `user`: moved to `client.username`.
- `password`: moved to `client.password`.
- `ssl`: moved to `client.ssl`.
- `skip_certificate_verification`: moved to `client.skip_certificate_verification`.
- `skip_certificate_verification`: moved to `client.verify_ssl`.
- `aggregate_topic`: moved to `aggregate_report_topic`.
- `forensic_topic`: moved to `forensic_report_topic`.

Expand Down
9 changes: 5 additions & 4 deletions src/parsedmarc/sink/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ def setup(self) -> None:
self._state = AppState.SETTING_UP

try:
if self.config.client.skip_certificate_verification:
if self.config.client.verify_ssl:
# Use default context
ssl_context = None
else:
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
else:
ssl_context = None

self.client = kafkaclient.KafkaClient(
kafka_hosts=self.config.client.hosts,
Expand Down Expand Up @@ -77,6 +78,6 @@ class KafkaConfig(BaseConfig):
class KafkaClient(BaseModel):
hosts: List[str]
ssl: bool = True
skip_certificate_verification: bool = False
verify_ssl: bool = True
username: str | None = None
password: str | None = None

0 comments on commit 97cd3c9

Please sign in to comment.