Skip to content

Commit

Permalink
Add Dockerfile linter
Browse files Browse the repository at this point in the history
  • Loading branch information
oscr committed Jul 10, 2022
1 parent 29495a2 commit 5277aa6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ lint: $(GOLANGCI_LINT) ## Lint the codebase
$(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
cd $(TEST_DIR); $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
cd $(TOOLS_DIR); $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
./scripts/ci-lint-dockerfiles.sh

.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter
Expand Down
26 changes: 26 additions & 0 deletions scripts/ci-lint-dockerfiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Copyright 2022 The Kubernetes Authors.
#
# Licensed 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.

set -o errexit
set -o nounset
set -o pipefail

FILES=$(find -- * -name Dockerfile)
while read -r file; do
echo "Linting: ${file}"
# Configure the linter to only fail for errors. Can be set to: error | warning | info | style | ignore | none
docker run --rm -i ghcr.io/hadolint/hadolint:v2.10.0 hadolint --failure-threshold error - < "${file}"
done <<< "${FILES}"

0 comments on commit 5277aa6

Please sign in to comment.