From 67ba702d686213040f297916b28f8ec6fbf4cc88 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Thu, 24 Sep 2020 13:02:11 +0200 Subject: [PATCH] Add Helm Chart linting (#11108) (cherry picked from commit 620b0989b8a5681b0a95478fd23917b2eff8daa6) --- .pre-commit-config.yaml | 7 +++++ BREEZE.rst | 10 +++---- STATIC_CODE_CHECKS.rst | 2 ++ breeze-complete | 3 +- scripts/ci/pre_commit/pre_commit_helm_lint.sh | 24 ++++++++++++++++ scripts/ci/static_checks/helm_lint.sh | 28 +++++++++++++++++++ 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100755 scripts/ci/pre_commit/pre_commit_helm_lint.sh create mode 100755 scripts/ci/static_checks/helm_lint.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e61a423ebf08a..4e7cc4df68ddf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -339,3 +339,10 @@ repos: language: system files: ^.pre-commit-config.yaml$|^INTHEWILD.md$ require_serial: true + - id: helm-lint + name: Lint Helm Chart + entry: ./scripts/ci/pre_commit/pre_commit_helm_lint.sh + language: system + pass_filenames: false + files: ^chart + require_serial: true diff --git a/BREEZE.rst b/BREEZE.rst index 404d61bb58c4e..728d590e7879f 100644 --- a/BREEZE.rst +++ b/BREEZE.rst @@ -1689,11 +1689,11 @@ This is the current syntax for `./breeze <./breeze>`_: check-builtin-literals check-executables-have-shebangs check-hooks-apply check-integrations check-merge-conflict check-xml debug-statements detect-private-key doctoc dont-use-safe-filter end-of-file-fixer fix-encoding-pragma - flake8 forbid-tabs insert-license incorrect-use-of-LoggingMixin language-matters - lint-dockerfile lint-openapi mixed-line-ending mypy pre-commit-descriptions pydevd - python2-compile python2-fastcheck python-no-log-warn rst-backticks setup-order - shellcheck sort-in-the-wild trailing-whitespace update-breeze-file update-extras - update-local-yml-file yamllint + flake8 forbid-tabs helm-lint incorrect-use-of-LoggingMixin insert-license + language-matters lint-dockerfile lint-openapi mixed-line-ending mypy + pre-commit-descriptions pydevd python2-compile python2-fastcheck python-no-log-warn + rst-backticks setup-order shellcheck sort-in-the-wild trailing-whitespace + update-breeze-file update-extras update-local-yml-file yamllint You can pass extra arguments including options to to the pre-commit framework as passed after --. For example: diff --git a/STATIC_CODE_CHECKS.rst b/STATIC_CODE_CHECKS.rst index 513c239ae9eb6..a8ce69a99631c 100644 --- a/STATIC_CODE_CHECKS.rst +++ b/STATIC_CODE_CHECKS.rst @@ -86,6 +86,8 @@ require Breeze Docker images to be installed locally: ----------------------------------- ---------------------------------------------------------------- ------------ ``forbid-tabs`` Fails if tabs are used in the project. ----------------------------------- ---------------------------------------------------------------- ------------ +``helm-lint`` Verifies if helm lint passes for the chart +----------------------------------- ---------------------------------------------------------------- ------------ ``incorrect-use-of-LoggingMixin`` Checks if LoggingMixin is properly imported. ----------------------------------- ---------------------------------------------------------------- ------------ ``insert-license`` Adds licenses for most file types. diff --git a/breeze-complete b/breeze-complete index ae42a40cbb4c0..e8b281ad895be 100644 --- a/breeze-complete +++ b/breeze-complete @@ -85,8 +85,9 @@ end-of-file-fixer fix-encoding-pragma flake8 forbid-tabs -insert-license +helm-lint incorrect-use-of-LoggingMixin +insert-license language-matters lint-dockerfile lint-openapi diff --git a/scripts/ci/pre_commit/pre_commit_helm_lint.sh b/scripts/ci/pre_commit/pre_commit_helm_lint.sh new file mode 100755 index 0000000000000..56a57f3555d95 --- /dev/null +++ b/scripts/ci/pre_commit/pre_commit_helm_lint.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +export REMEMBER_LAST_ANSWER="true" +export PRINT_INFO_FROM_SCRIPTS="false" +export SKIP_CHECK_REMOTE_IMAGE="true" + + +# shellcheck source=scripts/ci/static_checks/lint_dockerfile.sh +. "$( dirname "${BASH_SOURCE[0]}" )/../static_checks/helm_lint.sh" "${@}" diff --git a/scripts/ci/static_checks/helm_lint.sh b/scripts/ci/static_checks/helm_lint.sh new file mode 100755 index 0000000000000..37ec2180a00e3 --- /dev/null +++ b/scripts/ci/static_checks/helm_lint.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# shellcheck source=scripts/ci/libraries/_script_init.sh +. "$( dirname "${BASH_SOURCE[0]}" )/../libraries/_script_init.sh" + +function run_helm_lint() { + kind::make_sure_kubernetes_tools_are_installed + + cd "${AIRFLOW_SOURCES}/chart" || exit 1 + helm lint . -f values.yaml +} + +run_helm_lint