Skip to content

Commit

Permalink
[ FAB-7448 ] check_format trailing blanks
Browse files Browse the repository at this point in the history
Frequently scripts are inadvertently checked in with trailing blanks,
causing a constant trickle of patches unrelated to anything.
The check_format script will alert of trailing blanks,
and propose a one-liner to fix any problems found.

Change-Id: If29e5f6b1741925f78153bf0a8b5824540cd8fcd
Signed-off-by: Allen Bailey <eabailey@us.ibm.com>
  • Loading branch information
rennman committed Dec 13, 2017
1 parent f5af79b commit b57c216
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion images/fabric-ca-fvt/payload/slapd_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ slapd slapd/password2 password $LDAPPASWD\n\
slapd slapd/internal/adminpw password $LDAPPASWD\n\
slapd slapd/password1 password $LDAPPASWD\n\
slapd slapd/domain string example.com\n\
slapd shared/organization string example.com" | debconf-set-selections
slapd shared/organization string example.com" | debconf-set-selections
apt-get -y update
apt-get -y install --no-install-recommends slapd ldap-utils
adduser openldap ssl-cert
Expand Down
4 changes: 2 additions & 2 deletions images/fabric-ca-fvt/payload/tls_pki.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ five_year=$(date +"$five%m%d%H%M%SZ")
two_year=$(date +"$two%m%d%H%M%SZ")

KeyType="$1"
case ${KeyType:=rsa} in
ec) CaKeyLength=521
case ${KeyType:=rsa} in
ec) CaKeyLength=521
CaDigest="sha512"
EeKeyLength=384
EeDigest="sha384"
Expand Down
19 changes: 17 additions & 2 deletions scripts/check_format
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@
#
# SPDX-License-Identifier: Apache-2.0
#
rc=0

echo "Checking file format ..."
found=`gofmt -l \`find . -name "*.go" |grep -v "./vendor"\` 2>&1`
found=$(gofmt -l `find . -path ./vendor -prune -o -type f -regex ".*.go" -print` 2>&1)
if [[ -n "$found" ]]; then
echo "The following files need reformatting with 'gofmt -w <file>':"
echo "$found"
exit 1
let rc+=1
fi

echo "Checking for trailing blanks..."
find . -path ./vendor -prune -o -type f -regex ".*\(regenDocs\|\.\(go\|sh\)\)" \
-exec egrep -q " +$" {} \; \
-exec printf "trailing blanks in {}\n" \; | egrep ".*"
if test $? -eq 0; then
echo "To fix, run"
echo ' find . -path ./vendor -prune -o -type f -regex ".*\(regenDocs\|\.\(go\|sh\)\)" -exec sed -i "s/ \+$//" {} \;'
echo ""
let rc+=1
fi

test "$rc" -eq 0 || exit "$rc"
echo "All files are properly formatted"
4 changes: 2 additions & 2 deletions scripts/fvt/backwards_comp_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ function loadUsers {
psql -d $DBNAME -c "INSERT INTO users (id, token, type, affiliation, attributes, state, max_enrollments) VALUES ('notregistrar', '', 'user', 'org2', '[{\"name\": \"hf.Revoker\", \"value\": \"true\"}]', '0', '-1')"

sed -i "s/type: mysql/type: postgres/
s/datasource:.*/datasource: host=localhost port=$POSTGRES_PORT user=postgres password=postgres dbname=$DBNAME $postgresTls/" $TESTCONFIG
s/datasource:.*/datasource: host=localhost port=$POSTGRES_PORT user=postgres password=postgres dbname=$DBNAME $postgresTls/" $TESTCONFIG
;;
mysql)
mysql --host=localhost --user=root --password=mysql -e "CREATE DATABASE $DBNAME"
mysql --host=localhost --user=root --password=mysql --database=$DBNAME -e "CREATE TABLE IF NOT EXISTS users (id VARCHAR(255) NOT NULL, token blob, type VARCHAR(256), affiliation VARCHAR(1024), attributes TEXT, state INTEGER, max_enrollments INTEGER, PRIMARY KEY (id)) DEFAULT CHARSET=utf8 COLLATE utf8_bin"
mysql --host=localhost --user=root --password=mysql --database=$DBNAME -e "INSERT INTO users (id, token, type, affiliation, attributes, state, max_enrollments) VALUES ('registrar', '', 'user', 'org2', '[{\"name\": \"hf.Registrar.Roles\", \"value\": \"user,peer,client\"},{\"name\": \"hf.Revoker\", \"value\": \"true\"}]', '0', '-1')"
mysql --host=localhost --user=root --password=mysql --database=$DBNAME -e "INSERT INTO users (id, token, type, affiliation, attributes, state, max_enrollments) VALUES ('notregistrar', '', 'user', 'org2', '[{\"name\": \"hf.Revoker\", \"value\": \"true\"}]', '0', '-1')"
mysql --host=localhost --user=root --password=mysql --database=$DBNAME -e "INSERT INTO users (id, token, type, affiliation, attributes, state, max_enrollments) VALUES ('notregistrar', '', 'user', 'org2', '[{\"name\": \"hf.Revoker\", \"value\": \"true\"}]', '0', '-1')"
;;
*)
echo "Invalid database type"
Expand Down
2 changes: 1 addition & 1 deletion scripts/regenDocs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
######################################################################
#
# This script will use the fabric-ca-server and fabric-ca-client
# binaries to dynamically generate the CLI flags and the
# binaries to dynamically generate the CLI flags and the
# configuration files for both server and the client and place
# them in the docs/source folder. These files are referenced for
# in the fabric-ca documentation when talking about CLI and the
Expand Down
2 changes: 1 addition & 1 deletion test/fabric-ca-load-tester/launchServer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fi
pushd scripts/fvt
./fabric-ca_setup.sh -D -X -I -S -n$numInstances -m10 -d postgres -T
popd
# Docker requires your command to keep running in the foreground. Otherwise, it thinks
# Docker requires your command to keep running in the foreground. Otherwise, it thinks
# that command has stopped and shutsdown the container. Since fabric-ca_setup.sh starts
# fabric ca server in background and exits, we want this script to run in foreground and
# not return so the container in daemon mode continues to run for ever until it is stopped
Expand Down

0 comments on commit b57c216

Please sign in to comment.