apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .Chart.Name }}
spec:
  template:
    metadata:
      labels:
        app: physim
    spec:
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
    {{- if .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      containers:
      - name: physim
        image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        securityContext:
          {{- toYaml .Values.securityContext | nindent 12 }}
        env:
        - name: OPENAIR_DIR
          value: /opt/oai-physim
        command: ["/bin/sh", "-c"]
        args:
        - >
          cmake_targets/autotests/run_exec_autotests.bash -g "nr_pbchsim.106rb" -d bin/ &&
          echo "FINISHED" && sleep infinity
      dnsPolicy: ClusterFirst
      restartPolicy: Never
      schedulerName: default-scheduler
      serviceAccountName: {{ .Values.global.serviceAccountName }}
      terminationGracePeriodSeconds: 30
      {{- if .Values.global.nodeSelector}}
      nodeSelector:
         {{- toYaml .Values.global.nodeSelector | nindent 12 }}
      {{- end }}
      {{- if .Values.global.nodeName.nrpbschsim106rb}}
      nodeName: {{ .Values.global.nodeName.nrpbschsim106rb }}
      {{- end }}
