#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

---
kind: Job
apiVersion: batch/v1
metadata:
  name: issuer-vcs-add-profiles
  labels:
    component: issuer-vcs
    group: services
spec:
  template:
    spec:
      volumes:
        - name: script
          configMap:
            name: issuer-vcs-add-profiles-script
      restartPolicy: Never
      initContainers:
#        - name: wait
#          image: busybox
#          imagePullPolicy: IfNotPresent
#          command: ["sh"]
#          args: ["-c", "sleep 5"]
        - name: healthcheck-ready
          image: busybox
          imagePullPolicy: IfNotPresent
          command: ["/bin/sh"]
          args:
            - "-c"
            - |
              while [[ "$(wget -T 5 -S --spider http://issuer-vcs/healthcheck 2>&1 | grep '200 OK')" == "" ]];
              do echo "waiting for endpoint";
              sleep 5;
              done;
      containers:
      - name: issuer-vcs-add-profiles
        image: "alpine:latest"
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh"]
        args: ["/opt/vcs_issuer_configure.sh"]
        volumeMounts:
          - name: script
            mountPath: /opt
