|
| 1 | +{{/* |
| 2 | +Template for checking configuration |
| 3 | +
|
| 4 | +The messages templated here will be combined into a single `fail` call. |
| 5 | +
|
| 6 | +Message format: |
| 7 | +
|
| 8 | +``` |
| 9 | +checker: |
| 10 | + MESSAGE |
| 11 | +``` |
| 12 | +*/}} |
| 13 | +{{/* |
| 14 | +Compile all warnings into a single message, and call fail. |
| 15 | +
|
| 16 | +Due to gotpl scoping, we can't make use of `range`, so we have to add action lines. |
| 17 | +*/}} |
| 18 | +{{- define "checkConfig" -}} |
| 19 | +{{- $messages := list -}} |
| 20 | +{{/* add templates here */}} |
| 21 | +
|
| 22 | +{{- $messages = append $messages (include "checkNamespace" .) -}} |
| 23 | +{{- $messages = append $messages (include "checkSecret" .) -}} |
| 24 | +{{- $messages = append $messages (include "checkName" .) -}} |
| 25 | +{{- $messages = append $messages (include "checkContainerSelector" .) -}} |
| 26 | +{{- $messages = append $messages (include "checkDeploymentName" .) -}} |
| 27 | +{{- $messages = append $messages (include "checkInitContainerImage" .) -}} |
| 28 | +{{- $messages = append $messages (include "checkServerHostname" .) -}} |
| 29 | +
|
| 30 | +
|
| 31 | +{{- /* prepare output */}} |
| 32 | +{{- $messages = without $messages "" -}} |
| 33 | +{{- $message := join "\n" $messages -}} |
| 34 | +
|
| 35 | +{{- /* print output */}} |
| 36 | +{{- if $message -}} |
| 37 | +{{- printf "\nCONFIGURATION CHECKS:\n%s" $message | fail -}} |
| 38 | +{{- end -}} |
| 39 | +{{- end -}} |
| 40 | +
|
| 41 | +
|
| 42 | +{{- define "checkContainerSelector" -}} |
| 43 | +{{- range .Values.javaAgents }} |
| 44 | +{{- if not .containerSelector }} |
| 45 | +{{- printf "containerSelector Checker:\nError: The 'containerSelector' field is missing in %s java agent object. Please specify a 'containerSelector' paramter.\n" .name }} |
| 46 | +{{- end }} |
| 47 | +{{- end }} |
| 48 | +{{- end -}} |
| 49 | +
|
| 50 | +{{- define "checkDeploymentName" -}} |
| 51 | +{{- range .Values.javaAgents }} |
| 52 | +{{- if not .deploymentName }} |
| 53 | +{{- printf "deploymentName Checker:\nError: The 'deploymentName' field is missing in %s java agent object. Please specify a 'deploymentName' paramter.\n" .name }} |
| 54 | +{{- end }} |
| 55 | +{{- end }} |
| 56 | +{{- end -}} |
| 57 | +
|
| 58 | +{{- define "checkInitContainerImage" -}} |
| 59 | +{{- range .Values.javaAgents }} |
| 60 | +{{- if not .initContainer.image }} |
| 61 | +{{- printf "initContainerImage Checker:\nError: The 'initContainer.image' field is missing in %s java agent object. Please specify a 'initContainer.image' parameter.\n" .name }} |
| 62 | +{{- end }} |
| 63 | +{{- end }} |
| 64 | +{{- end -}} |
| 65 | +
|
| 66 | +{{- define "checkName" -}} |
| 67 | +{{- range .Values.javaAgents }} |
| 68 | +{{- if not .name }} |
| 69 | +{{- printf "Name Checker:\nError: The '.name' field is missing in %s java agent object. Please specify a '.name' parameter.\n" .name }} |
| 70 | +{{- end }} |
| 71 | +{{- end }} |
| 72 | +{{- end -}} |
| 73 | +
|
| 74 | +{{- define "checkServerHostname" -}} |
| 75 | +{{- range .Values.javaAgents }} |
| 76 | +{{- if not .serverHostname }} |
| 77 | +{{- printf "serverHostname Checker:\nError: The '.serverHostname' field is missing in %s java agent object. Please specify a '.serverHostname' parameter.\n" .name }} |
| 78 | +{{- end }} |
| 79 | +{{- end }} |
| 80 | +{{- end -}} |
| 81 | +
|
| 82 | +{{- define "checkNamespace" -}} |
| 83 | +{{- range .Values.javaAgents }} |
| 84 | +{{- if not .namespace }} |
| 85 | +{{- printf "Namespace Checker:\nError: The 'namespace' field is missing in %s java agent object. Please specify a namespace.\n" .name }} |
| 86 | +{{- end }} |
| 87 | +{{- end }} |
| 88 | +{{- end -}} |
| 89 | +
|
| 90 | +{{- define "checkSecret" -}} |
| 91 | +{{- range .Values.javaAgents }} |
| 92 | +{{- if and .agentPoolCredentials.existingSecret .agentPoolCredentials.apiKey .agentPoolCredentials.pinnedCertHash }} |
| 93 | +{{- printf "Secret Checker:\nError: both '.agentPoolCredentials.existingSecret' field and '.agentPoolCredentials.apiKey' '.agentPoolCredentials.pinnedCertHash' are provided in %s java agent object. Please choose either existingSecret or apiKey and pinnedCertHash.\n" .name }} |
| 94 | +{{- end }} |
| 95 | +{{- end }} |
| 96 | +{{- end -}} |
| 97 | +
|
| 98 | +
|
0 commit comments