#!/bin/bash 

PATH=/opt/wamblee/etcd/bin:$PATH

. /var/lib/wamblee/etcd/etcdimage
if [[ -z "$IMAGE" ]]
then
  echo "ETCD image cannot be determined" 1>&2
  exit 1
fi

echo "ETCD image: $IMAGE"

docker run --rm  \
  --network host \
  -v /etc/kubernetes/pki/etcd:/etc/kubernetes/pki/etcd \
  -v /var/lib/wamblee/etcd:/var/lib/wamblee/etcd \
  $IMAGE \
  etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/healthcheck-client.crt \
  --key=/etc/kubernetes/pki/etcd/healthcheck-client.key  "$@"