Skip to content

Commit b8c4b4c

Browse files
hack: Fix shell errors in generating completions
Did not work on OS X due to missing function, was using the wrong binary to execute.
1 parent 8f82bfc commit b8c4b4c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

hack/lib/init.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ OS_ROOT="$(dirname "${BASH_SOURCE}")/../.."
1616
function os::build::host_platform() {
1717
echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"
1818
}
19+
function os::log::warning() {
20+
echo "warning: ${1}" 1>&2
21+
}
1922
readonly -f os::build::host_platform

hack/update-generated-completions.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function os::build::gen-completions() {
1414
local tmpdir="${OS_ROOT}/_tmp/gen_comp"
1515
mkdir -p "${tmpdir}"
1616
# generate the new files
17-
${OS_ROOT}/oc completion ${shell} > $tmpdir/oc
17+
${oc} completion ${shell} > $tmpdir/oc
1818
# create the list of generated files
1919
ls "${tmpdir}" | LC_ALL=C sort > "${tmpdir}/.files_generated"
2020

@@ -42,9 +42,11 @@ function os::build::gen-completions() {
4242
}
4343
readonly -f os::build::gen-completions
4444

45+
oc="${OS_ROOT}/oc"
4546
platform="$(os::build::host_platform)"
4647
if [[ "${platform}" != "linux/amd64" ]]; then
4748
os::log::warning "Generating completions on ${platform} may not be identical to running on linux/amd64 due to conditional compilation."
49+
oc="${OS_ROOT}/_output/bin/${platform//\//_}/oc"
4850
fi
4951

5052
OUTPUT_DIR_ROOT="${1:-${OS_ROOT}/contrib/completions}"

hack/verify-generated-completions.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,5 @@ COMPLETION_ROOT="${OS_ROOT}/${COMPLETION_ROOT_REL}"
1414
TMP_COMPLETION_ROOT_REL="_output/verify-generated-completions/"
1515
TMP_COMPLETION_ROOT="${OS_ROOT}/${TMP_COMPLETION_ROOT_REL}"
1616

17-
platform="$(os::build::host_platform)"
18-
if [[ "${platform}" != "linux/amd64" ]]; then
19-
os::log::warning "Completions cannot be verified on non-Linux systems (${platform})"
20-
exit 0
21-
fi
22-
2317
${OS_ROOT}/hack/update-generated-completions.sh ${TMP_COMPLETION_ROOT_REL}
2418
diff -Naupr -x 'OWNERS' ${COMPLETION_ROOT} ${TMP_COMPLETION_ROOT}

0 commit comments

Comments
 (0)