cloudposse / charts

The "Cloud Posse" Distribution of Kubernetes Applications
https://cloudposse.com/accelerate
Apache License 2.0
158 stars 63 forks source link

Fix bad yaml when only secretKeyRef #267

Open asiegman opened 3 years ago

asiegman commented 3 years ago

Found a bug with my previous feature.

If you specified only a secretKeyRef, and not an accompanying fieldRef, the env: tag would be missing in the yaml section, causing invalid yaml as such:

      containers:
      - name: mything
        image: mything:latest
        imagePullPolicy: Always

        envFrom:
        - configMapRef:
            name: mything-env-default

          - name: MYTHING_USERNAME
            valueFrom:
              secretKeyRef:
                name: mything-user
                key: username
          - name: MYTHING_PASSWORD
            valueFrom:
              secretKeyRef:
                name: mything-user
                key: password

This fixes this bug, so that if either fieldKeyRef or secretKeyRefs are referenced, the env: section will have the appropriate yaml

      containers:
      - name: mything
        image: mything:latest
        imagePullPolicy: Always

        envFrom:
        - configMapRef:
            name: mything-env-default

        env:

          - name: MYTHING_USERNAME
            valueFrom:
              secretKeyRef:
                name: mything-user
                key: username
          - name: MYTHING_PASSWORD
            valueFrom:
              secretKeyRef:
                name: mything-user
                key: password