From 2799a4401ddfabfac2b5900f6c96c021e413b2a3 Mon Sep 17 00:00:00 2001 From: Shiyang Wang Date: Mon, 1 Oct 2018 21:24:57 +0800 Subject: [PATCH] add download-templates for cdi jinjia2 (#86) --- .gitignore | 3 +++ Dockerfile | 2 +- download-templates.sh | 24 +++++++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..781c3597 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA +.idea/ +*.iml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 58bed74d..e6bb4b84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ RUN yum install -y iptables wget \ ### UPSTREAM ONLY ### COPY requirements.yml /opt/ansible/requirements.yml COPY download-templates.sh /usr/bin/download-templates -RUN mkdir /opt/apb/kubevirt-templates \ +RUN mkdir /opt/apb/kubevirt-templates /opt/apb/kubevirt-templates/cdi \ && download-templates /opt/apb/kubevirt-templates RUN ansible-galaxy install -r /opt/ansible/requirements.yml \ diff --git a/download-templates.sh b/download-templates.sh index c8361cc1..8053a4a8 100755 --- a/download-templates.sh +++ b/download-templates.sh @@ -1,11 +1,12 @@ #!/bin/bash KUBEVIRT_TEMPLATE_DIR="${1:-$(dirname "${BASH_SOURCE}")}" +CDI_TEMPLATE_DIR="${KUBEVIRT_TEMPLATE_DIR}/cdi" echo "Download release templates from KubeVirt" vm_template_url="https://raw.githubusercontent.com/kubevirt/kubevirt" manifest_url="https://github.com/kubevirt/kubevirt/releases/download" - +cdi_manifest_url="https://github.com/kubevirt/containerized-data-importer/releases/download" if [ -z "${version}" ]; then version=$(git ls-remote --tags https://github.com/kubevirt/kubevirt | sed 's/.*refs\/tags\///g' | grep -v '\^{}') @@ -36,3 +37,24 @@ for item in ${version}; do wget -O "${KUBEVIRT_TEMPLATE_DIR}/${item}/kubevirt.yaml" "${manifest_url}/${item}/kubevirt.yaml" echo "Download for ${item} complete" done + +if [ -z "${cdi_version}" ]; then + cdi_version=$(git ls-remote --tags https://github.com/kubevirt/containerized-data-importer | sed 's/.*refs\/tags\///g' | grep -v '\^{}') +fi + +for item in ${cdi_version}; do + echo ${item} + echo "Downloading template for ${item}" + if [ ! -d "${item}" ]; then + mkdir "${CDI_TEMPLATE_DIR}/${item}" + fi + major=`echo ${item} | cut -dv -f2 | cut -d. -f1` + minor=`echo ${item} | cut -dv -f2 | cut -d. -f2` + patch=`echo ${item} | cut -dv -f2 | cut -d. -f3` + if [ "$major" -ge "1" ] && [ "$minor" -ge 2 ]; then + # We support j2 template since v1.2.0 + wget -O "${CDI_TEMPLATE_DIR}/${item}/cdi-controller.yaml.j2" "${cdi_manifest_url}/${item}/cdi-controller.yaml.j2" + fi + wget -O "${CDI_TEMPLATE_DIR}/${item}/cdi-controller.yaml" "${cdi_manifest_url}/${item}/cdi-controller.yaml" + echo "Download for ${item} complete" +done \ No newline at end of file