Skip to content

Commit

Permalink
Print details on connector name mismatch error (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted authored Oct 11, 2023
1 parent 74dd373 commit 10f02a9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
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

0 comments on commit 10f02a9

Please sign in to comment.