@@ -206,6 +206,34 @@ func TestRender(t *testing.T) {
206206 addLabels [* corev1.Namespace ](map [string ]string {"templates.weave.works/name" : "test-gitops-set" , "templates.weave.works/namespace" : testNS }))),
207207 },
208208 },
209+ {
210+ name : "repeat elements with no elements does not error" ,
211+ elements : []apiextensionsv1.JSON {
212+ {Raw : []byte (`{"env": "engineering-dev","externalIP": "192.168.50.50","namespaces":null}` )},
213+ },
214+ setOptions : []func (* templatesv1.GitOpsSet ){
215+ func (s * templatesv1.GitOpsSet ) {
216+ s .Spec .Templates = []templatesv1.GitOpsSetTemplate {
217+ {
218+ Content : runtime.RawExtension {
219+ Raw : mustMarshalJSON (t , makeTestService (types.NamespacedName {Name : "{{ .Element.env}}-demo1" , Namespace : testNS })),
220+ },
221+ },
222+ {
223+ Repeat : "{ $.namespaces }" ,
224+ Content : runtime.RawExtension {
225+ Raw : mustMarshalJSON (t , makeTestNamespace ("{{ .Repeat.name }}-{{ .Element.env }}" )),
226+ },
227+ },
228+ }
229+ },
230+ },
231+ want : []* unstructured.Unstructured {
232+ test .ToUnstructured (t , makeTestService (nsn (testNS , "engineering-dev-demo1" ), setClusterIP ("192.168.50.50" ),
233+ addAnnotations (map [string ]string {"app.kubernetes.io/instance" : "engineering-dev" }),
234+ addLabels [* corev1.Service ](map [string ]string {"templates.weave.works/name" : "test-gitops-set" , "templates.weave.works/namespace" : testNS }))),
235+ },
236+ },
209237 {
210238 name : "repeat elements with maps" ,
211239 elements : []apiextensionsv1.JSON {
0 commit comments