Skip to content

Commit

Permalink
Add datafile.go back to go build for container build scenario, with n…
Browse files Browse the repository at this point in the history
…o tool dependency.
  • Loading branch information
jackgr committed May 27, 2015
1 parent 8429624 commit 7a9d1f0
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 6,421 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -54,5 +54,7 @@ network_closure.sh
# Web UI
www/master/node_modules/
www/master/npm-debug.log
www/master/shared/config/development.json

# Karma output
www/test_out
2 changes: 0 additions & 2 deletions build/release.sh
Expand Up @@ -32,8 +32,6 @@ kube::build::verify_prereqs
kube::build::build_ui_image
kube::build::run_build_ui_command hack/ui/build-www.sh

kube::ui::build_ui

kube::build::build_image
kube::build::run_build_command hack/build-cross.sh

Expand Down
2 changes: 2 additions & 0 deletions hack/build-cross.sh
Expand Up @@ -24,6 +24,8 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"

kube::ui::build_ui

KUBE_BUILD_PLATFORMS=("${KUBE_SERVER_PLATFORMS[@]}")
kube::golang::build_binaries "${KUBE_SERVER_TARGETS[@]}"

Expand Down
2 changes: 2 additions & 0 deletions hack/build-go.sh
Expand Up @@ -23,5 +23,7 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"

kube::ui::build_ui

kube::golang::build_binaries "$@"
kube::golang::place_bins
38 changes: 21 additions & 17 deletions hack/lib/ui.sh
Expand Up @@ -17,38 +17,42 @@
# The paths used to find and package the assets.
readonly KUBE_BUILD_OUTPUT_PATH="${KUBE_OUTPUT}/www"
readonly KUBE_BUILD_ASSETS=(
app
www/app
third_party/swagger-ui
)
readonly KUBE_BUILD_TARGET=pkg/ui/datafile.go

function kube::ui::generate_asset_paths() {
local asset
for asset in "${KUBE_BUILD_ASSETS[@]}"; do
if [[ -d $"${KUBE_BUILD_OUTPUT_PATH}/${asset}" ]]; then
echo "${KUBE_BUILD_OUTPUT_PATH}/${asset}/..."
if [[ -d $"${KUBE_OUTPUT}/${asset}" ]]; then
echo "${KUBE_OUTPUT}/${asset}/..."
fi
done
}

function kube::ui::build_ui() {
if ! which go-bindata > /dev/null 2>&1 ; then
echo "Cannot find go-bindata. Install with \"go get github.com/jteeuwen/go-bindata/...\""
exit 1
fi

local -r asset_paths=$(kube::ui::generate_asset_paths)
if ! go-bindata -nocompress -o "${KUBE_BUILD_TARGET}" -prefix "${KUBE_OUTPUT}" -pkg ui "${asset_paths[@]}" third_party/swagger-ui/... >/dev/null 2>&1 ; then
echo "Cannot package assets."
exit 1
fi
echo "Skipping ui build."
else
mkdir -p "${KUBE_OUTPUT}"
tar cf - third_party/swagger-ui | ( cd "${KUBE_OUTPUT}" ; /bin/rm -rf third_party/swagger-ui ; tar xf - )
local -r asset_paths=$(kube::ui::generate_asset_paths)

if ! go-bindata -nocompress -o "${KUBE_BUILD_TARGET}" -prefix "${KUBE_OUTPUT}" -pkg ui "${asset_paths[@]}" >/dev/null 2>&1 ; then
echo "Cannot package assets."
exit 1
fi

local -r build_target=/tmp/datafile.go
local -r build_target=/tmp/datafile.go

sed "s/YEAR/$(date +'%Y')/" hooks/boilerplate.go.txt > $build_target
printf "// generated by hack/build-ui.sh; DO NOT EDIT\n" >> $build_target
cat "${KUBE_BUILD_TARGET}" >> $build_target
sed "s/YEAR/$(date +'%Y')/" hooks/boilerplate.go.txt > $build_target
printf "// generated by hack/build-ui.sh; DO NOT EDIT\n" >> $build_target
cat "${KUBE_BUILD_TARGET}" >> $build_target

gofmt -s -w $build_target
mv $build_target "${KUBE_BUILD_TARGET}"
gofmt -s -w $build_target
mv $build_target "${KUBE_BUILD_TARGET}"
fi
}

0 comments on commit 7a9d1f0

Please sign in to comment.