Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range function iterates over nested objects #1147

Open
francoisvandenplas opened this issue Jan 15, 2025 · 0 comments
Open

Range function iterates over nested objects #1147

francoisvandenplas opened this issue Jan 15, 2025 · 0 comments

Comments

@francoisvandenplas
Copy link

Hello,

It seems that the range function is also iterating over the nested interface

this template:

{{- range $index, $component := .Values }}
{{- if  (ne $index "global")  }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ $index }}-cm-component
  namespace: {{ $.Values.global.namespace }}
data:
  component: |
    {{ $component | toYaml | nindent 4 }}
{{- end }}
{{- end }}

with these values:

    global:
      namespace: app-dev
      env: dev
      scaling:
        replicas: 1
    listener:
      name: listener
      image: listener-img
      tag: develop
      process: outbound
      deployments:
        - name: xxx-listener
        - name: yyy-listener
          replicas: 1

    extractor:
      name: extractor
      image: extractor-img
      tag: developp
      process: inbound

      deployments:
        - name: xxx-extractor
          datatype: heartbeat-1
          format: AVRO
          replicas: 1
        - name: yyy-extractor
          datatype: heartbeat-2
          format: AVRO
          replicas: 1
        - name: zzz-extractor
          datatype: heartbeat-3
          format: AVRO
          replicas: 1

cause this error :

error while running post render on files: may not add resource with an already registered id: ConfigMap.v1.[noGrp]/deployments-cm-component.app-dev

The metadata.name is deployments-cm-component

if i add {{- if and (ne $index "global") (ne $index "deployments") }} , this cause this error :

error while running post render on files: may not add resource with an already registered id: ConfigMap.v1.[noGrp]/image-cm-component.app-dev
The metadata.name is image-cm-component

Is it an issue, or am i doing something wrong ?

François

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant