Merge pull request #8143 from tanjunchen/fix-shell-sh001

/hack: improve shell script  in hack
This commit is contained in:
Kubernetes Prow Robot 2019-12-27 18:41:39 -08:00 committed by GitHub
commit e7ad6a9601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 27 additions and 10 deletions

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors. # Copyright 2017 The Kubernetes Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,3 +1,5 @@
#!/bin/sh -eu
# Copyright 2017 The Kubernetes Authors. # Copyright 2017 The Kubernetes Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -12,5 +14,4 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
#!/bin/sh -eu
make ci make ci

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2019 The Kubernetes Authors. # Copyright 2019 The Kubernetes Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2019 The Kubernetes Authors. # Copyright 2019 The Kubernetes Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2019 The Kubernetes Authors. # Copyright 2019 The Kubernetes Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -23,7 +24,7 @@ export API_OPTIONS="--verify-only"
if make apimachinery-codegen; then if make apimachinery-codegen; then
echo "apimachinery is up to date" echo "apimachinery is up to date"
else else
echo "\n FAIL: - the verify-apimachinery.sh test failed, apimachinery is not up to date" echo -e "\n FAIL: - the verify-apimachinery.sh test failed, apimachinery is not up to date"
echo "\n FAIL: - please run the command 'make apimachinery'" echo -e "\n FAIL: - please run the command 'make apimachinery'"
exit 1 exit 1
fi fi

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2019 The Kubernetes Authors. # Copyright 2019 The Kubernetes Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -26,7 +27,7 @@ changed_files=$(git status --porcelain || true)
if [ -n "${changed_files}" ]; then if [ -n "${changed_files}" ]; then
echo "Detected that generation is needed; run 'make crds'" echo "Detected that generation is needed; run 'make crds'"
echo "changed files:" echo "changed files:"
printf "${changed_files}\n" printf "%s" "${changed_files}\n"
echo "git diff:" echo "git diff:"
git --no-pager diff git --no-pager diff
echo "To fix: run 'make crds'" echo "To fix: run 'make crds'"

View File

@ -25,7 +25,7 @@ changes=$(git status --porcelain || true)
if [ -n "${changes}" ]; then if [ -n "${changes}" ]; then
echo "ERROR: go modules are not up to date; please run: go mod tidy" echo "ERROR: go modules are not up to date; please run: go mod tidy"
echo "changed files:" echo "changed files:"
printf "${changes}\n" printf "%s" "${changes}\n"
echo "git diff:" echo "git diff:"
git --no-pager diff git --no-pager diff
exit 1 exit 1

View File

@ -1,3 +1,5 @@
#!/usr/bin/env bash
# Copyright 2019 The Kubernetes Authors. # Copyright 2019 The Kubernetes Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -12,17 +14,21 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
#!/bin/bash set -o errexit
set -o nounset
set -e set -o pipefail
REPO_ROOT=$(git rev-parse --show-toplevel) REPO_ROOT=$(git rev-parse --show-toplevel)
cd "${REPO_ROOT}" cd "${REPO_ROOT}"
OUTPUT_GOBIN="${REPO_ROOT}/_output/bin" OUTPUT_GOBIN="${REPO_ROOT}/_output/bin"
# Install tools we need, but from vendor/
GOBIN="${OUTPUT_GOBIN}" go install ./vendor/github.com/client9/misspell/cmd/misspell GOBIN="${OUTPUT_GOBIN}" go install ./vendor/github.com/client9/misspell/cmd/misspell
mkdir -p .build/docs mkdir -p .build/docs
# Spell checking
find . -type f \( -name "*.go*" -o -name "*.md*" \) -a -path "./docs/releases/*" -exec basename {} \; | \ find . -type f \( -name "*.go*" -o -name "*.md*" \) -a -path "./docs/releases/*" -exec basename {} \; | \
xargs -I{} sh -c 'sed -e "/^\* .*github.com\/kubernetes\/kops\/pull/d" docs/releases/{} > .build/docs/$(basename {})' xargs -I{} sh -c 'sed -e "/^\* .*github.com\/kubernetes\/kops\/pull/d" docs/releases/{} > .build/docs/$(basename {})'
find . -type f \( -name "*.go*" -o -name "*.md*" \) -a \( -not -path "./vendor/*" -not -path "./docs/releases/*" \) | \ find . -type f \( -name "*.go*" -o -name "*.md*" \) -a \( -not -path "./vendor/*" -not -path "./docs/releases/*" \) | \

View File

@ -31,6 +31,7 @@ kube::util::array_contains() {
done done
return 1 return 1
} }
function kube::util::read-array { function kube::util::read-array {
local i=0 local i=0
unset -v "$1" unset -v "$1"
@ -39,7 +40,10 @@ function kube::util::read-array {
} }
FOCUS="${1:-}" FOCUS="${1:-}"
FOCUS="${FOCUS%/}" # Remove the ending "/"
# Remove the ending "/"
FOCUS="${FOCUS%/}"
# See https://staticcheck.io/docs/checks # See https://staticcheck.io/docs/checks
CHECKS=( CHECKS=(
@ -50,7 +54,8 @@ CHECKS=(
export IFS=','; checks="${CHECKS[*]}"; unset IFS export IFS=','; checks="${CHECKS[*]}"; unset IFS
# Packages to ignore due to bugs in staticcheck # Packages to ignore due to bugs in staticcheck
# NOTE: To ignore issues detected a package, add it to the .staticcheck_failures blacklist # NOTE: To ignore issues detected a package,
# add it to the .staticcheck_failures blacklist
IGNORE=( IGNORE=(
) )
export IFS='|'; ignore_pattern="^(${IGNORE[*]})\$"; unset IFS export IFS='|'; ignore_pattern="^(${IGNORE[*]})\$"; unset IFS