Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print details on connector name mismatch error #369

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
pipelines/
defaults/
site/
scratch*
2 changes: 1 addition & 1 deletion kpops/components/base_components/kafka_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def connector_config_should_have_component_name(
component_name = values["prefix"] + values["name"]
connector_name: str | None = app.get("name")
if connector_name is not None and connector_name != component_name:
msg = "Connector name should be the same as component name"
msg = f"Connector name '{connector_name}' should be the same as component name '{component_name}'"
raise ValueError(msg)
app["name"] = component_name
return app
Expand Down
11 changes: 9 additions & 2 deletions tests/components/test_kafka_connector.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from pathlib import Path
from unittest.mock import MagicMock

Expand Down Expand Up @@ -85,7 +86,10 @@ def test_connector_config_name_override(
assert connector.app.name == CONNECTOR_FULL_NAME

with pytest.raises(
ValueError, match="Connector name should be the same as component name"
ValueError,
match=re.escape(
f"Connector name 'different-name' should be the same as component name '{CONNECTOR_FULL_NAME}'"
),
):
KafkaConnector(
name=CONNECTOR_NAME,
Expand All @@ -96,7 +100,10 @@ def test_connector_config_name_override(
)

with pytest.raises(
ValueError, match="Connector name should be the same as component name"
ValueError,
match=re.escape(
f"Connector name '' should be the same as component name '{CONNECTOR_FULL_NAME}'"
),
):
KafkaConnector(
name=CONNECTOR_NAME,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kubernetes-app:
name: "${component_type}"
name: ${component_type}
namespace: example-namespace
kafka-app:
app:
Expand All @@ -24,7 +24,7 @@ streams-app: # inherits from kafka-app
cleanup.policy: compact,delete

kafka-connector:
name: "sink-connector"
name: sink-connector
app:
batch.size: "2000"
behavior.on.malformed.documents: "warn"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kubernetes-app:
name: "${component_type}-development"
name: ${component_type}-development
namespace: development-namespace