Enable templates linting

- braces
- brackets
- colons
- commas
- comments
- hyphens
- indentation
- key-duplicates

with corresponding code changes.

Also disable enforcement for document-(start|end) rules and
disables warnings to increase readability.

* Unrestrict octal values rule since benefits of file modes readability
  exceed possible issues with yaml 1.2 adoption in future k8s versions.
  These issues will be addressed when/if they occur.

Change-Id: Ic5e327cf40c4b09c90738baff56419a6cef132da
Signed-off-by: Andrii Ostapenko <andrii.ostapenko@att.com>
This commit is contained in:
Andrii Ostapenko 2020-07-06 14:19:39 -05:00 committed by Andrii Ostapenko
parent 0807ecb354
commit 44d263b2bf
21 changed files with 74 additions and 48 deletions

View File

@ -38,7 +38,7 @@ spec:
{{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }} {{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }}
restartPolicy: Never restartPolicy: Never
initContainers: initContainers:
{{ tuple $envAll "tests" $mounts_barbican_tests_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} {{ tuple $envAll "tests" $mounts_barbican_tests_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }}
containers: containers:
- name: barbican-test - name: barbican-test
{{ tuple $envAll "scripted_test" | include "helm-toolkit.snippets.image" | indent 6 }} {{ tuple $envAll "scripted_test" | include "helm-toolkit.snippets.image" | indent 6 }}

View File

@ -96,7 +96,6 @@ spec:
mountPath: {{ ( split "://" .Values.conf.cinder.coordination.backend_url )._1 }} mountPath: {{ ( split "://" .Values.conf.cinder.coordination.backend_url )._1 }}
{{ end }} {{ end }}
- name: init-cinder-conf - name: init-cinder-conf
{{ tuple $envAll "cinder_volume" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ dict "envAll" $envAll "application" "cinder_volume" "container" "init_cinder_conf" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} {{ dict "envAll" $envAll "application" "cinder_volume" "container" "init_cinder_conf" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
image: {{ .Values.images.tags.ks_user }} image: {{ .Values.images.tags.ks_user }}
imagePullPolicy: {{ .Values.images.pull_policy }} imagePullPolicy: {{ .Values.images.pull_policy }}

View File

@ -32,9 +32,9 @@ metadata:
name: {{ $envAll.Values.secrets.identity.heat_stack_user }} name: {{ $envAll.Values.secrets.identity.heat_stack_user }}
type: Opaque type: Opaque
data: data:
OS_AUTH_URL: {{ tuple "identity" "internal" "api" $envAll | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | b64enc | indent 4 }} OS_AUTH_URL: {{ tuple "identity" "internal" "api" $envAll | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | b64enc }}
OS_REGION_NAME: {{ .Values.endpoints.identity.auth.heat_stack_user.region_name | b64enc | indent 4 }} OS_REGION_NAME: {{ .Values.endpoints.identity.auth.heat_stack_user.region_name | b64enc }}
OS_DOMAIN_NAME: {{ .Values.endpoints.identity.auth.heat_stack_user.domain_name | b64enc | indent 4 }} OS_DOMAIN_NAME: {{ .Values.endpoints.identity.auth.heat_stack_user.domain_name | b64enc }}
OS_USERNAME: {{ .Values.endpoints.identity.auth.heat_stack_user.username | b64enc | indent 4 }} OS_USERNAME: {{ .Values.endpoints.identity.auth.heat_stack_user.username | b64enc }}
OS_PASSWORD: {{ .Values.endpoints.identity.auth.heat_stack_user.password | b64enc | indent 4 }} OS_PASSWORD: {{ .Values.endpoints.identity.auth.heat_stack_user.password | b64enc }}
{{- end }} {{- end }}

View File

@ -32,9 +32,9 @@ metadata:
name: {{ $envAll.Values.secrets.identity.magnum_stack_user }} name: {{ $envAll.Values.secrets.identity.magnum_stack_user }}
type: Opaque type: Opaque
data: data:
OS_AUTH_URL: {{ tuple "identity" "internal" "api" $envAll | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | b64enc | indent 4 }} OS_AUTH_URL: {{ tuple "identity" "internal" "api" $envAll | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | b64enc }}
OS_REGION_NAME: {{ .Values.endpoints.identity.auth.magnum_stack_user.region_name | b64enc | indent 4 }} OS_REGION_NAME: {{ .Values.endpoints.identity.auth.magnum_stack_user.region_name | b64enc }}
OS_DOMAIN_NAME: {{ .Values.endpoints.identity.auth.magnum_stack_user.domain_name | b64enc | indent 4 }} OS_DOMAIN_NAME: {{ .Values.endpoints.identity.auth.magnum_stack_user.domain_name | b64enc }}
OS_USERNAME: {{ .Values.endpoints.identity.auth.magnum_stack_user.username | b64enc | indent 4 }} OS_USERNAME: {{ .Values.endpoints.identity.auth.magnum_stack_user.username | b64enc }}
OS_PASSWORD: {{ .Values.endpoints.identity.auth.magnum_stack_user.password | b64enc | indent 4 }} OS_PASSWORD: {{ .Values.endpoints.identity.auth.magnum_stack_user.password | b64enc }}
{{- end }} {{- end }}

View File

@ -26,11 +26,10 @@ kind: Pod
metadata: metadata:
name: {{ print $envAll.Release.Name "-test" }} name: {{ print $envAll.Release.Name "-test" }}
annotations: annotations:
"helm.sh/hook": test-success
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
labels: labels:
{{ tuple $envAll "neutron" "test" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ tuple $envAll "neutron" "test" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
"helm.sh/hook": test-success
{{ dict "envAll" $envAll "podName" "neutron-test" "containerNames" (list "init" "neutron-test" "neutron-test-ks-user") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 4 }} {{ dict "envAll" $envAll "podName" "neutron-test" "containerNames" (list "init" "neutron-test" "neutron-test-ks-user") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 4 }}
spec: spec:
nodeSelector: nodeSelector:

View File

@ -88,7 +88,7 @@ spec:
{{ dict "envAll" $envAll "application" "nova" "container" "nova_compute_init" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} {{ dict "envAll" $envAll "application" "nova" "container" "nova_compute_init" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
env: env:
- name: NOVA_USER_UID - name: NOVA_USER_UID
value: "{{ .Values.pod.user.nova.uid }}" value: "{{ .Values.pod.security_context.nova.pod.runAsUser }}"
command: command:
- /tmp/nova-compute-init.sh - /tmp/nova-compute-init.sh
terminationMessagePath: /var/log/termination-log terminationMessagePath: /var/log/termination-log

View File

@ -2335,9 +2335,6 @@ pod:
enabled: True enabled: True
params: params:
initialDelaySeconds: 30 initialDelaySeconds: 30
user:
nova:
uid: 42424
security_context: security_context:
nova: nova:
pod: pod:

View File

@ -24,5 +24,4 @@ images:
nova_spiceproxy: "docker.io/openstackhelm/nova:rocky-opensuse_15" nova_spiceproxy: "docker.io/openstackhelm/nova:rocky-opensuse_15"
nova_spiceproxy_assets: "docker.io/openstackhelm/nova:rocky-opensuse_15" nova_spiceproxy_assets: "docker.io/openstackhelm/nova:rocky-opensuse_15"
nova_service_cleaner: "docker.io/openstackhelm/ceph-config-helper:latest-opensuse_15" nova_service_cleaner: "docker.io/openstackhelm/ceph-config-helper:latest-opensuse_15"
... ...

View File

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

15
tox.ini
View File

@ -22,12 +22,15 @@ whitelist_externals =
rm rm
[testenv:lint] [testenv:lint]
deps = yamllint deps =
yq
yamllint
commands = commands =
bash -c "rm -rf {toxinidir}/.yamllint" rm -rf .yamllint
bash -c "mkdir -p {toxinidir}/.yamllint" bash -c 'if [ ! -d ../openstack-helm-infra ]; then\
bash -c "cp -r $(ls {toxinidir}) {toxinidir}/.yamllint/" git clone https://opendev.org/openstack/openstack-helm-infra ../openstack-helm-infra;\
bash -c "find {toxinidir}/.yamllint -type f -exec sed -i 's/%%%.*/XXX/g' \{\} +" fi'
bash -c "yamllint -c {toxinidir}/yamllint.conf {toxinidir}/.yamllint/*/values* {toxinidir}/yamllint.conf" bash ../openstack-helm-infra/tools/gate/lint.sh
whitelist_externals = whitelist_externals =
rm
bash bash

32
yamllint-templates.conf Normal file
View File

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

View File

@ -11,13 +11,11 @@ rules:
colons: enable colons: enable
commas: enable commas: enable
comments: enable comments: enable
comments-indentation: comments-indentation: disable
level: warning document-end: disable
document-end: enable document-start: disable
document-start: enable
empty-lines: enable empty-lines: enable
empty-values: empty-values: disable
level: warning
hyphens: enable hyphens: enable
indentation: indentation:
spaces: 2 spaces: 2
@ -27,9 +25,8 @@ rules:
line-length: disable line-length: disable
new-line-at-end-of-file: enable new-line-at-end-of-file: enable
new-lines: enable new-lines: enable
octal-values: enable octal-values: disable
quoted-strings: disable quoted-strings: disable
trailing-spaces: enable trailing-spaces: enable
truthy: truthy: disable
level: warning
... ...