kd icon indicating copy to clipboard operation
kd copied to clipboard

EOF if document contains --- in the middle of a condition block since 1.8.0

Open GJKrupa opened this issue 6 years ago • 2 comments

For example:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-map
data:
    my.value: 1
{{if eq .KUBE_NAMESPACE "my-prod"}}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-map-2
data:
    my.value: 2
{{end}}

We see the following error:

[ERROR] 2018/09/18 17:56:52 render.go:33: template: template:8: unexpected EOF

The last working version with these templates I can find is v0.13.0

GJKrupa avatar Sep 18 '18 17:09 GJKrupa

I get a similar problem if there is a --- inside a range

{{ range list 1 2 3 -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zookeeper{{ . }}
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: zookeeper
    spec:
      terminationGracePeriodSeconds: 30
      containers:
      - name: zookeeper
        image: bitnami/zookeeper:3.5.5
# .   ...
---
{{ end }}

PhilOfCalth avatar Aug 22 '19 17:08 PhilOfCalth

It can be gotten around by using a variable to replace the --- EG

{{ $end := "---" }}
{{ range list 1 2 3 -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zookeeper{{ . }}
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: zookeeper
    spec:
      terminationGracePeriodSeconds: 30
      containers:
      - name: zookeeper
        image: bitnami/zookeeper:3.5.5
# .   ...
{{ $end }}
{{ end }} 

PhilOfCalth avatar Aug 22 '19 17:08 PhilOfCalth