Skip to content

Commit c0eb8a1

Browse files
authored
Merge pull request #629 from opsmill/pog-develop-to-stable-20251113
Merge 'stable' into 'develop' with resolved conflicts
2 parents f532eac + 811c047 commit c0eb8a1

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang
1111

1212
<!-- towncrier release notes start -->
1313

14+
## [1.15.1](https://github.com/opsmill/infrahub-sdk-python/tree/v1.15.1) - 2025-11-13
15+
16+
### Fixed
17+
18+
- Fixed nested object template range expansion. ([#624](https://github.com/opsmill/infrahub-sdk-python/issues/624))
19+
1420
## [1.15.0](https://github.com/opsmill/infrahub-sdk-python/tree/v1.15.0) - 2025-11-10
1521

1622
### Added

infrahub_sdk/spec/object.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ async def process(self, client: InfrahubClient, branch: str | None = None) -> No
209209
position=[idx + 1],
210210
branch=branch,
211211
default_schema_kind=self.kind,
212+
parameters=self.parameters,
212213
)
213214

214215
@classmethod
@@ -458,7 +459,6 @@ async def create_node(
458459
data=value,
459460
branch=branch,
460461
default_schema_kind=default_schema_kind,
461-
parameters=parameters,
462462
)
463463
clean_data[key] = nodes[0]
464464

@@ -470,7 +470,9 @@ async def create_node(
470470
data=value,
471471
branch=branch,
472472
default_schema_kind=default_schema_kind,
473-
parameters=parameters,
473+
parameters=InfrahubObjectParameters(**value.get("parameters"))
474+
if "parameters" in value
475+
else None,
474476
)
475477
clean_data[key] = nodes
476478

@@ -509,7 +511,9 @@ async def create_node(
509511
context=context,
510512
branch=branch,
511513
default_schema_kind=default_schema_kind,
512-
parameters=parameters,
514+
parameters=InfrahubObjectParameters(**data[rel].get("parameters"))
515+
if "parameters" in data[rel]
516+
else None,
513517
)
514518

515519
return node

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "infrahub-sdk"
3-
version = "1.15.0"
3+
version = "1.15.1"
44
description = "Python Client to interact with Infrahub"
55
authors = [
66
{name = "OpsMill", email = "[email protected]"}

tests/unit/sdk/spec/test_object.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ def location_expansion_multiple_ranges_bad_syntax(root_location: dict) -> dict:
100100
return location
101101

102102

103+
@pytest.fixture
104+
def location_with_non_dict_parameters(root_location: dict) -> dict:
105+
data = [{"name": "Mexico", "type": "Country"}]
106+
location = root_location.copy()
107+
location["spec"]["data"] = data
108+
location["spec"]["parameters"] = "not_a_dict"
109+
return location
110+
111+
112+
@pytest.fixture
113+
def location_with_empty_parameters(root_location: dict) -> dict:
114+
data = [{"name": "Mexico", "type": "Country"}]
115+
location = root_location.copy()
116+
location["spec"]["data"] = data
117+
location["spec"]["parameters"] = {}
118+
return location
119+
120+
103121
async def test_validate_object(client: InfrahubClient, schema_query_01_data: dict, location_mexico_01) -> None:
104122
client.schema.set_cache(schema=schema_query_01_data, branch="main")
105123
obj = ObjectFile(location="some/path", content=location_mexico_01)
@@ -221,3 +239,27 @@ async def test_get_relationship_info_tags(
221239
rel_info = await get_relationship_info(client_with_schema_01, location_schema, "tags", data)
222240
assert rel_info.is_valid == is_valid
223241
assert rel_info.format == format
242+
243+
244+
async def test_parameters_top_level(client_with_schema_01: InfrahubClient, location_expansion) -> None:
245+
obj = ObjectFile(location="some/path", content=location_expansion)
246+
await obj.validate_format(client=client_with_schema_01)
247+
assert obj.spec.parameters.expand_range is True
248+
249+
250+
async def test_parameters_missing(client_with_schema_01: InfrahubClient, location_mexico_01) -> None:
251+
obj = ObjectFile(location="some/path", content=location_mexico_01)
252+
await obj.validate_format(client=client_with_schema_01)
253+
assert hasattr(obj.spec.parameters, "expand_range")
254+
255+
256+
async def test_parameters_empty_dict(client_with_schema_01: InfrahubClient, location_with_empty_parameters) -> None:
257+
obj = ObjectFile(location="some/path", content=location_with_empty_parameters)
258+
await obj.validate_format(client=client_with_schema_01)
259+
assert hasattr(obj.spec.parameters, "expand_range")
260+
261+
262+
async def test_parameters_non_dict(client_with_schema_01: InfrahubClient, location_with_non_dict_parameters) -> None:
263+
obj = ObjectFile(location="some/path", content=location_with_non_dict_parameters)
264+
with pytest.raises(ValidationError):
265+
await obj.validate_format(client=client_with_schema_01)

0 commit comments

Comments
 (0)