#!/bin/sh -e

# Install software dependencies
if [ -f /etc/alpine-release ]; then
  apk add docker-cli-buildx uuidgen
fi

# Generate image tag file
IMAGE_TAG_FILE="${MOLECULE_EPHEMERAL_DIRECTORY}/image"
echo "ttl.sh/$(uuidgen | tr '[:upper:]' '[:lower:]'):1d" > ${IMAGE_TAG_FILE}

# Build operator image
docker buildx build --platform linux/amd64 --tag $(cat ${IMAGE_TAG_FILE}) --push .

# Install OpenStack SDK
pip install \
  --extra-index-url https://vexxhost.github.io/wheels/alpine-3.15/ \
  netaddr \
  'openstacksdk<0.99.0'
