opsmill / infrahub

Infrahub - A new approach to Infrastructure Management
https://opsmill.com/
GNU Affero General Public License v3.0
212 stars 18 forks source link

feature: deleting a generator target object should delete the created objects of that target #3289

Open wvandeun opened 6 months ago

wvandeun commented 6 months ago

Component

API Server / GraphQL

Current Behavior

It is not clear how a generator target object should be properly deleted within Infrahub.

Expected Behavior

We should have a clear and defined way to delete generator target nodes and the resulting objects.

Steps to Reproduce

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_
wvandeun commented 6 months ago

after discussion with @ogenstad it would be better to flag this as a feature request