Commit eb96576b authored by Erik Sundell's avatar Erik Sundell Committed by Matthew Fisher

Reform indentation practices using nindent (#4562)

The essence of this commit is to help people get started with a better
indentation practice than this:

```yaml
spec:
  labels:
{{ toYaml .Values.labels | indent 4 }}
```

The previous indentation practice is harder to read. Instead this commit
introduces an indentation practice using `nindent` like this:

```yaml
spec:
  labels:
    {{- toYaml .Values.labels | nindent 4 }}
```
Signed-off-by: 's avatarErik Sundell <erik.i.sundell@gmail.com>
parent d41ca72e
...@@ -6,12 +6,13 @@ metadata: ...@@ -6,12 +6,13 @@ metadata:
# multiple times into the same namespace. # multiple times into the same namespace.
name: {{ template "nginx.fullname" . }} name: {{ template "nginx.fullname" . }}
labels: labels:
# The "app.kubernetes.io/managed-by" label is used to track which tool deployed a given chart. # The "app.kubernetes.io/managed-by" label is used to track which tool
# It is useful for admins who want to see what releases a particular tool # deployed a given chart. It is useful for admins who want to see what
# is responsible for. # releases a particular tool is responsible for.
app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/managed-by: {{ .Release.Service }}
# The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # The "app.kubernetes.io/instance" convention makes it easy to tie a release
# Kubernetes resources that were created as part of that release. # to all of the Kubernetes resources that were created as part of that
# release.
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
# This makes it easy to audit chart usage. # This makes it easy to audit chart usage.
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
...@@ -20,11 +21,11 @@ spec: ...@@ -20,11 +21,11 @@ spec:
replicas: {{ .Values.replicaCount }} replicas: {{ .Values.replicaCount }}
template: template:
metadata: metadata:
{{- if .Values.podAnnotations }} {{- if .Values.podAnnotations }}
# Allows custom annotations to be specified # Allows custom annotations to be specified
annotations: annotations:
{{ toYaml .Values.podAnnotations | indent 8 }} {{- toYaml .Values.podAnnotations | nindent 8 }}
{{- end }} {{- end }}
labels: labels:
app.kubernetes.io/name: {{ template "nginx.name" . }} app.kubernetes.io/name: {{ template "nginx.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
...@@ -42,14 +43,15 @@ spec: ...@@ -42,14 +43,15 @@ spec:
- mountPath: /usr/share/nginx/html - mountPath: /usr/share/nginx/html
name: wwwdata-volume name: wwwdata-volume
resources: resources:
# Allow chart users to specify resources. Usually, no default should be set, so this is left to be a conscious # Allow chart users to specify resources. Usually, no default should
# choice to the chart users and avoids that charts don't run out of the box on, e. g., Minikube when high resource # be set, so this is left to be a conscious choice to the chart
# requests are specified by default. # users and avoids that charts don't run out of the box on, e. g.,
{{ toYaml .Values.resources | indent 12 }} # Minikube when high resource requests are specified by default.
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.nodeSelector }} {{- if .Values.nodeSelector }}
nodeSelector: nodeSelector:
# Node selectors can be important on mixed Windows/Linux clusters. # Node selectors can be important on mixed Windows/Linux clusters.
{{ toYaml .Values.nodeSelector | indent 8 }} {{- toYaml .Values.nodeSelector | nindent 8 }}
{{- end }} {{- end }}
volumes: volumes:
- name: wwwdata-volume - name: wwwdata-volume
......
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
{{- if .Values.service.annotations }} {{- if .Values.service.annotations }}
annotations: annotations:
{{ toYaml .Values.service.annotations | indent 4 }} {{- toYaml .Values.service.annotations | nindent 4 }}
{{- end }} {{- end }}
labels: labels:
app.kubernetes.io/name: {{ template "nginx.name" . }} app.kubernetes.io/name: {{ template "nginx.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
...@@ -15,17 +15,17 @@ spec: ...@@ -15,17 +15,17 @@ spec:
# Provides options for the service so chart users have the full choice # Provides options for the service so chart users have the full choice
type: "{{ .Values.service.type }}" type: "{{ .Values.service.type }}"
clusterIP: "{{ .Values.service.clusterIP }}" clusterIP: "{{ .Values.service.clusterIP }}"
{{- if .Values.service.externalIPs }} {{- if .Values.service.externalIPs }}
externalIPs: externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }} {{- toYaml .Values.service.externalIPs | nindent 4 }}
{{- end }} {{- end }}
{{- if .Values.service.loadBalancerIP }} {{- if .Values.service.loadBalancerIP }}
loadBalancerIP: "{{ .Values.service.loadBalancerIP }}" loadBalancerIP: "{{ .Values.service.loadBalancerIP }}"
{{- end }} {{- end }}
{{- if .Values.service.loadBalancerSourceRanges }} {{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }} {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }} {{- end }}
ports: ports:
- name: http - name: http
port: {{ .Values.service.port }} port: {{ .Values.service.port }}
......
...@@ -138,10 +138,10 @@ metadata: ...@@ -138,10 +138,10 @@ metadata:
helm.sh/chart: {{ include "<CHARTNAME>.chart" . }} helm.sh/chart: {{ include "<CHARTNAME>.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.ingress.annotations }} {{- with .Values.ingress.annotations }}
annotations: annotations:
{{ toYaml . | indent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
{{- if .Values.ingress.tls }} {{- if .Values.ingress.tls }}
tls: tls:
...@@ -206,18 +206,18 @@ spec: ...@@ -206,18 +206,18 @@ spec:
path: / path: /
port: http port: http
resources: resources:
{{ toYaml .Values.resources | indent 12 }} {{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
{{ toYaml . | indent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
{{- with .Values.affinity }} {{- with .Values.affinity }}
affinity: affinity:
{{ toYaml . | indent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
{{- with .Values.tolerations }} {{- with .Values.tolerations }}
tolerations: tolerations:
{{ toYaml . | indent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
` `
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment