Skip to content

Commit

Permalink
chore: replace if with with (and improve strip using with -)
Browse files Browse the repository at this point in the history
Signed-off-by: WrenIX <[email protected]>
  • Loading branch information
WrenIX committed Feb 2, 2024
1 parent 76825b4 commit 52f5312
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 63 deletions.
16 changes: 8 additions & 8 deletions charts/nextcloud/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: app
{{- if .Values.ingress.labels }}
{{ toYaml .Values.ingress.labels | indent 4 }}
{{- with .Values.ingress.labels }}
{{- toYaml . | indent 4 }}
{{- end }}
{{- if .Values.ingress.annotations }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- with .Values.ingress.className }}
ingressClassName: {{ . }}
{{- end }}
rules:
- host: {{ .Values.nextcloud.host }}
Expand All @@ -38,8 +38,8 @@ spec:
serviceName: {{ template "nextcloud.fullname" . }}
servicePort: {{ .Values.service.port }}
{{- end }}
{{- if .Values.ingress.tls }}
{{- with .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- toYaml . | indent 4 }}
{{- end }}
{{- end }}
15 changes: 8 additions & 7 deletions charts/nextcloud/templates/metrics/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ spec:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: metrics
{{- if .Values.metrics.podLabels }}
{{ toYaml .Values.metrics.podLabels | indent 8 }}
{{- end }}
{{- with .Values.metrics.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.metrics.image.pullSecrets }}
{{- with .Values.metrics.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.metrics.image.pullSecrets }}
{{- range . }}
- name: {{ . }}
{{- end}}
{{- end }}
Expand Down Expand Up @@ -66,8 +66,9 @@ spec:
ports:
- name: metrics
containerPort: 9205
{{- if .Values.metrics.resources }}
resources: {{- toYaml .Values.metrics.resources | nindent 10 }}
{{- with .Values.metrics.resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
securityContext:
runAsUser: 1000
Expand Down
18 changes: 10 additions & 8 deletions charts/nextcloud/templates/metrics/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: metrics
{{- if .Values.metrics.service.labels -}}
{{ toYaml .Values.metrics.service.labels | nindent 4 }}
{{- with .Values.metrics.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end -}}
{{- if .Values.metrics.service.annotations }}
annotations: {{ toYaml .Values.metrics.service.annotations | nindent 4 }}
{{- with .Values.metrics.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.metrics.service.type }}
{{ if eq .Values.metrics.service.type "LoadBalancer" -}} {{ if .Values.metrics.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }}
{{ end -}}
{{- end -}}
{{- if eq .Values.metrics.service.type "LoadBalancer" }}
{{- with .Values.metrics.service.loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- end }}
ports:
- name: metrics
port: 9205
Expand Down
18 changes: 7 additions & 11 deletions charts/nextcloud/templates/metrics/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "nextcloud.fullname" . }}
{{- if .Values.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.metrics.serviceMonitor.namespace | quote }}
{{- else }}
namespace: {{ .Release.Namespace | quote }}
{{- end }}
namespace: {{ .Values.metrics.serviceMonitor.namespace | default .Release.Namespace | quote }}
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: metrics
{{- if .Values.metrics.serviceMonitor.labels -}}
{{ toYaml .Values.metrics.serviceMonitor.labels | nindent 4 }}
{{- with .Values.metrics.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel | quote }}
Expand All @@ -30,10 +26,10 @@ spec:
endpoints:
- port: metrics
path: "/"
{{- if .Values.metrics.serviceMonitor.interval }}
interval: {{ .Values.metrics.serviceMonitor.interval }}
{{- with .Values.metrics.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
{{- with .Values.metrics.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- end }}
14 changes: 7 additions & 7 deletions charts/nextcloud/templates/nextcloud-data-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: app
{{- if .Values.persistence.nextcloudData.annotations }}
{{- with .Values.persistence.nextcloudData.annotations }}
annotations:
{{ toYaml .Values.persistence.nextcloudData.annotations | indent 4 }}
{{- toYaml . | indent 4 }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.nextcloudData.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.nextcloudData.size | quote }}
{{- if .Values.persistence.nextcloudData.storageClass }}
{{- if (eq "-" .Values.persistence.nextcloudData.storageClass) }}
{{- with .Values.persistence.nextcloudData.storageClass }}
{{- if (eq "-" .) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.nextcloudData.storageClass }}"
storageClassName: "{{ . }}"
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end }}
{{- end }}
14 changes: 7 additions & 7 deletions charts/nextcloud/templates/nextcloud-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: app
{{- if .Values.persistence.annotations }}
{{- with .Values.persistence.annotations }}
annotations:
{{ toYaml .Values.persistence.annotations | indent 4 }}
{{- toYaml . | indent 4 }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
{{- with .Values.persistence.storageClass }}
{{- if (eq "-" .) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
storageClassName: "{{ . }}"
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end }}
{{- end }}
14 changes: 7 additions & 7 deletions charts/nextcloud/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ metadata:
type: Opaque
data:
nextcloud-username: {{ .Values.nextcloud.username | b64enc | quote }}
{{- if .Values.nextcloud.password }}
nextcloud-password: {{ .Values.nextcloud.password | b64enc | quote }}
{{- with .Values.nextcloud.password }}
nextcloud-password: {{ . | b64enc | quote }}
{{- else }}
nextcloud-password: {{ randAlphaNum 10 | b64enc | quote }}
{{- end }}
{{- if .Values.metrics.token }}
nextcloud-token: {{ .Values.metrics.token | b64enc | quote }}
{{- with .Values.metrics.token }}
nextcloud-token: {{ . | b64enc | quote }}
{{- else }}
nextcloud-token: {{ randAlphaNum 10 | b64enc | quote }}
{{- end }}
{{- if .Values.nextcloud.mail.enabled }}
smtp-username: {{ default "" .Values.nextcloud.mail.smtp.name | b64enc | quote }}
smtp-password: {{ default "" .Values.nextcloud.mail.smtp.password | b64enc | quote }}
smtp-host: {{ default "" .Values.nextcloud.mail.smtp.host | b64enc | quote }}
smtp-username: {{ .Values.nextcloud.mail.smtp.name | default "" | b64enc | quote }}
smtp-password: {{ .Values.nextcloud.mail.smtp.password | default "" | b64enc | quote }}
smtp-host: {{ .Values.nextcloud.mail.smtp.host | default "" | b64enc | quote }}
{{- end }}
{{- end }}
12 changes: 6 additions & 6 deletions charts/nextcloud/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ metadata:
spec:
type: {{ .Values.service.type }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }}
loadBalancerIP: {{ default "" .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP | default "" }}
{{- end }}
{{- if .Values.service.ipFamilies }}
{{- with .Values.service.ipFamilies }}
ipFamilies:
{{- toYaml .Values.service.ipFamilies | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.service.ipFamilyPolicy }}
ipFamilyPolicy: {{ .Values.service.ipFamilyPolicy }}
{{- with .Values.service.ipFamilyPolicy }}
ipFamilyPolicy: {{ . }}
{{- end }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.nextcloud.containerPort }}
protocol: TCP
name: http
{{- if eq .Values.service.type "NodePort" }}
nodePort: {{ default "" .Values.service.nodePort}}
nodePort: {{ .Values.service.nodePort | default "" }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
Expand Down
4 changes: 2 additions & 2 deletions charts/nextcloud/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.rbac.serviceaccount.name }}
{{- if .Values.rbac.serviceaccount.annotations }}
{{- with .Values.rbac.serviceaccount.annotations }}
annotations:
{{- toYaml .Values.rbac.serviceaccount.annotations | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

0 comments on commit 52f5312

Please sign in to comment.