When a script wanted to signal that a binary needed to exist that could
be built, we were previously using a lot of boilerplate to check for the
binary, build it if it wasn't there, and then find it again to use it.
Instead, we can just `ensure::built_binary_exists`
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
| ... | ... |
@@ -14,8 +14,8 @@ os::provision::build-origin() {
|
| 14 | 14 |
|
| 15 | 15 |
# This optimization is intended for devcluster use so hard-coding the |
| 16 | 16 |
# arch in the path should be ok. |
| 17 |
- if [[ -f "$(os::build::find-binary oc "${origin_root}")" &&
|
|
| 18 |
- "${skip_build}" = "true" ]]; then
|
|
| 17 |
+ if OS_ROOT="${origin_root}" os::util::find::built_binary oc >/dev/null 2>&1 &&
|
|
| 18 |
+ [[ "${skip_build}" = "true" ]]; then
|
|
| 19 | 19 |
echo "WARNING: Skipping openshift build due to OPENSHIFT_SKIP_BUILD=true" |
| 20 | 20 |
else |
| 21 | 21 |
echo "Building openshift" |
| ... | ... |
@@ -5,11 +5,7 @@ |
| 5 | 5 |
STARTTIME=$(date +%s) |
| 6 | 6 |
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
| 7 | 7 |
|
| 8 |
-oc="$(os::build::find-binary oc ${OS_ROOT})"
|
|
| 9 |
-if [[ -z "${oc}" ]]; then
|
|
| 10 |
- "${OS_ROOT}/hack/build-go.sh" cmd/oc
|
|
| 11 |
- oc="$(os::build::find-binary oc ${OS_ROOT})"
|
|
| 12 |
-fi |
|
| 8 |
+os::util::ensure::built_binary_exists 'oc' |
|
| 13 | 9 |
|
| 14 | 10 |
function build() {
|
| 15 | 11 |
eval "'${oc}' ex dockerbuild $2 $1 ${OS_BUILD_IMAGE_ARGS:-}"
|
| ... | ... |
@@ -44,11 +44,7 @@ else |
| 44 | 44 |
os::build::extract_tar "${OS_IMAGE_RELEASE_TAR}" "${imagedir}"
|
| 45 | 45 |
fi |
| 46 | 46 |
|
| 47 |
-oc="$(os::build::find-binary oc ${OS_ROOT})"
|
|
| 48 |
-if [[ -z "${oc}" ]]; then
|
|
| 49 |
- "${OS_ROOT}/hack/build-go.sh" cmd/oc
|
|
| 50 |
- oc="$(os::build::find-binary oc ${OS_ROOT})"
|
|
| 51 |
-fi |
|
| 47 |
+os::util::ensure::built_binary_exists 'oc' |
|
| 52 | 48 |
|
| 53 | 49 |
function build() {
|
| 54 | 50 |
eval "'${oc}' ex dockerbuild $2 $1 ${OS_BUILD_IMAGE_ARGS:-}"
|
| ... | ... |
@@ -1,12 +1,8 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
|
| 3 |
-if ! which origin-version-change &>/dev/null; then |
|
| 4 |
- echo "The 'origin-version-change' was not found in the PATH." |
|
| 5 |
- echo "To build it, run: ./hack/build-go.sh cmd/origin-version-change" |
|
| 6 |
- echo |
|
| 7 |
- exit 1 |
|
| 8 |
-fi |
|
| 3 |
+source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
|
| 9 | 4 |
|
| 5 |
+os::util::ensure::built_binary_exists 'origin-version-change' |
|
| 10 | 6 |
IGNORE_FILES={$IGNORE_FILES:-"examples/sample-app/github-webhook-example.json"}
|
| 11 | 7 |
|
| 12 | 8 |
sample_files=$(find {api,examples,docs,images,plugins,test} -name "*.json" -o -name "*.yaml")
|
| ... | ... |
@@ -1,8 +1,5 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
| 3 | 3 |
|
| 4 |
-"${OS_ROOT}/hack/build-go.sh" tools/rebasehelpers/godepchecker
|
|
| 5 |
- |
|
| 6 |
-# Find binary |
|
| 7 |
-godepchecker="$(os::build::find-binary godepchecker)" |
|
| 8 | 4 |
$godepchecker "$@" |
| 5 |
+os::util::ensure::built_binary_exists 'godepchecker' |
| ... | ... |
@@ -38,23 +38,14 @@ function cleanup() |
| 38 | 38 |
os::test::junit::check_test_counters |
| 39 | 39 |
|
| 40 | 40 |
# use the junitreport tool to generate us a report |
| 41 |
- "${OS_ROOT}/hack/build-go.sh" tools/junitreport
|
|
| 42 |
- junitreport="$(os::build::find-binary junitreport)" |
|
| 43 |
- |
|
| 44 |
- if [[ -z "${junitreport}" ]]; then
|
|
| 45 |
- echo "It looks as if you don't have a compiled junitreport binary" |
|
| 46 |
- echo |
|
| 47 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 48 |
- echo "'./hack/build-go.sh tools/junitreport'." |
|
| 49 |
- exit 1 |
|
| 50 |
- fi |
|
| 51 |
- |
|
| 52 | 41 |
cat "${JUNIT_REPORT_OUTPUT}" \
|
| 53 | 42 |
| "${junitreport}" --type oscmd \
|
| 54 | 43 |
--suites nested \ |
| 55 | 44 |
--roots github.com/openshift/origin \ |
| 56 | 45 |
--output "${ARTIFACT_DIR}/report.xml"
|
| 57 | 46 |
cat "${ARTIFACT_DIR}/report.xml" | "${junitreport}" summarize
|
| 47 |
+ os::util::ensure::built_binary_exists 'junitreport' |
|
| 48 |
+ |
|
| 58 | 49 |
fi |
| 59 | 50 |
|
| 60 | 51 |
ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds" |
| ... | ... |
@@ -200,16 +200,7 @@ fi |
| 200 | 200 |
# Run 'go test' with the accumulated arguments and packages: |
| 201 | 201 |
if [[ -n "${junit_report}" ]]; then
|
| 202 | 202 |
# we need to generate jUnit xml |
| 203 |
- "${OS_ROOT}/hack/build-go.sh" tools/junitreport
|
|
| 204 |
- junitreport="$(os::build::find-binary junitreport)" |
|
| 205 |
- |
|
| 206 |
- if [[ -z "${junitreport}" ]]; then
|
|
| 207 |
- echo "It looks as if you don't have a compiled junitreport binary" |
|
| 208 |
- echo |
|
| 209 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 210 |
- echo "'./hack/build-go.sh tools/junitreport'." |
|
| 211 |
- exit 1 |
|
| 212 |
- fi |
|
| 203 |
+ os::util::ensure::built_binary_exists 'junitreport' |
|
| 213 | 204 |
|
| 214 | 205 |
test_output_file="${LOG_DIR}/test-go.log"
|
| 215 | 206 |
test_error_file="${LOG_DIR}/test-go-err.log"
|
| ... | ... |
@@ -3,8 +3,7 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
| 3 | 3 |
|
| 4 | 4 |
os::build::setup_env |
| 5 | 5 |
|
| 6 |
-hack/build-go.sh cmd/dockerregistry |
|
| 7 |
-dockerregistry="$( os::build::find-binary dockerregistry )" |
|
| 6 |
+os::util::ensure::built_binary_exists 'dockerregistry' |
|
| 8 | 7 |
|
| 9 | 8 |
url="${DOCKER_REGISTRY_URL:-localhost:5000}"
|
| 10 | 9 |
# find the first builder service account token |
| ... | ... |
@@ -3,20 +3,7 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
| 3 | 3 |
|
| 4 | 4 |
os::build::setup_env |
| 5 | 5 |
|
| 6 |
-"${OS_ROOT}/hack/build-go.sh" vendor/k8s.io/kubernetes/cmd/libs/go2idl/client-gen
|
|
| 7 |
- |
|
| 8 |
-# Find binary |
|
| 9 |
-clientgen="$(os::build::find-binary client-gen)" |
|
| 10 |
- |
|
| 11 |
-if [[ ! "$clientgen" ]]; then |
|
| 12 |
- {
|
|
| 13 |
- echo "It looks as if you don't have a compiled client-gen binary" |
|
| 14 |
- echo |
|
| 15 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 16 |
- echo "'./hack/build-go.sh vendor/k8s.io/kubernetes/cmd/libs/go2idl/client-gen'." |
|
| 17 |
- } >&2 |
|
| 18 |
- exit 1 |
|
| 19 |
-fi |
|
| 6 |
+os::util::ensure::built_binary_exists 'client-gen' 'vendor/k8s.io/kubernetes/cmd/libs/go2idl/client-gen' |
|
| 20 | 7 |
|
| 21 | 8 |
# list of package to generate client set for |
| 22 | 9 |
packages=( |
| ... | ... |
@@ -3,15 +3,6 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
| 3 | 3 |
|
| 4 | 4 |
os::build::setup_env |
| 5 | 5 |
|
| 6 |
-"${OS_ROOT}/hack/build-go.sh" tools/genconversion
|
|
| 7 |
-genconversion="$( os::build::find-binary genconversion )" |
|
| 8 |
- |
|
| 9 |
-if [[ -z "${genconversion}" ]]; then
|
|
| 10 |
- echo "It looks as if you don't have a compiled genconversion binary." |
|
| 11 |
- echo |
|
| 12 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 13 |
- echo "'./hack/build-go.sh tools/genconversion'." |
|
| 14 |
- exit 1 |
|
| 15 |
-fi |
|
| 6 |
+os::util::ensure::built_binary_exists 'genconversion' |
|
| 16 | 7 |
|
| 17 | 8 |
${genconversion} --output-base="${GOPATH}/src" "$@"
|
| 18 | 9 |
\ No newline at end of file |
| ... | ... |
@@ -3,15 +3,6 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
| 3 | 3 |
|
| 4 | 4 |
os::build::setup_env |
| 5 | 5 |
|
| 6 |
-"${OS_ROOT}/hack/build-go.sh" tools/gendeepcopy
|
|
| 7 |
-gendeepcopy="$( os::build::find-binary gendeepcopy )" |
|
| 8 |
- |
|
| 9 |
-if [[ -z "${gendeepcopy}" ]]; then
|
|
| 10 |
- echo "It looks as if you don't have a compiled gendeepcopy binary." |
|
| 11 |
- echo |
|
| 12 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 13 |
- echo "'./hack/build-go.sh tools/gendeepcopy'." |
|
| 14 |
- exit 1 |
|
| 15 |
-fi |
|
| 6 |
+os::util::ensure::built_binary_exists 'gendeepcopy' |
|
| 16 | 7 |
|
| 17 | 8 |
${gendeepcopy} --output-base="${GOPATH}/src" "$@"
|
| 18 | 9 |
\ No newline at end of file |
| ... | ... |
@@ -4,31 +4,8 @@ |
| 4 | 4 |
|
| 5 | 5 |
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
| 6 | 6 |
|
| 7 |
-"${OS_ROOT}/hack/build-go.sh" tools/gendocs tools/genman
|
|
| 8 |
- |
|
| 9 |
-# Find binary |
|
| 10 |
-gendocs="$(os::build::find-binary gendocs)" |
|
| 11 |
-genman="$(os::build::find-binary genman)" |
|
| 12 |
- |
|
| 13 |
-if [[ -z "$gendocs" ]]; then |
|
| 14 |
- {
|
|
| 15 |
- echo "It looks as if you don't have a compiled gendocs binary" |
|
| 16 |
- echo |
|
| 17 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 18 |
- echo "'./hack/build-go.sh tools/gendocs'." |
|
| 19 |
- } >&2 |
|
| 20 |
- exit 1 |
|
| 21 |
-fi |
|
| 22 |
- |
|
| 23 |
-if [[ -z "$genman" ]]; then |
|
| 24 |
- {
|
|
| 25 |
- echo "It looks as if you don't have a compiled genman binary" |
|
| 26 |
- echo |
|
| 27 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 28 |
- echo "'./hack/build-go.sh tools/genman'" |
|
| 29 |
- } >&2 |
|
| 30 |
- exit 1 |
|
| 31 |
-fi |
|
| 7 |
+os::util::ensure::built_binary_exists 'gendocs' |
|
| 8 |
+os::util::ensure::built_binary_exists 'genman' |
|
| 32 | 9 |
|
| 33 | 10 |
OUTPUT_DIR_REL=${1:-""}
|
| 34 | 11 |
OUTPUT_DIR="${OS_ROOT}/${OUTPUT_DIR_REL}/docs/generated"
|
| ... | ... |
@@ -22,15 +22,7 @@ fi |
| 22 | 22 |
|
| 23 | 23 |
os::build::setup_env |
| 24 | 24 |
|
| 25 |
-"${OS_ROOT}/hack/build-go.sh" tools/genprotobuf vendor/k8s.io/kubernetes/cmd/libs/go2idl/go-to-protobuf/protoc-gen-gogo
|
|
| 26 |
-genprotobuf="$( os::build::find-binary genprotobuf )" |
|
| 27 |
- |
|
| 28 |
-if [[ -z "${genprotobuf}" ]]; then
|
|
| 29 |
- echo "It looks as if you don't have a compiled genprotobuf binary." |
|
| 30 |
- echo |
|
| 31 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 32 |
- echo "'./hack/build-go.sh tools/genprotobuf'." |
|
| 33 |
- exit 1 |
|
| 34 |
-fi |
|
| 25 |
+os::util::ensure::built_binary_exists 'genprotobuf' |
|
| 26 |
+os::util::ensure::built_binary_exists 'protoc-gen-gogo' vendor/k8s.io/kubernetes/cmd/libs/go2idl/go-to-protobuf/protoc-gen-gogo |
|
| 35 | 27 |
|
| 36 | 28 |
PATH="$( dirname "${genprotobuf}" ):${PATH}" ${genprotobuf} --output-base="${GOPATH}/src" "$@"
|
| ... | ... |
@@ -15,16 +15,7 @@ dryrun="${DRY_RUN:-}"
|
| 15 | 15 |
|
| 16 | 16 |
mkdir -p /tmp/openshift/generate/swaggerdoc |
| 17 | 17 |
|
| 18 |
-"${OS_ROOT}/hack/build-go.sh" tools/genswaggerdoc
|
|
| 19 |
-genswaggerdoc="$( os::build::find-binary genswaggerdoc )" |
|
| 20 |
- |
|
| 21 |
-if [[ -z "${genswaggerdoc}" ]]; then
|
|
| 22 |
- echo "It looks as if you don't have a compiled genswaggerdoc binary." |
|
| 23 |
- echo |
|
| 24 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 25 |
- echo "'./hack/build-go.sh tools/genswaggerdoc'." |
|
| 26 |
- exit 1 |
|
| 27 |
-fi |
|
| 18 |
+os::util::ensure::built_binary_exists 'genswaggerdoc' |
|
| 28 | 19 |
|
| 29 | 20 |
source_files="$( find_files | grep -E '/v1/types.go' )" |
| 30 | 21 |
|
| ... | ... |
@@ -4,20 +4,7 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
| 4 | 4 |
echo "===== Verifying CLI Conventions =====" |
| 5 | 5 |
|
| 6 | 6 |
# ensure we have the latest compiled binaries |
| 7 |
-"${OS_ROOT}/hack/build-go.sh" tools/clicheck
|
|
| 8 |
- |
|
| 9 |
-# Find binary |
|
| 10 |
-clicheck="$(os::build::find-binary clicheck)" |
|
| 11 |
- |
|
| 12 |
-if [[ -z "$clicheck" ]]; then |
|
| 13 |
- {
|
|
| 14 |
- echo "It looks as if you don't have a compiled clicheck binary" |
|
| 15 |
- echo |
|
| 16 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 17 |
- echo "'./hack/build-go.sh tools/clicheck'." |
|
| 18 |
- } >&2 |
|
| 19 |
- exit 1 |
|
| 20 |
-fi |
|
| 7 |
+os::util::ensure::built_binary_exists 'clicheck' |
|
| 21 | 8 |
|
| 22 | 9 |
if ! output=`$clicheck 2>&1` |
| 23 | 10 |
then |
| ... | ... |
@@ -6,10 +6,8 @@ if ! git status &> /dev/null; then |
| 6 | 6 |
exit 0 |
| 7 | 7 |
fi |
| 8 | 8 |
|
| 9 |
-"${OS_ROOT}/hack/build-go.sh" tools/rebasehelpers/commitchecker
|
|
| 9 |
+os::util::ensure::built_binary_exists 'commitchecker' |
|
| 10 | 10 |
|
| 11 |
-# Find binary |
|
| 12 |
-commitchecker="$(os::build::find-binary commitchecker)" |
|
| 13 | 11 |
echo "===== Verifying UPSTREAM Commits =====" |
| 14 | 12 |
$commitchecker |
| 15 | 13 |
echo "SUCCESS: All commits are valid." |
| ... | ... |
@@ -47,23 +47,14 @@ function cleanup() {
|
| 47 | 47 |
os::test::junit::check_test_counters |
| 48 | 48 |
|
| 49 | 49 |
# use the junitreport tool to generate us a report |
| 50 |
- "${OS_ROOT}/hack/build-go.sh" tools/junitreport
|
|
| 51 |
- junitreport="$(os::build::find-binary junitreport)" |
|
| 52 |
- |
|
| 53 |
- if [[ -z "${junitreport}" ]]; then
|
|
| 54 |
- echo "It looks as if you don't have a compiled junitreport binary" |
|
| 55 |
- echo |
|
| 56 |
- echo "If you are running from a clone of the git repo, please run" |
|
| 57 |
- echo "'./hack/build-go.sh tools/junitreport'." |
|
| 58 |
- exit 1 |
|
| 59 |
- fi |
|
| 60 |
- |
|
| 61 | 50 |
cat "${JUNIT_REPORT_OUTPUT}" "${junit_gssapi_output}" \
|
| 62 | 51 |
| "${junitreport}" --type oscmd \
|
| 63 | 52 |
--suites nested \ |
| 64 | 53 |
--roots github.com/openshift/origin \ |
| 65 | 54 |
--output "${ARTIFACT_DIR}/report.xml"
|
| 66 | 55 |
cat "${ARTIFACT_DIR}/report.xml" | "${junitreport}" summarize
|
| 56 |
+ os::util::ensure::built_binary_exists 'junitreport' |
|
| 57 |
+ |
|
| 67 | 58 |
fi |
| 68 | 59 |
|
| 69 | 60 |
endtime=$(date +%s); echo "$0 took $((endtime - starttime)) seconds" |
| ... | ... |
@@ -212,7 +212,8 @@ function run-extended-tests() {
|
| 212 | 212 |
|
| 213 | 213 |
if [[ -n "${dlv_debug}" ]]; then
|
| 214 | 214 |
# run tests using delve debugger |
| 215 |
- local test_cmd="dlv exec ${TEST_BINARY} -- ${test_args}"
|
|
| 215 |
+ local extended_test; extended_test="$( os::util::find::built_binary extended.test )" |
|
| 216 |
+ local test_cmd="dlv exec ${extended_test} -- ${test_args}"
|
|
| 216 | 217 |
else |
| 217 | 218 |
# run tests normally |
| 218 | 219 |
local test_cmd="${TEST_BINARY} ${test_args}"
|
| ... | ... |
@@ -22,15 +22,11 @@ function os::test::extended::focus {
|
| 22 | 22 |
# be done in other contexts. |
| 23 | 23 |
function os::test::extended::setup () {
|
| 24 | 24 |
# build binaries |
| 25 |
- if [[ -z "$(os::build::find-binary ginkgo)" ]]; then |
|
| 26 |
- hack/build-go.sh vendor/github.com/onsi/ginkgo/ginkgo |
|
| 27 |
- fi |
|
| 28 |
- if [[ -z "$(os::build::find-binary extended.test)" ]]; then |
|
| 29 |
- hack/build-go.sh test/extended/extended.test |
|
| 30 |
- fi |
|
| 31 |
- if [[ -z "$(os::build::find-binary openshift)" ]]; then |
|
| 32 |
- hack/build-go.sh |
|
| 33 |
- fi |
|
| 25 |
+ os::util::ensure::built_binary_exists 'ginkgo' 'vendor/github.com/onsi/ginkgo/ginkgo' |
|
| 26 |
+ os::util::ensure::built_binary_exists 'extended.test' 'test/extended/extended.test' |
|
| 27 |
+ os::util::ensure::built_binary_exists 'openshift' |
|
| 28 |
+ os::util::ensure::built_binary_exists 'oadm' |
|
| 29 |
+ os::util::ensure::built_binary_exists 'oc' |
|
| 34 | 30 |
|
| 35 | 31 |
os::util::environment::setup_time_vars |
| 36 | 32 |
os::util::environment::setup_all_server_vars "test-extended/core" |
| ... | ... |
@@ -163,7 +159,7 @@ function os::test::extended::run () {
|
| 163 | 163 |
return |
| 164 | 164 |
fi |
| 165 | 165 |
|
| 166 |
- "${GINKGO}" -v "${runArgs[@]}" "${EXTENDEDTEST}" "$@"
|
|
| 166 |
+ ginkgo -v "${runArgs[@]}" "$( os::util::find::built_binary extended.test )" "$@"
|
|
| 167 | 167 |
} |
| 168 | 168 |
|
| 169 | 169 |
# Create a list of extended tests to be run with the given arguments |