@@ -418,6 +418,56 @@ func TestRender(t *testing.T) {
418418 },
419419 },
420420 },
421+ {
422+ name : "toYaml function" ,
423+ elements : []apiextensionsv1.JSON {
424+ {Raw : []byte (`{"env":"testing","depends":[{"name":"testing"}]}` )},
425+ },
426+ setOptions : []func (* templatesv1.GitOpsSet ){
427+ func (s * templatesv1.GitOpsSet ) {
428+ s .ObjectMeta .Annotations = map [string ]string {
429+ "templates.weave.works/delimiters" : "((,))" ,
430+ }
431+ s .Spec .Templates = []templatesv1.GitOpsSetTemplate {
432+ {
433+ Content : runtime.RawExtension {
434+ Raw : []byte (`{"apiVersion":"kustomize.toolkit.fluxcd.io/v1beta2","kind":"Kustomization","metadata":{"name":"testing-demo"},"spec":{"dependsOn":"(( .Element.depends | toYaml | nindent 8 ))","interval":"5m","path":"./examples/kustomize/environments/(( .Element.env ))","prune":true,"sourceRef":{"kind":"GitRepository","name":"go-demo-repo"}}}` ),
435+ },
436+ },
437+ }
438+ },
439+ },
440+ want : []* unstructured.Unstructured {
441+ {
442+ Object : map [string ]interface {}{
443+ "apiVersion" : "kustomize.toolkit.fluxcd.io/v1beta2" ,
444+ "kind" : "Kustomization" ,
445+ "metadata" : map [string ]interface {}{
446+ "name" : "testing-demo" ,
447+ "namespace" : "demo" ,
448+ "labels" : map [string ]interface {}{
449+ "templates.weave.works/name" : "test-gitops-set" ,
450+ "templates.weave.works/namespace" : "demo" ,
451+ },
452+ },
453+ "spec" : map [string ]interface {}{
454+ "dependsOn" : []any {
455+ map [string ]any {
456+ "name" : "testing" ,
457+ },
458+ },
459+ "interval" : "5m" ,
460+ "path" : "./examples/kustomize/environments/testing" ,
461+ "prune" : true ,
462+ "sourceRef" : map [string ]interface {}{
463+ "kind" : "GitRepository" ,
464+ "name" : "go-demo-repo" ,
465+ },
466+ },
467+ },
468+ },
469+ },
470+ },
421471 }
422472
423473 for _ , tt := range generatorTests {
0 commit comments