annetutil / annet

configuration generation and deploying utility for network equipment
https://annetutil.github.io/annet/
MIT License
49 stars 19 forks source link

Fix: JSONFragment: leak config between running #131

Closed grigory51 closed 1 week ago

grigory51 commented 1 week ago

When generator run in ann deploy, after deploy all generators re-running for check diff.

If re-run generator, it will have config after prev running and results will be strange.

For example:

class Susanin(JSONFragment):
    def path(self, device: DeviceView) -> str:
       ...

    def acl(self, _) -> List[str]:
        return [
            "/disabled_nodes",
            "/disabled_links",
        ]

   def run(self, device) -> str:
         with self.block("disabled_nodes"):
            yield []
        with self.block("disabled_links"):
            yield []

Get:

-    "disabled_links": [],
-    "disabled_nodes": [],
+    "disabled_links": [
+        [],
+        []
+    ],
+    "disabled_nodes": [
+        [],
+        []
+    ],

But no diff in realy.