mirror of https://github.com/status-im/consul.git
Create a new ui_version function to pull it out of an index.html file
Also verify the ui version after it was built that it matches the env var we set in the build container.
This commit is contained in:
parent
d6bc5bc2db
commit
f926786292
|
@ -919,3 +919,23 @@ function shasum_directory {
|
||||||
|
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ui_version {
|
||||||
|
# Arguments:
|
||||||
|
# $1 - path to index.html
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0 - success
|
||||||
|
# * -failure
|
||||||
|
#
|
||||||
|
# Notes: echoes the version to stdout upon success
|
||||||
|
if ! test -f "$1"
|
||||||
|
then
|
||||||
|
err "ERROR: No such file: '$1'"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local ui_version=$(sed -n ${SED_EXT} -e 's/.*CONSUL_VERSION%22%3A%22([^%]*)%22%2C%22.*/\1/p' < "$1") || return 1
|
||||||
|
echo "$ui_version"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ function build_ui {
|
||||||
# make sure we run within the ui dir
|
# make sure we run within the ui dir
|
||||||
pushd ${ui_dir} > /dev/null
|
pushd ${ui_dir} > /dev/null
|
||||||
|
|
||||||
status "Creating the UI Build Container with image: ${image_name} and embedding as version ${version}"
|
status "Creating the UI Build Container with image: ${image_name} and version '${version}'"
|
||||||
local container_id=$(docker create -it -e "CONSUL_GIT_SHA=${commit_hash}" -e "CONSUL_VERSION=${version}" ${image_name})
|
local container_id=$(docker create -it -e "CONSUL_GIT_SHA=${commit_hash}" -e "CONSUL_VERSION=${version}" ${image_name})
|
||||||
local ret=$?
|
local ret=$?
|
||||||
if test $ret -eq 0
|
if test $ret -eq 0
|
||||||
|
@ -85,10 +85,18 @@ function build_ui {
|
||||||
|
|
||||||
if test ${ret} -eq 0
|
if test ${ret} -eq 0
|
||||||
then
|
then
|
||||||
|
local ui_vers=$(ui_version "${1}/ui-v2/dist/index.html")
|
||||||
|
if test "${version}" != "${ui_vers}"
|
||||||
|
then
|
||||||
|
err "ERROR: UI version mismatch. Expecting: '${version}' found '${ui_vers}'"
|
||||||
|
ret=1
|
||||||
|
else
|
||||||
rm -rf ${1}/pkg/web_ui/v2
|
rm -rf ${1}/pkg/web_ui/v2
|
||||||
mkdir -p ${1}/pkg/web_ui
|
mkdir -p ${1}/pkg/web_ui
|
||||||
cp -r ${1}/ui-v2/dist ${1}/pkg/web_ui/v2
|
cp -r ${1}/ui-v2/dist ${1}/pkg/web_ui/v2
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ function main {
|
||||||
fi
|
fi
|
||||||
status_stage "==> Building UI"
|
status_stage "==> Building UI"
|
||||||
build_ui "${sdir}" "${image}" || return 1
|
build_ui "${sdir}" "${image}" || return 1
|
||||||
status_stage "==> UI V2 Built with embedded version: $(cat ${sdir}/pkg/web_ui/v2/index.html | sed -n -e 's/.*CONSUL_VERSION%22%3A%22//p' | sed -n -e 's/%22%2C%22.*//p')"
|
status "==> UI Built with Version: $(ui_version ${sdir}/pkg/web_ui/v2/index.html)"
|
||||||
;;
|
;;
|
||||||
ui-legacy )
|
ui-legacy )
|
||||||
if is_set "${refresh}"
|
if is_set "${refresh}"
|
||||||
|
|
Loading…
Reference in New Issue