Merge pull request #1470 from timstclair/assets

Fix UI assets
This commit is contained in:
Tim St. Clair 2016-09-19 15:41:38 -07:00 committed by GitHub
commit 418c181eba
5 changed files with 33 additions and 17 deletions

View File

@ -31,11 +31,14 @@ vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)
build:
build: assets
@echo ">> building binaries"
@./build/assets.sh
@./build/build.sh
assets:
@echo ">> building assets"
@./build/assets.sh
release:
@echo ">> building release binaries"
@RELEASE=true ./build/build.sh

View File

@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
GIT_ROOT=$(dirname "${BASH_SOURCE}")/..
ASSETS_INPUT_DIRS="$GIT_ROOT/pages/assets/js/... $GIT_ROOT/pages/assets/styles/..."
@ -24,6 +26,8 @@ TEMPLATES_INPUT_DIRS="$GIT_ROOT/pages/assets/html/..."
TEMPLATES_OUTPUT_PATH="$GIT_ROOT/pages/templates.go"
TEMPLATES_PACKAGE="pages"
FORCE="${FORCE:-}" # Force assets to be rebuilt if FORCE=true
go get -u github.com/jteeuwen/go-bindata/...
build_asset () {
@ -33,7 +37,7 @@ build_asset () {
local tmp_output=$(mktemp)
local year=$(date +%Y)
go-bindata -o $output_path -pkg $package $input_dirs
go-bindata -nometadata -o $output_path -pkg $package $input_dirs
cat build/boilerplate/boilerplate.go.txt | sed "s/YEAR/$year/" > "${tmp_output}"
echo -e "// generated by build/assets.sh; DO NOT EDIT\n" >> "${tmp_output}"
cat "${output_path}" >> "${tmp_output}"
@ -42,17 +46,17 @@ build_asset () {
}
for f in $GIT_ROOT/pages/assets/js/* $GIT_ROOT/pages/assets/styles/*; do
if [ "$f" -nt $ASSETS_OUTPUT_PATH -o ! -e $ASSETS_OUTPUT_PATH ]; then
build_asset "$ASSETS_PACKAGE" "$ASSETS_OUTPUT_PATH" "$ASSETS_INPUT_DIRS"
if [ "$FORCE" == "true" ] || [ "$f" -nt $ASSETS_OUTPUT_PATH -o ! -e $ASSETS_OUTPUT_PATH ]; then
build_asset "$ASSETS_PACKAGE" "$ASSETS_OUTPUT_PATH" "$ASSETS_INPUT_DIRS"
break;
fi
done
for f in $GIT_ROOT/pages/assets/html/*; do
if [ "$f" -nt $TEMPLATES_OUTPUT_PATH -o ! -e $TEMPLATES_OUTPUT_PATH ]; then
if [ "$FORCE" == "true" ] || [ "$f" -nt $TEMPLATES_OUTPUT_PATH -o ! -e $TEMPLATES_OUTPUT_PATH ]; then
build_asset "$TEMPLATES_PACKAGE" "$TEMPLATES_OUTPUT_PATH" "$TEMPLATES_INPUT_DIRS"
break;
fi
done
exit 0
exit 0

View File

@ -22,6 +22,15 @@ BUILDER=${BUILDER:-false} # Whether this is running a PR builder job.
export GO_FLAGS="-race"
export GORACE="halt_on_error=1"
# Check whether assets need to be rebuilt.
FORCE=true build/assets.sh
if [[ ! -z "$(git diff --name-only pages)" ]]; then
echo "Found changes to UI assets:"
git diff --name-only pages
echo "Run: `make assets FORCE=true`"
exit 1
fi
make
go build -tags test github.com/google/cadvisor/integration/runner

File diff suppressed because one or more lines are too long

View File

@ -98,7 +98,7 @@ func pagesAssetsHtmlContainersHtml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "pages/assets/html/containers.html", size: 9533, mode: os.FileMode(416), modTime: time.Unix(1462817463, 0)}
info := bindataFileInfo{name: "pages/assets/html/containers.html", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}