datawire / forge

Define and run multi-container apps in Kubernetes
http://forge.sh
Apache License 2.0
416 stars 43 forks source link

Comments not respected it seems like during parsing. #176

Closed pkim-auro closed 6 years ago

pkim-auro commented 6 years ago

In k8s/deployment.yaml

{{ forge.profile }}

This gives an error: portfolio-service: /home/pkim/git/portfolio-service/k8s/./deployment.yaml: 'forge' is undefined

  #{{orge.profile }} 

also error: portfolio-service: /home/pkim/git/portfolio-service/k8s/./deployment.yaml: 'orge' is undefined

  #{{ build.name }} 

correctly builds and does not show.

maybe this is expected but when i comment out a line and it doesn't show up the interior shouldn't error out.

plombardi89 commented 6 years ago

Can you show us the complete YAML template?

pkim-auro commented 6 years ago

i added it as the last line of hello-world-python

---
apiVersion: v1
kind: Service
metadata:
  name: {{build.name}}
  {%- if "endpoint" in build.profile %}
  annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v0
      kind: Mapping
      name: {{build.name}}-mapping
      prefix: {{build.profile.endpoint}}
      service: {{build.name}}
      {%- if "weight" in build.profile %}
      weight: {{build.profile.weight}}
      {%- endif %}
  {%- endif %}
spec:
  selector:
    app: {{build.name}}
  ports:
    - port: 80
      targetPort: http-api
  type: ClusterIP
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: {{build.name}}
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: {{build.name}}
    spec:
      containers:
      - name: {{build.name}}
        image: {{build.images["Dockerfile"]}}
        imagePullPolicy: Always
        resources:
          requests:
            memory: 0.1G
            cpu: 0.1
          limits:
            memory: {{build.profile.max_memory}}
            cpu: {{build.profile.max_cpu}}
        ports:
        - name: http-api
          containerPort: 8080
        #{{ forge.yaml }}
pkim-auro commented 6 years ago

After learning a bit more about Jinja template handling, this appears to be correct behavior because comments in Jinja are bookended by {# and #}. So the line starting with # is trying to render a comment whose content could be templated. I now believe this is correct behavior and will close. Apologies for the noise.