It is not clear how a generator target object should be properly deleted within Infrahub.
When you delete the target node from the target group, then the generator does not seem to delete all the objects that the generator created as a result of the target.
When you delete the target node from Infrahub, then the generator will raise an error message.
Expected Behavior
We should have a clear and defined way to delete generator target nodes and the resulting objects.
Steps to Reproduce
load the following schema
---
version: "1.0"
nodes:
- name: TagService
namespace: Test
attributes:
- name: name
label: Name
kind: Text
optional: false
unique: true
- name: amount
label: Amount
kind: Number
optional: false
query TagService($name: String!) {
TestTagService(name__value: $name) {
edges {
node {
name {
value
}
amount {
value
}
}
}
}
}
from infrahub_sdk.generator import InfrahubGenerator
class TestTagService(InfrahubGenerator):
async def generate(self, data: dict) -> None:
service = data["TestTagService"]["edges"][0]["node"]
name = service["name"]["value"]
amount = service["amount"]["value"]
for i in range(amount):
tag = await self.client.create(kind="BuiltinTag", name=f"{name}-{i+1}")
await tag.save(allow_upsert=True)
- create/syn the external repository in Infrahub
- create a new branch in Infrahub
- create a TestTagService object with name test and amount 3
- add the TestTagService object to the `tag_services` group
- create a proposed change to merge the branch into main
- 3 tags will have been created
- merge the branch
- create a new branch in Infrahub
- delete the TestTagService object from the `tag_services` group
- open a proposed change for the branch
- the generator will run, but it will not delete the tag objects
- open a new branch in Infrahub
- delete the TestTagService object
- open a proposed change for the branch
- the generator will raise an error message (and the tag object will not have been deleted)
### Additional Information
_No response_
Component
API Server / GraphQL
Current Behavior
It is not clear how a generator target object should be properly deleted within Infrahub.
When you delete the target node from the target group, then the generator does not seem to delete all the objects that the generator created as a result of the target.
When you delete the target node from Infrahub, then the generator will raise an error message.
Expected Behavior
We should have a clear and defined way to delete generator target nodes and the resulting objects.
Steps to Reproduce
tag_services
in Infrahubclass TestTagService(InfrahubGenerator): async def generate(self, data: dict) -> None: service = data["TestTagService"]["edges"][0]["node"]