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:
283283lint-golangci-lint :
284284 go run github.com/golangci/golangci-lint/cmd/
[email protected] run
285285
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
22#
33# Copyright 2019 The Kubernetes Authors.
44#
@@ -20,15 +20,15 @@ set -o errexit
2020set -o nounset
2121
2222# 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
2424 # `git credential fill` requires the repo url match to consume the credentials stored by git-sync.
2525 # Askpass git only support repo started with "file://" which is used in test_e2e.sh.
2626 REPO=$( echo " $@ " | grep -o " file://[^ ]*" )
2727 OUTPUT=$( echo " url=${REPO} " | git credential fill)
2828 USERNAME=$( echo " ${OUTPUT} " | grep " ^username=.*" )
2929 PASSWD=$( echo " ${OUTPUT} " | grep " ^password=.*" )
3030 # 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
3232 echo " invalid test username/password pair: ${USERNAME} :${PASSWD} "
3333 exit 1
3434 fi
Original file line number Diff line number Diff line change 1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17-
18- if [ -z " $1 " -o -z " $2 " ]; then
17+ if [ -z " $1 " ] || [ -z " $2 " ]; then
1918 echo " usage: $0 <port> <shell-command>"
2019 exit 1
2120fi
2221
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 "
2527while 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 "
2930 date >> /var/log/hits
3031done
You can’t perform that action at this time.
0 commit comments