From 04241a673d538e59746d06857620e66934c9d453 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Wed, 12 Apr 2017 12:12:05 -0400 Subject: [PATCH] Do etcd semver validation using posix only --- hack/lib/etcd.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hack/lib/etcd.sh b/hack/lib/etcd.sh index 4bfa16612d..2f6e511a1b 100755 --- a/hack/lib/etcd.sh +++ b/hack/lib/etcd.sh @@ -36,12 +36,12 @@ kube::etcd::validate() { # validate installed version is at least equal to minimum version=$(etcd --version | tail -n +1 | head -n 1 | cut -d " " -f 3) - if [[ "`echo -e "${version}\n${ETCD_VERSION}" | sort -rV | head -n 1`" != "$version" ]]; then + if [[ $(kube::etcd::version $ETCD_VERSION) -gt $(kube::etcd::version $version) ]]; then export PATH=$KUBE_ROOT/third_party/etcd:$PATH hash etcd echo $PATH version=$(etcd --version | head -n 1 | cut -d " " -f 3) - if [[ "`echo -e "${version}\n${ETCD_VERSION}" | sort -rV | head -n 1`" != "$version" ]]; then + if [[ $(kube::etcd::version $ETCD_VERSION) -gt $(kube::etcd::version $version) ]]; then kube::log::usage "etcd version ${ETCD_VERSION} or greater required." kube::log::info "You can use 'hack/install-etcd.sh' to install a copy in third_party/." exit 1 @@ -49,6 +49,10 @@ kube::etcd::validate() { fi } +kube::etcd::version() { + printf '%s\n' "${@}" | awk -F . '{ printf("%d%03d%03d\n", $1, $2, $3) }' +} + kube::etcd::start() { # validate before running kube::etcd::validate