{{<- define "kubeflow-pipelines.viewer-pod-template.yaml" ->}}
## NOTE: we define the 'viewer-pod-template' file as YAML and then convert it to JSON
spec:
  serviceAccountName: default-editor
  containers:
    - env:
        - name: AWS_REGION
          value: {{< .Values.kubeflow_tools.pipelines.bucket.region | quote >}}
        - name: S3_ENDPOINT
          ## NOTE: this sets `boto3.client('s3', endpoint_url=XXXX)`, so needs to be the full URL
          value: {{< (tmpl.Exec "kubeflow_pipelines.object_store.endpoint_url" .) | quote >}}
        - name: AWS_ACCESS_KEY_ID
          {{<- if .Values.kubeflow_tools.pipelines.objectStore.auth.fromEnv >}}
          value: ""
          {{<- else >}}
          valueFrom:
            secretKeyRef:
              name: {{< (tmpl.Exec "kubeflow_pipelines.object_store.auth.secret_name" .) | quote >}}
              key: {{< (tmpl.Exec "kubeflow_pipelines.object_store.auth.access_key_key" .) | quote >}}
          {{<- end >}}
        - name: AWS_SECRET_ACCESS_KEY
          {{<- if .Values.kubeflow_tools.pipelines.objectStore.auth.fromEnv >}}
          value: ""
          {{<- else >}}
          valueFrom:
            secretKeyRef:
              name: {{< (tmpl.Exec "kubeflow_pipelines.object_store.auth.secret_name" .) | quote >}}
              key: {{< (tmpl.Exec "kubeflow_pipelines.object_store.auth.secret_key_key" .) | quote >}}
          {{<- end >}}
{{<- end ->}}
{{< tmpl.Exec "kubeflow-pipelines.viewer-pod-template.yaml" . | yaml | toJSONPretty "  " >}}