holos-run / holos

Holos - The Holistic platform manager
https://holos.run
Apache License 2.0
21 stars 0 forks source link

Idempotent Join #274

Closed jeffmccune closed 1 month ago

jeffmccune commented 1 month ago

Why is the join transformer test case not idempotent?

jeffmccune commented 1 month ago

The issue is attributable to re-using the same Resources struct in 3 different generators. This is not a valid test becaue it makes no sense to duplicate resources like this.

Changing the test to ensure each generator generates a unique resource is idempotent, so there's nothing to fix here.

If this issue comes up again, a work-around is to use a final Kustomize transformer. Kustomize is designed to produce idempotent output.

Test:

while git diff --quiet; do holos render platform ./platform; done

Change:

diff --git a/examples/v1alpha4/projects/tests/join/output.cue b/examples/v1alpha4/projects/tests/join/output.cue
index ece8b30..9fc72ed 100644
--- a/examples/v1alpha4/projects/tests/join/output.cue
+++ b/examples/v1alpha4/projects/tests/join/output.cue
@@ -31,19 +31,19 @@ import (
                                artifact: "clusters/\(_Tags.cluster)/components/\(Name)/\(Name).gen.yaml"
                                generators: [
                                        {
-                                               kind:      "Resources"
-                                               output:    "1.yaml"
-                                               resources: Resources
+                                               kind:   "Resources"
+                                               output: "1.yaml"
+                                               resources: Namespace: jeff: #Namespaces["\(_Tags.environment)-jeff"]
                                        },
                                        {
-                                               kind:      "Resources"
-                                               output:    "2.yaml"
-                                               resources: Resources
+                                               kind:   "Resources"
+                                               output: "2.yaml"
+                                               resources: Namespace: gary: #Namespaces["\(_Tags.environment)-gary"]
                                        },
                                        {
-                                               kind:      "Resources"
-                                               output:    "3.yaml"
-                                               resources: Resources
+                                               kind:   "Resources"
+                                               output: "3.yaml"
+                                               resources: Namespace: nate: #Namespaces["\(_Tags.environment)-nate"]
                                        },
                                ]
                                transformers: [{