File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -283,4 +283,13 @@ lint-staticcheck:
283
283
lint-golangci-lint :
284
284
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0 run
285
285
286
- lint : lint-staticcheck lint-golangci-lint
286
+ lint-shellcheck :
287
+ docker run \
288
+ --rm \
289
+ -v ` pwd` :` pwd` \
290
+ -w ` pwd` \
291
+ docker.io/koalaman/shellcheck-alpine:v0.9.0 \
292
+ shellcheck \
293
+ $$(git ls-files ':!:vendor' '*.sh' )
294
+
295
+ lint : lint-staticcheck lint-golangci-lint lint-shellcheck
Original file line number Diff line number Diff line change 1
- #! /bin/sh
1
+ #! /bin/bash
2
2
#
3
3
# Copyright 2019 The Kubernetes Authors.
4
4
#
@@ -20,15 +20,15 @@ set -o errexit
20
20
set -o nounset
21
21
22
22
# Ask pass some ops, fail if it mismatched the magic password.
23
- if [ " $1 " = " clone" -o " $1 " = " ls-remote" -o " $1 " = " fetch" ]; then
23
+ if [[ " $1 " == " clone" || " $1 " == " ls-remote" || " $1 " = " fetch" ] ]; then
24
24
# `git credential fill` requires the repo url match to consume the credentials stored by git-sync.
25
25
# Askpass git only support repo started with "file://" which is used in test_e2e.sh.
26
26
REPO=$( echo " $@ " | grep -o " file://[^ ]*" )
27
27
OUTPUT=$( echo " url=${REPO} " | git credential fill)
28
28
USERNAME=$( echo " ${OUTPUT} " | grep " ^username=.*" )
29
29
PASSWD=$( echo " ${OUTPUT} " | grep " ^password=.*" )
30
30
# Test case must match the magic username and password below.
31
- if [ " ${USERNAME} " != " username=my-username" -o " ${PASSWD} " != " password=my-password" ]; then
31
+ if [[ " ${USERNAME} " != " username=my-username" || " ${PASSWD} " != " password=my-password" ] ]; then
32
32
echo " invalid test username/password pair: ${USERNAME} :${PASSWD} "
33
33
exit 1
34
34
fi
Original file line number Diff line number Diff line change 14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
17
-
18
- if [ -z " $1 " -o -z " $2 " ]; then
17
+ if [ -z " $1 " ] || [ -z " $2 " ]; then
19
18
echo " usage: $0 <port> <shell-command>"
20
19
exit 1
21
20
fi
22
21
23
- F=" /tmp/fifo.$RANDOM "
24
-
22
+ # This construction allows the passed-in command ($2) to optionally read from
23
+ # the client before responding (e.g. an HTTP request).
24
+ CMD_TO_NC=$( mktemp -u)
25
+ NC_TO_CMD=$( mktemp -u)
26
+ mkfifo " $CMD_TO_NC " " $NC_TO_CMD "
25
27
while true ; do
26
- rm -f " $F "
27
- mkfifo " $F "
28
- cat " $F " | sh -c " $2 " 2>&1 | nc -l -p " $1 " -N -w1 > " $F "
28
+ sh -c " $2 " > " $CMD_TO_NC " 2>&1 < " $NC_TO_CMD " &
29
+ nc -l -p " $1 " -N -w1 < " $CMD_TO_NC " > " $NC_TO_CMD "
29
30
date >> /var/log/hits
30
31
done
You can’t perform that action at this time.
0 commit comments