Refactor: Use helper for st2-config-vol volume/volumeMounts definitions by cognifloyd · Pull Request #198 · StackStorm/stackstorm-k8s

@cognifloyd

This reduces duplication of the st2-config-vol definitions in volumes: and volumeMounts: blocks.

@cognifloyd

pull-request-size bot says that this PR is size/L because it deletes a lot of lines. In templates/deployments.yaml and templates/jobs.yaml I added two lines for every 9 lines I removed:

---
apiVersion: ...
kind: ...
metadata:
  ...
spec:
  template:
    metadata:
      ...
    spec:
      ...
      containers:
      - name: ...
        ...
        volumeMounts:
-       - name: st2-config-vol
-         mountPath: /etc/st2/st2.docker.conf
-         subPath: st2.docker.conf
-       - name: st2-config-vol
-         mountPath: /etc/st2/st2.user.conf
-         subPath: st2.user.conf
+      {{- include "st2-config-volume-mounts" . | nindent 8 }}
      volumes:
-       - name: st2-config-vol
-         configMap:
-           name: {{ .Release.Name }}-st2-config
+      {{- include "st2-config-volume" . | nindent 8 }}

And then the template definition is just:
https://github.com/StackStorm/stackstorm-ha/blob/d330e353ab7a312cb7647c56e0bd441ee10b2509/templates/_helpers.tpl#L74-L87

@ericreeves

This seems like a great change.

@cognifloyd

ericreeves

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great.

@cognifloyd

@cognifloyd cognifloyd changed the title Move st2-config-vol volume/volumeMounts definitions to helpers Refactor: Use helper for st2-config-vol volume/volumeMounts definitions

Jul 3, 2021

ericreeves

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more much needed deduplication!

@cognifloyd

@armab This one is the next easiest PR to review. Please and thank you!

arm4b

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This reduces duplication.

@cognifloyd

@cognifloyd