{{- if eq true .Values.firefoxDebug.enabled -}}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template "selenium.firefoxDebug.fullname" . }}
  labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
  replicas: {{ .Values.firefoxDebug.replicas }}
  template:
    metadata:
      labels:
        app: {{ template "selenium.firefoxDebug.fullname" . }}
        chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
        release: "{{ .Release.Name }}"
        heritage: "{{ .Release.Service }}"
      annotations: 
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.firefoxDebug.image }}:{{ .Values.firefoxDebug.tag }}"
          imagePullPolicy: {{ .Values.firefoxDebug.pullPolicy }}
          ports:
            {{- if .Values.firefoxDebug.jmxPort }}
            - containerPort: {{ .Values.firefoxDebug.jmxPort }}
              name: jmx
              protocol: TCP
            {{- end }}
            - containerPort: 5900 
              name: vnc
          env:
            - name: HUB_PORT_4444_TCP_ADDR
              value: {{ template "selenium.hub.fullname" . }}
            - name: HUB_PORT_4444_TCP_PORT
              value: {{ .Values.hub.port | quote }}
            - name: JAVA_TOOL_OPTIONS
              value: {{ default "" .Values.firefoxDebug.javaOpts | quote }}
            - name: SE_OPTS
              value: {{ default "" .Values.firefoxDebug.seOpts | quote }}
            {{- if .Values.firefoxDebug.firefoxVersion }}
            - name: FIREFOX_VERSION
              value: {{ .Values.firefoxDebug.firefoxVersion | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.nodeMaxInstances }}
            - name: NODE_MAX_INSTANCES
              value: {{ .Values.firefoxDebug.nodeMaxInstances | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.nodeMaxSession }}
            - name: NODE_MAX_SESSION
              value: {{ .Values.firefoxDebug.nodeMaxSession | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.nodeRegisterCycle }}
            - name: NODE_REGISTER_CYCLE
              value: {{ .Values.firefoxDebug.nodeRegisterCycle | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.nodePort }}
            - name: NODE_PORT
              value: {{ .Values.firefoxDebug.nodePort | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.screenWidth }}
            - name: SCREEN_WIDTH
              value: {{ .Values.firefoxDebug.screenWidth | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.screenHeight }}
            - name: SCREEN_HEIGHT
              value: {{ .Values.firefoxDebug.screenHeight | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.screenDepth }}
            - name: SCREEN_DEPTH
              value: {{ .Values.firefoxDebug.screenDepth | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.display }}
            - name: DISPLAY
              value: {{ .Values.firefoxDebug.display | quote }}
            {{- end }}
            {{- if .Values.firefoxDebug.timeZone }}
            - name: TZ
              value: {{ .Values.firefoxDebug.timeZone | quote }}
            {{- end }}
          resources:
{{ toYaml .Values.firefoxDebug.resources | indent 12 }}
      nodeSelector:
{{- if .Values.firefoxDebug.nodeSelector }}
{{ toYaml .Values.firefoxDebug.nodeSelector | indent 8  }}
{{- else if .Values.global.nodeSelector }}
{{ toYaml .Values.global.nodeSelector | indent 8  }}
{{- end }}
{{- end -}}
