This repository was archived by the owner on Sep 24, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +90
-0
lines changed Expand file tree Collapse file tree 4 files changed +90
-0
lines changed Original file line number Diff line number Diff line change @@ -23,3 +23,4 @@ REPO_PATH=$(get_root_path)
23
23
24
24
" ${REPO_PATH} " /hack/update-deps.sh
25
25
" ${REPO_PATH} " /hack/update-gofmt.sh
26
+ " ${REPO_PATH} " /hack/update-goimports.sh
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # Copyright 2019 The Kubernetes Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # script to run gofmt over our code (not vendor)
17
+ set -o errexit
18
+ set -o nounset
19
+ set -o pipefail
20
+
21
+ # shellcheck source=/dev/null
22
+ source " $( dirname " $0 " ) /utils.sh"
23
+ # cd to the root path
24
+ cd_root_path
25
+
26
+ # update go imports
27
+ goimports -w ./
Original file line number Diff line number Diff line change @@ -53,6 +53,12 @@ if [[ "${VERIFY_GOFMT:-true}" == "true" ]]; then
53
53
cd " ${REPO_PATH} "
54
54
fi
55
55
56
+ if [[ " ${VERIFY_GOIMPORTS:- true} " == " true" ]]; then
57
+ echo " [*] Verifying goimports..."
58
+ hack/verify-goimports.sh || res=1
59
+ cd " ${REPO_PATH} "
60
+ fi
61
+
56
62
if [[ " ${VERIFY_GOLINT:- true} " == " true" ]]; then
57
63
echo " [*] Verifying golint..."
58
64
hack/verify-golint.sh || res=1
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # Copyright 2019 The Kubernetes Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ set -o errexit
17
+ set -o nounset
18
+ set -o pipefail
19
+
20
+ # shellcheck source=/dev/null
21
+ source " $( dirname " $0 " ) /utils.sh"
22
+ # cd to the root path
23
+ cd_root_path
24
+
25
+ # create a temporary directory
26
+ TMP_DIR=$( mktemp -d)
27
+
28
+ # cleanup
29
+ exitHandler () (
30
+ echo " Cleaning up..."
31
+ rm -rf " ${TMP_DIR} "
32
+ )
33
+ trap exitHandler EXIT
34
+
35
+ # pull goimports
36
+ export GO111MODULE=on
37
+ URL=" https://github.com/golang/tools.git"
38
+ git clone --quiet --depth=1 " ${URL} " " ${TMP_DIR} "
39
+ pushd " ${TMP_DIR} " > /dev/null
40
+ popd > /dev/null
41
+
42
+ # build goimports
43
+ BIN_PATH=" ${TMP_DIR} /cmd/goimports"
44
+ pushd " ${BIN_PATH} " > /dev/null
45
+ echo " Building goimports..."
46
+ go build > /dev/null
47
+ popd > /dev/null
48
+
49
+ # check for goimports diffs
50
+ diff=$( git ls-files | grep " \.go" | grep -v " \/vendor" | xargs " ${BIN_PATH} /goimports" -d 2>&1 )
51
+ if [[ -n " ${diff} " ]]; then
52
+ echo " ${diff} "
53
+ echo
54
+ echo " Check failed. Please run hack/update-goimports.sh"
55
+ exit 1
56
+ fi
You can’t perform that action at this time.
0 commit comments