Skip to content
Open
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 infrahub_sdk/schema/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class InfrahubPythonTransformConfig(InfrahubRepositoryConfigElement):
default=False,
description="Decide if the transform should convert the result of the GraphQL query to SDK InfrahubNode objects.",
)
description: str | None = Field(default=None, description="Description for this transform")

def load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubTransform]:
module = import_module(module_path=self.file_path, import_root=import_root, relative_path=relative_path)
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/sdk/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,27 @@ async def test_infrahub_repository_config_dups() -> None:
assert "Found multiples element with the same names: ['check01', 'check02']" in str(exc.value)


async def test_python_transform_config_description() -> None:
"""Verify InfrahubPythonTransformConfig supports an optional description field."""
# With description
config_with_desc = InfrahubPythonTransformConfig(
name="my_transform", file_path="transforms/my.py", class_name="MyTransform", description="A useful transform"
)
assert config_with_desc.description == "A useful transform"

# Without description (default None)
config_without_desc = InfrahubPythonTransformConfig(
name="my_transform", file_path="transforms/my.py", class_name="MyTransform"
)
assert config_without_desc.description is None

# Explicit None
config_explicit_none = InfrahubPythonTransformConfig(
name="my_transform", file_path="transforms/my.py", class_name="MyTransform", description=None
)
assert config_explicit_none.description is None


@mock.patch(
"infrahub_sdk.ctl.schema.get_node",
return_value={
Expand Down
Loading