Enable yamllint rules for templates

- braces
- brackets
- colons
- commas
- comments
- comments-indentation
- document-start
- hyphens
- indentation

With corresponding code changes.

Also idempotency fix for lint script.

Change-Id: Ibe5281cbb4ad7970e92f3d1f921abb1efc89dc3b
This commit is contained in:
Andrii Ostapenko 2020-06-16 19:55:47 -05:00
parent ddfa7a4741
commit dfb32ccf60
35 changed files with 90 additions and 108 deletions

View File

@ -71,9 +71,9 @@ rules:
- namespaces
verbs:
- get
- apiGroups: ["batch" ]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get" ]
verbs: ["get"]
---
# This manifest installs the calico/node container, as well
# as the Calico CNI plugins and network config on

View File

@ -126,8 +126,8 @@ spec:
# conf.controllers expanded values
{{ include "helm-toolkit.utils.to_k8s_env_vars" .Values.conf.controllers | indent 12 }}
# etcd tls files
{{ if .Values.endpoints.etcd.auth.client.tls.ca }}
# etcd tls files
- name: ETCD_CA_CERT_FILE
value: {{ .Values.endpoints.etcd.auth.client.path.ca }}
{{ end }}

View File

@ -83,7 +83,7 @@ spec:
fieldRef:
fieldPath: metadata.namespace
- name: KUBECTL_PARAM
value: {{ tuple $envAll "ceph" "ceph-defragosd" | include "helm-toolkit.snippets.kubernetes_kubectl_params" | indent 10 }}
value: {{ tuple $envAll "ceph" "ceph-defragosd" | include "helm-toolkit.snippets.kubernetes_kubectl_params" }}
command:
- /tmp/utils-defragOSDs.sh
- cron
@ -105,6 +105,6 @@ spec:
emptyDir: {}
- name: ceph-client-bin
configMap:
name: ceph-client-bin
name: ceph-client-bin
defaultMode: 0555
{{- end }}

View File

@ -99,7 +99,7 @@ spec:
- name: MON_PORT_V2
value: {{ tuple "ceph_mon" "internal" "mon_msgr2" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }}
- name: KUBECTL_PARAM
value: {{ tuple $envAll "ceph" "checkdns" | include "helm-toolkit.snippets.kubernetes_kubectl_params" | indent 10 }}
value: {{ tuple $envAll "ceph" "checkdns" | include "helm-toolkit.snippets.kubernetes_kubectl_params" }}
command:
- /tmp/_start.sh
volumeMounts:

View File

@ -98,14 +98,14 @@ spec:
ports:
- containerPort: 6800
livenessProbe:
tcpSocket:
port: 6800
initialDelaySeconds: 60
timeoutSeconds: 5
tcpSocket:
port: 6800
initialDelaySeconds: 60
timeoutSeconds: 5
readinessProbe:
tcpSocket:
port: 6800
timeoutSeconds: 5
tcpSocket:
port: 6800
timeoutSeconds: 5
volumeMounts:
- name: pod-tmp
mountPath: /tmp

View File

@ -118,19 +118,19 @@ spec:
containerPort: {{ tuple "ceph_mgr" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
{{ end -}}
livenessProbe:
exec:
command:
- /tmp/mgr-check.sh
- liveness
initialDelaySeconds: 30
timeoutSeconds: 5
exec:
command:
- /tmp/mgr-check.sh
- liveness
initialDelaySeconds: 30
timeoutSeconds: 5
readinessProbe:
exec:
command:
- /tmp/mgr-check.sh
- readiness
initialDelaySeconds: 30
timeoutSeconds: 5
exec:
command:
- /tmp/mgr-check.sh
- readiness
initialDelaySeconds: 30
timeoutSeconds: 5
volumeMounts:
- name: pod-tmp
mountPath: /tmp

View File

@ -136,7 +136,7 @@ spec:
- name: CEPH_PUBLIC_NETWORK
value: {{ .Values.network.public | quote }}
- name: KUBECTL_PARAM
value: {{ tuple $envAll "ceph" "mon" | include "helm-toolkit.snippets.kubernetes_kubectl_params" | indent 10 }}
value: {{ tuple $envAll "ceph" "mon" | include "helm-toolkit.snippets.kubernetes_kubectl_params" }}
- name: MON_PORT
value: {{ tuple "ceph_mon" "internal" "mon" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }}
- name: MON_PORT_V2
@ -157,26 +157,26 @@ spec:
- /tmp/mon-start.sh
lifecycle:
preStop:
exec:
command:
- /tmp/mon-stop.sh
exec:
command:
- /tmp/mon-stop.sh
ports:
- containerPort: {{ tuple "ceph_mon" "internal" "mon" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
- containerPort: {{ tuple "ceph_mon" "internal" "mon_msgr2" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
livenessProbe:
exec:
command:
- /tmp/mon-check.sh
- liveness
initialDelaySeconds: 360
periodSeconds: 180
exec:
command:
- /tmp/mon-check.sh
- liveness
initialDelaySeconds: 360
periodSeconds: 180
readinessProbe:
exec:
command:
- /tmp/mon-check.sh
- readiness
initialDelaySeconds: 60
periodSeconds: 60
exec:
command:
- /tmp/mon-check.sh
- readiness
initialDelaySeconds: 60
periodSeconds: 60
volumeMounts:
- name: pod-tmp
mountPath: /tmp

View File

@ -68,7 +68,7 @@ spec:
initContainers:
{{ tuple $envAll "job_keyring_generator" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
- name: {{ $jobName }}
- name: {{ $jobName }}
{{ tuple $envAll "ceph_config_helper" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ tuple $envAll $envAll.Values.pod.resources.jobs.secret_provisioning | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
{{ dict "envAll" $envAll "application" "ceph" "container" "$jobName" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}

View File

@ -70,7 +70,7 @@ spec:
initContainers:
{{ tuple $envAll "storage_keys_generator" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
- name: ceph-storage-keys-generator
- name: ceph-storage-keys-generator
{{ tuple $envAll "ceph_config_helper" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ tuple $envAll $envAll.Values.pod.resources.jobs.secret_provisioning | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
{{ dict "envAll" $envAll "application" "storage_keys_generator" "container" "ceph_storage_keys_generator" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}

View File

@ -98,7 +98,7 @@ spec:
initContainers:
{{ tuple $envAll "cephfs_client_key_generator" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
- name: ceph-storage-keys-generator
- name: ceph-storage-keys-generator
{{ tuple $envAll "ceph_config_helper" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ tuple $envAll $envAll.Values.pod.resources.jobs.secret_provisioning | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
{{ dict "envAll" $envAll "application" "cephfs_client_key_generator" "container" "ceph_storage_keys_generator" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}

View File

@ -36,7 +36,7 @@ metadata:
type: Opaque
data:
elasticsearch.yml: {{ toYaml .Values.conf.elasticsearch.config | b64enc }}
#NOTE(portdirect): this must be last, to work round helm ~2.7 bug.
# NOTE(portdirect): this must be last, to work round helm ~2.7 bug.
{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.httpd "key" "httpd.conf" "format" "Secret") | indent 2 }}
{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.log4j2 "key" "log4j2.properties" "format" "Secret") | indent 2 }}
{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.jvm_options "key" "jvm.options" "format" "Secret") | indent 2 }}

View File

@ -103,7 +103,7 @@ spec:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
fieldPath: metadata.name
- name: ELASTICSEARCH_USERNAME
valueFrom:
secretKeyRef:

View File

@ -97,7 +97,7 @@ spec:
{{ tuple $envAll "flannel" | include "helm-toolkit.snippets.image" | indent 10 }}
securityContext:
privileged: true
command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr" ]
command: ["/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr"]
env:
- name: POD_NAME
valueFrom:
@ -116,7 +116,7 @@ spec:
mountPath: /etc/kube-flannel/
- name: install-cni
image: {{ .Values.images.tags.flannel }}
command: [ "/bin/sh", "-c", "set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf; while true; do sleep 3600; done" ]
command: ["/bin/sh", "-c", "set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf; while true; do sleep 3600; done"]
volumeMounts:
- name: pod-tmp
mountPath: /tmp

View File

@ -22,7 +22,7 @@ metadata:
spec:
ports:
- name: forward
port: {{ tuple "fluentd" "internal" "service" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
port: {{ tuple "fluentd" "internal" "service" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
{{ if .Values.network.fluentd.node_port.enabled }}
nodePort: {{ .Values.network.fluentd.node_port.port }}
{{ end }}

View File

@ -22,6 +22,6 @@ metadata:
type: Opaque
data:
kibana.yml: {{ toYaml .Values.conf.kibana | b64enc }}
#NOTE(portdirect): this must be last, to work round helm ~2.7 bug.
# NOTE(portdirect): this must be last, to work round helm ~2.7 bug.
{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.httpd "key" "httpd.conf" "format" "Secret") | indent 2 }}
{{- end }}

View File

@ -33,7 +33,7 @@ spec:
{{ $envAll.Values.labels.test.node_selector_key }}: {{ $envAll.Values.labels.test.node_selector_value | quote }}
restartPolicy: Never
initContainers:
{{ tuple $envAll "tests" $mounts_kubernetes_keystone_webhook_tests_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
{{ tuple $envAll "tests" $mounts_kubernetes_keystone_webhook_tests_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }}
containers:
- name: {{ $envAll.Release.Name }}-kubernetes-keystone-webhook-test
{{ tuple $envAll "scripted_test" | include "helm-toolkit.snippets.image" | indent 6 }}

View File

@ -24,5 +24,5 @@ spec:
- name: ldap
port: {{ tuple "ldap" "internal" "ldap" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
selector:
{{ tuple $envAll "ldap" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
{{ tuple $envAll "ldap" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
{{- end }}

View File

@ -81,7 +81,7 @@ spec:
- metadata:
name: ldap-data
spec:
accessModes: [ "ReadWriteOnce" ]
accessModes: ["ReadWriteOnce"]
storageClassName: {{ .Values.storage.pvc.class_name }}
resources:
requests:
@ -89,7 +89,7 @@ spec:
- metadata:
name: ldap-config
spec:
accessModes: [ "ReadWriteOnce" ]
accessModes: ["ReadWriteOnce"]
storageClassName: {{ .Values.storage.pvc.class_name }}
resources:
requests:

View File

@ -37,7 +37,7 @@ spec:
{{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }}
restartPolicy: Never
initContainers:
{{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
{{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }}
containers:
- name: mariadb-test
{{ dict "envAll" $envAll "application" "tests" "container" "test" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 6 }}

View File

@ -263,7 +263,7 @@ spec:
- metadata:
name: mysql-data
spec:
accessModes: [ "ReadWriteOnce" ]
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.volume.size }}

View File

@ -15,8 +15,8 @@ limitations under the License.
{{- if .Values.manifests.deployment }}
{{- $envAll := . }}
{{- $rcControllerName := printf "%s-%s" $envAll.Release.Name "memcached" }}
{{- $configMapBinName := printf "%s-%s" $envAll.Release.Name "memcached-bin" }}
{{- $rcControllerName := printf "%s-%s" $envAll.Release.Name "memcached" }}
{{- $configMapBinName := printf "%s-%s" $envAll.Release.Name "memcached-bin" }}
{{ tuple $envAll "memcached" $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
---

View File

@ -24,5 +24,5 @@ spec:
- name: db
port: {{ tuple "mongodb" "internal" "mongodb" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
selector:
{{ tuple $envAll "mongodb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
{{ tuple $envAll "mongodb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
{{- end }}

View File

@ -130,7 +130,7 @@ spec:
annotations:
{{ .Values.volume.class_path }}: {{ .Values.volume.class_name }}
spec:
accessModes: [ "ReadWriteOnce" ]
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.volume.size }}

View File

@ -30,6 +30,6 @@ data:
{{- $objectFile := printf "%s.cfg" $objectType -}}
{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" $config.template "key" $objectFile "format" "Secret") | indent 2 }}
{{- end }}
#NOTE(portdirect): this must be last, to work round helm ~2.7 bug.
# NOTE(portdirect): this must be last, to work round helm ~2.7 bug.
{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.httpd "key" "httpd.conf" "format" "Secret") | indent 2 }}
{{- end }}

View File

@ -43,7 +43,7 @@ metadata:
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
verbs: ['use']
verbs: ['use']
resourceNames:
- {{ $pspName }}
{{- end }}

View File

@ -23,4 +23,3 @@ type: Opaque
data:
admin_user.conf: {{ tuple "secrets/_admin_user.conf.tpl" . | include "helm-toolkit.utils.template" | b64enc }}
{{- end }}

View File

@ -24,5 +24,5 @@ spec:
- name: restapi
port: {{ tuple "postgresql-restapi" "internal" "restapi" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
selector:
{{ tuple $envAll "postgresql" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
{{ tuple $envAll "postgresql" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
{{- end }}

View File

@ -448,7 +448,7 @@ spec:
annotations:
{{ .Values.storage.pvc.class_path }}: {{ .Values.storage.pvc.class_name }}
spec:
accessModes: [ "ReadWriteOnce" ]
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.storage.pvc.size }}

View File

@ -88,14 +88,14 @@ spec:
mountPath: /tmp
- name: proc
mountPath: /host/proc
readOnly: true
readOnly: true
- name: sys
mountPath: /host/sys
readOnly: true
readOnly: true
{{ if .Values.conf.collectors.textfile.directory }}
- name: stats-out
mountPath: {{.Values.conf.collectors.textfile.directory }}
readOnly: true
readOnly: true
{{ end }}
- name: node-exporter-bin
mountPath: /tmp/node-exporter.sh

View File

@ -89,7 +89,7 @@ spec:
mountPath: /tmp
- name: proc
mountPath: /host/proc
readOnly: true
readOnly: true
volumes:
- name: pod-tmp
emptyDir: {}

View File

@ -25,6 +25,6 @@ data:
{{ range $key, $value := .Values.conf.prometheus.rules }}
{{ $key }}.rules: {{ toYaml $value | b64enc }}
{{ end }}
#NOTE(srwilkers): this must be last, to work round helm ~2.7 bug.
# NOTE(srwilkers): this must be last, to work round helm ~2.7 bug.
{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.httpd "key" "httpd.conf" "format" "Secret") | indent 2 }}
{{- end }}

View File

@ -25,14 +25,14 @@ limitations under the License.
{{- if regexMatch "^[0-9]*m$" $val -}}
{{- $val = div (float64 (trimSuffix "m" $val)) 1000 -}}
{{- end -}}
{{/* NOTE(aostapenko) String with floating number does not convert well to int*/}}
{{/* NOTE(aostapenko) String with floating number does not convert well to int */}}
{{- $val | float64 | int | default 1 -}}
{{- end -}}
{{- if .Values.manifests.statefulset }}
{{- $envAll := . }}
{{- $rcControllerName := printf "%s-%s" $envAll.Release.Name "rabbitmq" }}
{{- $rcControllerName := printf "%s-%s" $envAll.Release.Name "rabbitmq" }}
{{ tuple $envAll "rabbitmq" $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
---
apiVersion: rbac.authorization.k8s.io/v1
@ -277,7 +277,7 @@ spec:
- metadata:
name: rabbitmq-data
spec:
accessModes: [ "ReadWriteOnce" ]
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ $envAll.Values.volume.size }}

View File

@ -20,7 +20,7 @@ apiVersion: v1
metadata:
name: docker-images
spec:
accessModes: [ "ReadWriteOnce" ]
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.volume.size }}

View File

@ -7,10 +7,10 @@ HELM_VERSION=$(yq -r '.version.helm' ${HELM_DATA_YAML})
GOOGLE_HELM_REPO_URL=$(yq -r '.url.google_helm_repo' ${HELM_DATA_YAML})
LINT_DIR=.yamllint
rm -rf */charts/helm-toolkit
mkdir ${LINT_DIR}
cp -r * ${LINT_DIR}
rm -rf ${LINT_DIR}/*/templates
rm -rf */charts/helm-toolkit
wget -qO ${LINT_DIR}/helm.tgz ${GOOGLE_HELM_REPO_URL}/helm-${HELM_VERSION}-linux-amd64.tar.gz
tar xzf ${LINT_DIR}/helm.tgz -C ${LINT_DIR} --strip-components=1 linux-amd64/helm

View File

@ -6,44 +6,27 @@ yaml-files:
- '.yamllint'
rules:
braces:
level: warning
brackets:
level: warning
colons:
level: warning
commas:
level: warning
comments:
level: warning
comments-indentation:
level: warning
braces: enable
brackets: enable
colons: enable
commas: enable
comments: enable
comments-indentation: enable
document-end: disable
document-start:
level: warning
empty-lines:
level: warning
empty-values:
level: warning
hyphens:
level: warning
document-start: enable
empty-lines: disable
empty-values: disable
hyphens: enable
indentation:
spaces: 2
indent-sequences: whatever
level: warning
key-duplicates:
level: warning
key-duplicates: disable
key-ordering: disable
line-length: disable
new-line-at-end-of-file:
level: warning
new-lines:
level: warning
octal-values:
level: warning
new-line-at-end-of-file: disable
new-lines: disable
octal-values: disable
quoted-strings: disable
trailing-spaces:
level: warning
truthy:
level: warning
trailing-spaces: disable
truthy: disable
...