{{ if .Values.database.credentials.secretName }} apiVersion: v1 kind: Pod metadata: name: "{{ include "common.names.fullname" . }}-db-connectivity-test" annotations: "helm.sh/hook": test "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded" {{- if not .Values.testPods.annotations }} {{- include "bamboo.podAnnotations" . | nindent 4 }} {{- else }} {{- range $key, $value := .Values.testPods.annotations }} {{ $key | quote }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} labels: {{- if not .Values.testPods.labels }} {{- include "common.labels.commonLabels" . | nindent 4 }} {{- else }} {{- range $key, $value := .Values.testPods.labels }} {{ $key | quote }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} spec: serviceAccountName: {{ include "bamboo.serviceAccountName" . }} containers: - name: test image: {{ include "bamboo.image" . | quote }} imagePullPolicy: IfNotPresent env: - name: JDBC_DRIVER value: {{ .Values.database.driver | quote }} - name: JDBC_URL value: {{ .Values.database.url | quote }} - name: JDBC_USER valueFrom: secretKeyRef: name: {{ .Values.database.credentials.secretName }} key: {{ .Values.database.credentials.usernameSecretKey }} - name: JDBC_PASSWORD valueFrom: secretKeyRef: name: {{ .Values.database.credentials.secretName }} key: {{ .Values.database.credentials.passwordSecretKey }} - name: CLASSPATH value: "/opt/atlassian/bamboo/lib/*" command: - /bin/bash - -ec - | cat < output.txt var jdbcUrl = System.getenv("JDBC_URL"); var jdbcUsername = System.getenv("JDBC_USER"); var jdbcPassword = System.getenv("JDBC_PASSWORD"); System.out.println("Establishing connection to " + jdbcUrl); try (var c = java.sql.DriverManager.getConnection(jdbcUrl, jdbcUsername, jdbcPassword)) { System.out.println("Connection established OK, " + c.getClass()); } EOF cat output.txt grep -q "Connection established OK" output.txt {{- with .Values.testPods.resources }} resources: {{- toYaml . | nindent 8 }} {{- end }} restartPolicy: Never {{- with .Values.testPods.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.testPods.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.testPods.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} {{- if .Values.testPods.schedulerName }} schedulerName: {{ .Values.testPods.schedulerName | quote }} {{- end }} {{ end }}