apiVersion: batch/v1
kind: Job
metadata:
  name: test
spec:
  template:
    spec:
      restartPolicy: Never
      initContainers:
      - name: k8psh
        image: 76eddge/k8psh
        imagePullPolicy: Never
        args: [ --install, /k8psh/bin/k8pshd ]
        env:
        - name: K8PSH_DEBUG # To debug, modify the Dockerfile to have cmake create a debug build
          value: 'Process, Main, Configuration'
        volumeMounts:
        - mountPath: /k8psh/bin
          name: k8psh-bin
      containers:
      - name: server
        image: alpine
        command: [ /bin/sh, -c, '/k8psh/bin/k8pshd --config=/workspace-server/test/config/k8s.conf --name=server --max-connections=3' ]
        env:
        - name: K8PSH_DEBUG # To debug, modify the Dockerfile to have cmake create a debug build
          value: 'Process, Main, Configuration'
        - name: K8PSH_TEST
          value: 'ServerTest'
        resources:
          requests:
            memory: 100Mi
            cpu: 100m
        volumeMounts:
        - mountPath: /workspace-server
          name: workspace
        - mountPath: /k8psh/bin
          name: k8psh-bin
          readOnly: true
      - name: client
        image: ubuntu
        tty: true
        command: [ /bin/sh, -c, 'BINDIR=$(mktemp -d); cd /workspace/test && k8pshd --executable-directory=$BINDIR && uname -a && printenv K8PSH_TEST && pwd && $BINDIR/uname -a && $BINDIR/printenv K8PSH_TEST && $BINDIR/pwd' ]
        env:
        - name: K8PSH_CONFIG
          value: /workspace/test/config/k8s.conf
        - name: K8PSH_DEBUG # To debug, modify the Dockerfile to have cmake create a debug build
          value: 'Process, Main, Configuration'
        - name: K8PSH_TEST
          value: 'ClientTest'
        - name: PATH
          value: '/bin:/usr/bin:/k8psh/bin'
        resources:
          requests:
            memory: 100Mi
            cpu: 100m
        volumeMounts:
        - mountPath: /workspace
          name: workspace
        - mountPath: /k8psh/bin
          name: k8psh-bin
          readOnly: true
      volumes:
      - name: k8psh-bin
        emptyDir:
          medium: Memory
      - name: workspace
        hostPath:
          path: "${GITHUB_WORKSPACE}"
          type: Directory
