From 815deeaa2ed087ec41a368b6b9dd1a69d5a973e8 Mon Sep 17 00:00:00 2001 From: Andrii Ostapenko Date: Mon, 6 Jul 2020 14:41:10 -0500 Subject: [PATCH] Enable templates linting - braces - brackets - colons - commas - comments - hyphens - indentation - key-duplicates with corresponding code changes. Also disable document-(start|end) rule. * 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. Depends-On: https://review.opendev.org/739600 Change-Id: Ide884ed541898db2ba21a863aff0cea9ec3f75dd Signed-off-by: Andrii Ostapenko --- artifactory/templates/statefulset.yaml | 2 +- ranger-agent/Chart.yaml | 1 - sonobuoy/templates/configmap-plugins.yaml | 2 +- .../gate/playbooks/osh-infra-deploy-k8s.yaml | 2 +- tools/gate/playbooks/zuul-linter.yaml | 2 +- tox.ini | 11 +++++-- yamllint-templates.conf | 32 +++++++++++++++++++ yamllint.conf | 15 ++++----- zuul.d/jobs.yaml | 2 +- 9 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 yamllint-templates.conf diff --git a/artifactory/templates/statefulset.yaml b/artifactory/templates/statefulset.yaml index 47b3f767..f9a258b1 100644 --- a/artifactory/templates/statefulset.yaml +++ b/artifactory/templates/statefulset.yaml @@ -80,7 +80,7 @@ spec: - metadata: name: artifactory-data spec: - accessModes: [ "ReadWriteOnce" ] + accessModes: ["ReadWriteOnce"] resources: requests: storage: {{ .Values.storage.requests.storage }} diff --git a/ranger-agent/Chart.yaml b/ranger-agent/Chart.yaml index 64843a1c..c34bf958 100644 --- a/ranger-agent/Chart.yaml +++ b/ranger-agent/Chart.yaml @@ -19,4 +19,3 @@ sources: - https://opendev.org/openstack/openstack-helm maintainers: - name: OpenStack-Helm Authors - diff --git a/sonobuoy/templates/configmap-plugins.yaml b/sonobuoy/templates/configmap-plugins.yaml index 8df57cbf..4bfb0e52 100644 --- a/sonobuoy/templates/configmap-plugins.yaml +++ b/sonobuoy/templates/configmap-plugins.yaml @@ -21,6 +21,6 @@ metadata: name: sonobuoy-plugins data: {{ range .Values.conf.plugins }} -{{- include "helm-toolkit.snippets.values_template_renderer" ( dict "envAll" $envAll "template" .data "key" .name ) | indent 4 }} +{{- include "helm-toolkit.snippets.values_template_renderer" ( dict "envAll" $envAll "template" .data "key" .name ) | indent 2 }} {{ end }} {{- end }} diff --git a/tools/gate/playbooks/osh-infra-deploy-k8s.yaml b/tools/gate/playbooks/osh-infra-deploy-k8s.yaml index 9e16fa3a..9f56e28d 100644 --- a/tools/gate/playbooks/osh-infra-deploy-k8s.yaml +++ b/tools/gate/playbooks/osh-infra-deploy-k8s.yaml @@ -31,4 +31,4 @@ roles: - deploy-kubeadm-aio-node tags: - - deploy-kubeadm-aio-node \ No newline at end of file + - deploy-kubeadm-aio-node diff --git a/tools/gate/playbooks/zuul-linter.yaml b/tools/gate/playbooks/zuul-linter.yaml index d963a2b1..3e9f0710 100644 --- a/tools/gate/playbooks/zuul-linter.yaml +++ b/tools/gate/playbooks/zuul-linter.yaml @@ -15,4 +15,4 @@ - name: Execute a Whitespace Linter check command: find . -not -path "*/\.*" -not -path "*/doc/build/*" -not -name "*.tgz" -type f -exec egrep -l " +$" {} \; register: result - failed_when: result.stdout != "" \ No newline at end of file + failed_when: result.stdout != "" diff --git a/tox.ini b/tox.ini index c7b9e0c8..d2f6b11d 100644 --- a/tox.ini +++ b/tox.ini @@ -14,8 +14,15 @@ passenv = *_proxy *_PROXY commands = {posargs} [testenv:lint] -deps = yamllint +deps = + yq + yamllint commands = - bash -c "yamllint -c {toxinidir}/yamllint.conf */values* yamllint.conf" + rm -rf .yamllint + bash -c 'if [ ! -d ../openstack-helm-infra ]; then\ + git clone https://opendev.org/openstack/openstack-helm-infra ../openstack-helm-infra;\ + fi' + bash ../openstack-helm-infra/tools/gate/lint.sh whitelist_externals = + rm bash diff --git a/yamllint-templates.conf b/yamllint-templates.conf new file mode 100644 index 00000000..d833c5b0 --- /dev/null +++ b/yamllint-templates.conf @@ -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 +... diff --git a/yamllint.conf b/yamllint.conf index 8c80f8e7..b5c21923 100644 --- a/yamllint.conf +++ b/yamllint.conf @@ -12,13 +12,11 @@ rules: commas: enable comments: enable comments-indentation: enable - document-end: enable - document-start: enable + document-end: disable + document-start: disable empty-lines: enable - empty-values: - level: warning - hyphens: - level: warning + empty-values: disable + hyphens: enable indentation: spaces: 2 indent-sequences: whatever @@ -27,9 +25,8 @@ rules: line-length: disable new-line-at-end-of-file: enable new-lines: enable - octal-values: enable + octal-values: disable quoted-strings: disable trailing-spaces: enable - truthy: - level: warning + truthy: disable ... diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 869b5adf..3340e10b 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -158,4 +158,4 @@ - ./tools/deployment/common/install-packages.sh - ./tools/deployment/common/deploy-k8s.sh - ./tools/deployment/common/setup-client.sh - - ./tools/deployment/component/mini-mirror/mini-mirror.sh \ No newline at end of file + - ./tools/deployment/component/mini-mirror/mini-mirror.sh