Skip to content

Commit

Permalink
Migrate final function from and remove hack/util.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov committed Jun 9, 2017
1 parent 0f82878 commit 34bd18b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 35 deletions.
1 change: 0 additions & 1 deletion hack/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ cd "${OS_ROOT}"

library_files=( $( find "${OS_ROOT}/hack/lib" -type f -name '*.sh' -not -path '*/hack/lib/init.sh' ) )
# TODO(skuzmets): Move the contents of the following files into respective library files.
library_files+=( "${OS_ROOT}/hack/common.sh" )
library_files+=( "${OS_ROOT}/hack/util.sh" )

for library_file in "${library_files[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion hack/lib/util/ensure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
function os::util::ensure::system_binary_exists() {
local binary="$1"

if ! os::util::find::system_binary "${binary}" >/dev/null 2>&1; then
if ! os::util::find::system_binary "${binary}" >/dev/null 2>&1; then
os::log::fatal "Required \`${binary}\` binary was not found in \$PATH."
fi
}
Expand Down
31 changes: 30 additions & 1 deletion hack/lib/util/misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function os::util::curl_etcd() {
-out "${etcd_client_cert_p12}" \
-password "pass:${etcd_client_cert_p12_password}"
fi

b
curl --fail --silent --cacert "${ca_bundle}" \
--cert "${etcd_client_cert_p12}:${etcd_client_cert_p12_password}" "${full_url}"
else
Expand All @@ -204,3 +204,32 @@ function os::util::host_platform() {
echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"
}
readonly -f os::util::host_platform

# os::util::list_go_src_files lists files we consider part of our project
# source code, useful for tools that iterate over source to provide vet-
# ting or linting, etc.
#
# Globals:
# None
# Arguments:
# None
# Returns:
# None
function os::util::list_go_src_files() {
find . -not \( \
\( \
-wholename './_output' \
-o -wholename './.*' \
-o -wholename './pkg/assets/bindata.go' \
-o -wholename './pkg/assets/*/bindata.go' \
-o -wholename './pkg/bootstrap/bindata.go' \
-o -wholename './openshift.local.*' \
-o -wholename './test/extended/testdata/bindata.go' \
-o -wholename '*/vendor/*' \
-o -wholename './cmd/service-catalog/*' \
-o -wholename './cmd/cluster-capacity/*' \
-o -wholename './assets/bower_components/*' \
\) -prune \
\) -name '*.go' | sort -u
}
readonly -f os::util::list_go_src_files
2 changes: 1 addition & 1 deletion hack/update-generated-swagger-descriptions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mkdir -p "${tmpdir}"

os::util::ensure::built_binary_exists 'genswaggerdoc'

source_files="$( find_files | grep -E '/v1/types.go' )"
source_files="$( os::util::list_go_src_files | grep -E '/v1/types.go' )"

if [[ -n "${dryrun}" ]]; then
echo "The following files would be read by $0:"
Expand Down
26 changes: 0 additions & 26 deletions hack/util.sh

This file was deleted.

2 changes: 1 addition & 1 deletion hack/verify-gofmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

os::golang::verify_go_version

bad_files=$(find_files | xargs gofmt -s -l)
bad_files=$(os::util::list_go_src_files | xargs gofmt -s -l)
if [[ -n "${bad_files}" ]]; then
echo "!!! gofmt needs to be run on the following files: " >&2
echo "${bad_files}"
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if [ "$arg" == "-m" ]; then
fi
set -e
else
bad_files=$(find_files | \
bad_files=$(os::util::list_go_src_files | \
sort -u | \
sed 's/^.{2}//' | \
xargs -n1 printf "${GOPATH}/src/${OS_GO_PACKAGE}/%s\n" | \
Expand Down
5 changes: 2 additions & 3 deletions hack/verify-govet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ function govet_blacklist_contains() {
return 1
}

# cmd requires special handling since go tool vet descends recursively
test_dirs="$(find_files | cut -d '/' -f 1-2 | sort -u | grep -v "^./cmd")"
test_dirs+=" $(find_files | grep "^./cmd/"| cut -d '/' -f 1-3 | LC_ALL=C sort -u)"
test_dirs="$(os::util::list_go_src_files | cut -d '/' -f 1-2 | sort -u | grep -v "^./cmd")"
test_dirs+=" $(os::util::list_go_src_files | grep "^./cmd/"| cut -d '/' -f 1-3 | LC_ALL=C sort -u)"
for test_dir in ${test_dirs}; do
if ! result="$(go tool vet -shadow=false "${test_dir}" 2>&1)"; then
while read -r line; do
Expand Down

0 comments on commit 34bd18b

Please sign in to comment.