Skip to content

Commit

Permalink
Fail if streams-boostrap v3 model is instantiated with v2 attribute (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted authored Jan 14, 2025
1 parent d76f374 commit 1a2e8cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kpops/components/streams_bootstrap/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ class StreamsBootstrapValues(SerializeAsOptionalModel, HelmAppValues):
description=describe_attr("tolerations", __doc__),
)

@pydantic.model_validator(mode="before")
@classmethod
def unsupported_attributes(cls, values: Any) -> Any:
for attr in ("streams",):
if attr in values:
msg = f"streams-bootstrap v3 no longer supports '{attr}' attribute."
raise ValueError(msg)
return values


class KafkaConfig(CamelCaseConfigModel, DescConfigModel):
"""Kafka Streams config.
Expand Down
21 changes: 21 additions & 0 deletions tests/components/streams_bootstrap/test_streams_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,27 @@ async def test_should_raise_validation_error_for_invalid_helm_chart_version(self
},
)

def test_should_raise_validation_error_for_unsupported_attribute(self):
with pytest.raises(
ValueError,
match=re.escape(
"streams-bootstrap v3 no longer supports 'streams' attribute."
),
):
assert StreamsBootstrap.model_validate(
{
"name": "example-name",
"namespace": "test-namespace",
"values": {
"image": "streamsBootstrap",
"kafka": {
"bootstrapServers": "localhost:9092",
},
"streams": {},
},
},
)

@pytest.mark.parametrize(
("input", "expectation"),
[
Expand Down

0 comments on commit 1a2e8cf

Please sign in to comment.