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

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

@ -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

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

@ -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,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

@ -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

@ -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

@ -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,7 +25,7 @@ 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 -}}
@ -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
...