Skip to content

Commit c5e1456

Browse files
authored
Merge pull request #4892 from opsmill/pog-connect-automation-to-specific-computed-attribute
Tie Prefect automation for computed attribute to target specific attribute
2 parents d83ca7f + db23cf9 commit c5e1456

File tree

1 file changed

+13
-2
lines changed
  • backend/infrahub/computed_attribute

1 file changed

+13
-2
lines changed

backend/infrahub/computed_attribute/tasks.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,22 @@ async def process_transform(
118118

119119
@flow(name="process_computed_attribute_jinja2", log_prints=True)
120120
async def process_jinja2(
121-
branch_name: str, node_kind: str, object_id: str, updated_fields: list[str] | None = None
121+
branch_name: str,
122+
node_kind: str,
123+
object_id: str,
124+
computed_attribute_name: str,
125+
computed_attribute_kind: str,
126+
updated_fields: list[str] | None = None,
122127
) -> None:
123128
"""Request to the creation of git branches in available repositories."""
124129
service = services.service
125130
schema_branch = registry.schema.get_schema_branch(name=branch_name)
126131

127-
computed_macros = schema_branch.get_impacted_macros(kind=node_kind, updates=updated_fields)
132+
computed_macros = [
133+
attrib
134+
for attrib in schema_branch.get_impacted_macros(kind=node_kind, updates=updated_fields)
135+
if attrib.kind == computed_attribute_kind and attrib.attribute.name == computed_attribute_name
136+
]
128137
for computed_macro in computed_macros:
129138
found = []
130139
for id_filter in computed_macro.node_filters:
@@ -238,6 +247,8 @@ async def computed_attribute_setup() -> None:
238247
"branch_name": "{{ event.resource['infrahub.branch.name'] }}",
239248
"node_kind": "{{ event.resource['infrahub.node.kind'] }}",
240249
"object_id": "{{ event.resource['infrahub.node.id'] }}",
250+
"computed_attribute_name": computed_attribute.attribute.name,
251+
"computed_attribute_kind": computed_attribute.kind,
241252
},
242253
job_variables={},
243254
)

0 commit comments

Comments
 (0)