Skip to content

Commit c16dc72

Browse files
committed
[hack/verify-file-sizes.sh] Support Mac OS X
1 parent e3bb757 commit c16dc72

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

hack/verify-file-sizes.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ cd "${KUBE_ROOT}"
2424
# Files larger than 1MB need to be allowed explicitly.
2525
maxsize=$((1 * 1024 * 1024))
2626

27+
run_stat() {
28+
local file="$1"
29+
case "$(uname -s)" in
30+
Darwin)
31+
stat -f %z "$file" | tr -d '\n'
32+
;;
33+
Linux)
34+
stat --printf=%s "$file"
35+
;;
36+
*)
37+
kube::log::error "Unsupported host OS. Must be Linux or Mac OS X."
38+
exit 1
39+
;;
40+
esac
41+
}
42+
2743
# Sorted list of those exceptions.
2844
allowlist=(
2945
staging/src/k8s.io/kubectl/images/kubectl-logo-full.png
@@ -42,7 +58,7 @@ largefiles () {
4258
case "$tree" in
4359
w/-text)
4460
# Only binary files have a size limit.
45-
size="$(stat --printf=%s "$file")"
61+
size="$(run_stat "$file")"
4662
if [ "${size}" -gt "$maxsize" ] &&
4763
! kube::util::array_contains "$file" "${allowlist[@]}"; then
4864
echo "$file is too large ($size bytes)"

0 commit comments

Comments
 (0)