Skip to content

Commit

Permalink
add download-templates for cdi jinjia2 (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiyang Wang authored and Ryan Hallisey committed Oct 1, 2018
1 parent 9d6352c commit 2799a44
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA
.idea/
*.iml
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
24 changes: 23 additions & 1 deletion download-templates.sh
Original file line number Diff line number Diff line change
@@ -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 '\^{}')
Expand Down Expand Up @@ -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

0 comments on commit 2799a44

Please sign in to comment.