---
apiVersion: v1
kind: ConfigMap
metadata:
  name: updater-script
  namespace: spack
  labels:
    svc: updater
data:
  script: |
    #! /bin/sh -e
    date
    echo

    wget -O -                                                            \
        "https://dl.k8s.io/v1.15.0/kubernetes-client-linux-amd64.tar.gz" \
            | tar xzf -                                                  \

    set +e
    result=0
    for dep in spack-packages spack-io cdash ; do
        echo "ROLLOUT deployments/$dep" \
        && kubernetes/client/bin/kubectl rollout restart -n spack \
            deployments/$dep
        return_code="$?"

        if [ "$result" '=' '0' ] ; then
            result="$return_code"
        fi
    done

    exit $result
