apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

## global namespace must be set due to:
## https://github.com/kubernetes-sigs/kustomize/issues/1301#issuecomment-1308228710
namespace: kubeflow

resources:
  ## upstream
  - upstream/apps/jupyter/jupyter-web-app/upstream/overlays/istio

patchesStrategicMerge:
  - patches/patch-jupyter-web-app-authorizationpolicy.yaml
  {{<- if .Values.kubeflow_tools.notebooks.notebookTemplate >}}
  - patches/patch-jupyter-web-app-deployment.yaml
  {{<- end >}}
  - patches/patch-jupyter-web-app-virtualservice.yaml

configMapGenerator:
  - name: parameters
    behavior: merge
    literals:
      - JWA_UI="default"
      - JWA_PREFIX="/jupyter"
      - JWA_CLUSTER_DOMAIN="cluster.local"
      - JWA_USERID_HEADER="kubeflow-userid"
      - JWA_USERID_PREFIX=""
      - JWA_APP_SECURE_COOKIES="true"

  ## this is used to overwrite the default `spawner_ui_config.yaml` with our custom one
  - name: config
    behavior: merge
    files:
      - files/spawner_ui_config.yaml

  ## this is used to overwrite the placeholder logos with the actual logos for each tool
  - name: logos
    behavior: merge
    files:
      ## VSCode
      - files/logos/group-one-icon.svg
      - files/logos/group-one-logo.svg
      ## RStudio Server
      - files/logos/group-two-icon.svg
      - files/logos/group-two-logo.svg
      ## JupyterLab
      - files/logos/jupyter-icon.svg
      - files/logos/jupyter-logo.svg

  {{<- if .Values.kubeflow_tools.notebooks.notebookTemplate >}}
  {{<- "\n" >}}
  ## this is used to overwrite the default `notebook_template.yaml` with our custom one
  - name: notebook-template
    files:
      - files/notebook_template.yaml
  {{<- end >}}

images:
  - name: docker.io/kubeflownotebookswg/jupyter-web-app
    newName: {{< .Values.kubeflow_tools.notebooks.images.jupyterWebApp.repository | quote >}}
    {{<- if .Values.kubeflow_tools.notebooks.images.jupyterWebApp.tag >}}
    newTag: {{< .Values.kubeflow_tools.notebooks.images.jupyterWebApp.tag | quote >}}
    {{<- end >}}