# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

{{- if .Values.exampleDataLoader.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .Release.Name }}-example-data-loader
  namespace: {{ .Release.Namespace }}
spec:
  backoffLimit: 3
  template:
    metadata:
      name: {{ .Release.Name }}-example-data-loader
    spec:
      restartPolicy: Never
      containers:
        - name: example-data-loader
          image: {{ .Values.texera.imageRegistry }}/{{ .Values.exampleDataLoader.imageName }}:{{ .Values.texera.imageTag }}
          env:
            - name: TEXERA_EXAMPLE_USERNAME
              value: {{ .Values.exampleDataLoader.username }}
            - name: TEXERA_EXAMPLE_PASSWORD
              value: {{ .Values.exampleDataLoader.password }}
            - name: TEXERA_EXAMPLE_DATASET_DIR
              value: {{ .Values.exampleDataLoader.datasetDir }}
            - name: TEXERA_EXAMPLE_WORKFLOW_DIR
              value: {{ .Values.exampleDataLoader.workflowDir }}
            - name: TEXERA_WEB_APPLICATION_URL
              value: http://{{ .Values.webserver.name }}-svc:{{ .Values.webserver.service.port }}/api
            - name: TEXERA_FILE_SERVICE_URL
              value: http://{{ .Values.fileService.name }}-svc:{{ .Values.fileService.service.port }}/api
{{- end }}