Skip to content

Commit

Permalink
Using nindent to allow formatting helm with proper indentation (#256)
Browse files Browse the repository at this point in the history
* Using nindent to allow formatting helm with proper indentation

Our helm chart was formatted with non-standard indentation to allow the templating to result in the correct output

This is not ideal, as:
 - Tools expect certain indentation and when you go against this, they no longer help you and/or point out things as errors when they aren't
 - Makes it hard to read and understand the actual resulting indentation

Now we helm charts can be written with the same indentation that the resulting yaml will have, making it much easier to work with

* Including all files, accidentally missed in first commit
  • Loading branch information
JamesMurkin authored Nov 28, 2019
1 parent 65aa547 commit eb3a23a
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 66 deletions.
32 changes: 16 additions & 16 deletions deployment/armada/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ metadata:
name: {{ include "armada.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "armada.labels.all" . | indent 4 }}
{{- include "armada.labels.all" . | nindent 4 }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
{{ include "armada.labels.identity" . | indent 6 }}
{{- if .Values.strategy }}
{{- include "armada.labels.identity" . | nindent 6 }}
{{- if .Values.strategy }}
strategy:
{{ toYaml .Values.strategy | indent 4 }}
{{- end }}
{{- toYaml .Values.strategy | nindent 4 }}
{{- end }}
template:
metadata:
name: {{ include "armada.name" . }}
labels:
{{ include "armada.labels.all" . | indent 8 }}
{{- include "armada.labels.all" . | nindent 8 }}
spec:
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
serviceAccountName: {{ include "armada.name" . }}
Expand All @@ -32,12 +32,12 @@ spec:
args:
- --config
- /config/application_config.yaml
{{- if .Values.env }}
{{- if .Values.env }}
env:
{{ toYaml .Values.env | indent 12 }}
{{- end }}
{{- toYaml .Values.env | nindent 12 -}}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- toYaml .Values.resources | nindent 12 -}}
ports:
- containerPort: {{ .Values.applicationConfig.grpcPort }}
protocol: TCP
Expand All @@ -53,9 +53,9 @@ spec:
mountPath: /config/application_config.yaml
subPath: {{ include "armada.config.filename" . }}
readOnly: true
{{- if .Values.additionalVolumeMounts }}
{{ toYaml .Values.additionalVolumeMounts | indent 12 }}
{{- end }}
{{- if .Values.additionalVolumeMounts }}
{{- toYaml .Values.additionalVolumeMounts | nindent 12 -}}
{{- end }}
securityContext:
allowPrivilegeEscalation: false
readinessProbe:
Expand All @@ -80,6 +80,6 @@ spec:
- name: user-config
secret:
secretName: {{ include "armada.config.name" . }}
{{- if .Values.additionalVolumes }}
{{ toYaml .Values.additionalVolumes | indent 8 }}
{{- end }}
{{- if .Values.additionalVolumes }}
{{- toYaml .Values.additionalVolumes | nindent 8 }}
{{- end }}
2 changes: 1 addition & 1 deletion deployment/armada/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
certmanager.k8s.io/cluster-issuer: {{ required "A value is required for .Values.clusterIssuer" .Values.clusterIssuer }}
labels:
{{ include "armada.labels.all" . | indent 4 }}
{{- include "armada.labels.all" . | nindent 4 }}
spec:
rules:
- host: {{ required "A value is required for .Values.hostname" .Values.hostname }}
Expand Down
2 changes: 1 addition & 1 deletion deployment/armada/templates/ingressrest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
certmanager.k8s.io/cluster-issuer: {{ required "A value is required for .Values.clusterIssuer" .Values.clusterIssuer }}
nginx.ingress.kubernetes.io/rewrite-target: /$2
labels:
{{ include "armada.labels.all" . | indent 4 }}
{{- include "armada.labels.all" . | nindent 4 }}
spec:
rules:
- host: {{ required "A value is required for .Values.hostname" .Values.hostname }}
Expand Down
8 changes: 4 additions & 4 deletions deployment/armada/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ metadata:
name: {{ include "armada.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "armada.labels.all" . | indent 4 }}
{{- if .Values.prometheus.labels }}
{{ toYaml .Values.prometheus.labels | indent 4 }}
{{- end }}
{{- include "armada.labels.all" . | nindent 4 -}}
{{- if .Values.prometheus.labels }}
{{- toYaml .Values.prometheus.labels | nindent 4 -}}
{{- end }}
spec:
groups:
- name: grpc-server-metrics
Expand Down
2 changes: 1 addition & 1 deletion deployment/armada/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ include "armada.config.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "armada.labels.all" . | indent 4 }}
{{- include "armada.labels.all" . | nindent 4 }}
type: Opaque
data:
{{ include "armada.config.filename" . }}: |
Expand Down
4 changes: 2 additions & 2 deletions deployment/armada/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ metadata:
name: {{ include "armada.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "armada.labels.all" . | indent 4 }}
{{- include "armada.labels.all" . | nindent 4 }}
spec:
{{- if .Values.nodePort }}
type: NodePort
{{- end }}
selector:
{{ include "armada.labels.identity" . | indent 4 }}
{{- include "armada.labels.identity" . | nindent 4 }}
ports:
- name: grpc
protocol: TCP
Expand Down
2 changes: 1 addition & 1 deletion deployment/armada/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: {{ include "armada.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "armada.labels.all" . | indent 4 }}
{{- include "armada.labels.all" . | nindent 4 }}
10 changes: 5 additions & 5 deletions deployment/armada/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ metadata:
name: {{ include "armada.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "armada.labels.all" . | indent 4 }}
{{- if .Values.prometheus.labels }}
{{ toYaml .Values.prometheus.labels | indent 4 }}
{{- end }}
{{- include "armada.labels.all" . | nindent 4 -}}
{{- if .Values.prometheus.labels }}
{{- toYaml .Values.prometheus.labels | nindent 4 -}}
{{- end }}
spec:
selector:
matchLabels:
{{ include "armada.labels.identity" . | indent 6 }}
{{- include "armada.labels.identity" . | nindent 6 }}
endpoints:
- port: metrics
interval: 3s
Expand Down
2 changes: 1 addition & 1 deletion deployment/executor/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterRole
metadata:
name: {{ include "executor.name" . }}
labels:
{{ include "executor.labels.all" . | indent 4 }}
{{- include "executor.labels.all" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand Down
10 changes: 5 additions & 5 deletions deployment/executor/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ include "executor.name" . }}
labels:
{{ include "executor.labels.all" . | indent 4 }}
{{- include "executor.labels.all" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand All @@ -20,13 +20,13 @@ kind: ClusterRoleBinding
metadata:
name: {{ include "executor.name" $root }}-{{ .nameSuffix }}
labels:
{{ include "executor.labels.all" $root | indent 4 }}
{{- include "executor.labels.all" $root | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .clusterRoleName }}
subjects:
- kind: ServiceAccount
name: {{ include "executor.name" $root }}
namespace: {{ $root.Release.Namespace }}
- kind: ServiceAccount
name: {{ include "executor.name" $root }}
namespace: {{ $root.Release.Namespace }}
{{ end }}
25 changes: 12 additions & 13 deletions deployment/executor/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ metadata:
name: {{ include "executor.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "executor.labels.all" . | indent 4 }}
{{- include "executor.labels.all" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{ include "executor.labels.identity" . | indent 6 }}
{{- include "executor.labels.identity" . | nindent 6 }}
template:
metadata:
name: {{ include "executor.name" . }}
labels:
{{ include "executor.labels.all" . | indent 8 }}
{{- include "executor.labels.all" . | nindent 8 }}
spec:
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
serviceAccountName: {{ include "executor.name" . }}
Expand All @@ -33,7 +33,7 @@ spec:
{{ toYaml .Values.env | indent 12 }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- toYaml .Values.resources | nindent 12 -}}
ports:
- containerPort: 9001
protocol: TCP
Expand All @@ -43,20 +43,19 @@ spec:
mountPath: /config/application_config.yaml
subPath: {{ include "executor.config.filename" . }}
readOnly: true
{{- if .Values.additionalVolumeMounts }}
{{ toYaml .Values.additionalVolumeMounts | indent 12 }}
{{- end }}
{{- if .Values.additionalVolumeMounts }}
{{- toYaml .Values.additionalVolumeMounts | nindent 12 -}}
{{- end }}
securityContext:
allowPrivilegeEscalation: false
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- toYaml .Values.nodeSelector | nindent 8 -}}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- toYaml .Values.tolerations | nindent 8 -}}
volumes:
- name: user-config
secret:
secretName: {{ include "executor.config.name" . }}
{{- if .Values.additionalVolumes }}
{{ toYaml .Values.additionalVolumes | indent 8 }}
{{- end }}

{{- if .Values.additionalVolumes }}
{{- toYaml .Values.additionalVolumes | nindent 8 }}
{{- end }}
8 changes: 4 additions & 4 deletions deployment/executor/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ metadata:
name: {{ include "executor.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "executor.labels.all" . | indent 4 }}
{{- if .Values.prometheus.labels }}
{{ toYaml .Values.prometheus.labels | indent 4 }}
{{- end }}
{{- include "executor.labels.all" . | nindent 4 }}
{{- if .Values.prometheus.labels }}
{{- toYaml .Values.prometheus.labels | nindent 4 }}
{{- end }}
spec:
groups:
- name: armada-pods
Expand Down
8 changes: 4 additions & 4 deletions deployment/executor/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ metadata:
name: {{ include "executor.config.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "executor.labels.all" . | indent 4 }}
{{- include "executor.labels.all" . | nindent 4 }}
type: Opaque
data:
{{ include "executor.config.filename" . }}: |
{{- if .Values.applicationConfig }}
{{ toYaml .Values.applicationConfig | b64enc | indent 4 }}
{{- end }}
{{- if .Values.applicationConfig }}
{{- toYaml .Values.applicationConfig | b64enc | indent 4 }}
{{- end }}
4 changes: 2 additions & 2 deletions deployment/executor/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ metadata:
name: {{ include "executor.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "executor.labels.all" . | indent 4 }}
{{- include "executor.labels.all" . | nindent 4 }}
spec:
selector:
{{ include "executor.labels.identity" . | indent 4 }}
{{- include "executor.labels.identity" . | nindent 4 }}
ports:
- name: metrics
protocol: TCP
Expand Down
2 changes: 1 addition & 1 deletion deployment/executor/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: {{ include "executor.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "executor.labels.all" . | indent 4 }}
{{- include "executor.labels.all" . | nindent 4 }}
10 changes: 5 additions & 5 deletions deployment/executor/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ metadata:
name: {{ include "executor.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "executor.labels.all" . | indent 4 }}
{{- if .Values.prometheus.labels }}
{{ toYaml .Values.prometheus.labels | indent 4 }}
{{- end }}
{{- include "executor.labels.all" . | nindent 4 }}
{{- if .Values.prometheus.labels }}
{{- toYaml .Values.prometheus.labels | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{ include "executor.labels.identity" . | indent 6 }}
{{- include "executor.labels.identity" . | nindent 6 }}
endpoints:
- port: metrics
interval: 3s
Expand Down

0 comments on commit eb3a23a

Please sign in to comment.