{{- if and .Values.driver.nvidiaDriverCRD.enabled .Values.driver.nvidiaDriverCRD.deployDefaultCR }}
apiVersion: nvidia.com/v1alpha1
kind: NVIDIADriver
metadata:
  name: default
spec:
  repository: {{ .Values.driver.repository }}
  image: {{ .Values.driver.image }}
  version: {{ .Values.driver.version }}
  kernelModuleType: {{ .Values.driver.kernelModuleType }}
  usePrecompiled: {{ .Values.driver.usePrecompiled }}
  driverType: {{ .Values.driver.nvidiaDriverCRD.driverType | default "gpu" }}
  {{- if .Values.daemonsets.annotations }}
  annotations: {{ toYaml .Values.daemonsets.annotations | nindent 6 }}
  {{- end }}
  {{- if .Values.daemonsets.labels }}
  labels: {{ toYaml .Values.daemonsets.labels | nindent 6 }}
  {{- end }}
  {{- if .Values.driver.nvidiaDriverCRD.nodeSelector }}
  nodeSelector: {{ toYaml .Values.driver.nvidiaDriverCRD.nodeSelector | nindent 6 }}
  {{- end }}
  {{- if .Values.driver.imagePullSecrets }}
  imagePullSecrets: {{ toYaml .Values.driver.imagePullSecrets | nindent 4 }}
  {{- end }}
  {{- if .Values.driver.manager }}
  manager: {{ toYaml .Values.driver.manager | nindent 4 }}
  {{- end }}
  {{- if .Values.driver.startupProbe }}
  startupProbe: {{ toYaml .Values.driver.startupProbe | nindent 4 }}
  {{- end }}
  {{- if .Values.driver.livenessProbe }}
  livenessProbe: {{ toYaml .Values.driver.livenessProbe | nindent 4 }}
  {{- end }}
  {{- if .Values.driver.readinessProbe }}
  readinessProbe: {{ toYaml .Values.driver.readinessProbe | nindent 4 }}
  {{- end }}
  rdma:
    enabled: {{ .Values.driver.rdma.enabled }}
    useHostMofed: {{ .Values.driver.rdma.useHostMofed }}
  {{- if .Values.daemonsets.tolerations }}
  tolerations: {{ toYaml .Values.daemonsets.tolerations | nindent 6 }}
  {{- end }}
  {{- if .Values.driver.repoConfig.configMapName }}
  repoConfig:
    name: {{ .Values.driver.repoConfig.configMapName }}
  {{- end }}
  {{- if .Values.driver.certConfig.name }}
  certConfig:
    name: {{ .Values.driver.certConfig.name }}
  {{- end }}
  {{- if .Values.driver.licensingConfig.configMapName }}
  licensingConfig:
    name: {{ .Values.driver.licensingConfig.configMapName }}
    nlsEnabled: {{ .Values.driver.licensingConfig.nlsEnabled | default true }}
  {{- end }}
  {{- if .Values.driver.virtualTopology.config }}
  virtualTopologyConfig:
    name: {{ .Values.driver.virtualTopology.config }}
  {{- end }}
  {{- if .Values.driver.kernelModuleConfig.name }}
  kernelModuleConfig:
    name: {{ .Values.driver.kernelModuleConfig.name }}
  {{- end }}
  {{- if .Values.driver.resources }}
  resources: {{ toYaml .Values.driver.resources | nindent 6 }}
  {{- end }}
  {{- if .Values.driver.env }}
  env: {{ toYaml .Values.driver.env | nindent 6 }}
  {{- end }}
  {{- if .Values.driver.args }}
  args: {{ toYaml .Values.driver.args | nindent 6 }}
  {{- end }}
  {{- if .Values.gds.enabled }}
  gds:
    enabled: {{ .Values.gds.enabled }}
    {{- if .Values.gds.repository }}
    repository: {{ .Values.gds.repository }}
    {{- end }}
    {{- if .Values.gds.image }}
    image: {{ .Values.gds.image }}
    {{- end }}
    version: {{ .Values.gds.version | quote }}
    {{- if .Values.gds.imagePullPolicy }}
    imagePullPolicy: {{ .Values.gds.imagePullPolicy }}
    {{- end }}
    {{- if .Values.gds.imagePullSecrets }}
    imagePullSecrets: {{ toYaml .Values.gds.imagePullSecrets | nindent 8 }}
    {{- end }}
    {{- if .Values.gds.env }}
    env: {{ toYaml .Values.gds.env | nindent 6 }}
    {{- end }}
    {{- if .Values.gds.args }}
    args: {{ toYaml .Values.gds.args | nindent 6 }}
    {{- end }}
  {{- end }}
  {{- if .Values.gdrcopy }}
  gdrcopy:
    enabled: {{ .Values.gdrcopy.enabled | default false  }}
    {{- if .Values.gdrcopy.repository }}
    repository: {{ .Values.gdrcopy.repository }}
    {{- end }}
    {{- if .Values.gdrcopy.image }}
    image: {{ .Values.gdrcopy.image }}
    {{- end }}
    version: {{ .Values.gdrcopy.version | quote }}
    {{- if .Values.gdrcopy.imagePullPolicy }}
    imagePullPolicy: {{ .Values.gdrcopy.imagePullPolicy }}
    {{- end }}
    {{- if .Values.gdrcopy.imagePullSecrets }}
    imagePullSecrets: {{ toYaml .Values.gdrcopy.imagePullSecrets | nindent 8 }}
    {{- end }}
    {{- if .Values.gdrcopy.env }}
    env: {{ toYaml .Values.gdrcopy.env | nindent 6 }}
    {{- end }}
    {{- if .Values.gdrcopy.args }}
    args: {{ toYaml .Values.gdrcopy.args | nindent 6 }}
    {{- end  }}
  {{- end }}
{{- end }}
