[VOL-4415] Moved voltctl installation to its own keyword
Change-Id: Id58162b7a100efda715a837dc87959cdf4bf1307
diff --git a/vars/createKubernetesCluster.groovy b/vars/createKubernetesCluster.groovy
index 24a052f..4843d8b 100644
--- a/vars/createKubernetesCluster.groovy
+++ b/vars/createKubernetesCluster.groovy
@@ -54,18 +54,7 @@
mv ./kind $WORKSPACE/bin/kind
# install voltctl
- HOSTOS="\$(uname -s | tr "[:upper:]" "[:lower:"])"
- HOSTARCH="\$(uname -m | tr "[:upper:]" "[:lower:"])"
- if [ "\$HOSTARCH" == "x86_64" ]; then
- HOSTARCH="amd64"
- fi
- if [ "${cfg.branch}" == "voltha-2.8" ]; then
- VC_VERSION="1.6.11"
- else
- VC_VERSION="\$(curl --fail -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')"
- fi
- curl -Lo $WORKSPACE/bin/voltctl https://github.com/opencord/voltctl/releases/download/v\$VC_VERSION/voltctl-\$VC_VERSION-\$HOSTOS-\$HOSTARCH
- chmod +x $WORKSPACE/bin/voltctl
+ installVoltctl("${cfg.branch}")
# start the kind cluster
kind create cluster --name ${cfg.name} --config kind.cfg
diff --git a/vars/installVoltctl.groovy b/vars/installVoltctl.groovy
new file mode 100644
index 0000000..d81c9ed
--- /dev/null
+++ b/vars/installVoltctl.groovy
@@ -0,0 +1,20 @@
+# This keyword will install the voltctl based on the branch (e.g.: voltha-2.8 or master)
+def call(String branch) {
+ sh returnStdout: false, script: """
+ mkdir -p $WORKSPACE/bin
+ cd $WORKSPACE
+ if [ "${branch}" == "voltha-2.8" ]; then
+ VOLTCTL_VERSION=1.6.11
+ else
+ VOLTCTL_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
+ fi
+ HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
+ HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
+ if [ \$HOSTARCH == "x86_64" ]; then
+ HOSTARCH="amd64"
+ fi
+ curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VOLTCTL_VERSION}/voltctl-\${VOLTCTL_VERSION}-\${HOSTOS}-\${HOSTARCH}
+ chmod 755 $WORKSPACE/bin/voltctl
+ voltctl version --clientonly
+ """
+}