{{- if and (not (eq .Values.mode "daemonset")) (not (eq .Values.mode "deployment")) (not (eq .Values.mode "statefulset")) }}
{{ fail "[ERROR] 'mode' must be set. See https://github.com/open-telemetry/opentelemetry-helm-charts/blob/main/charts/opentelemetry-collector/UPGRADING.md for instructions." }}
{{ end }}

{{- if and (eq .Values.dnsPolicy "None") (not .Values.dnsConfig) }}
{{- fail "[ERROR] dnsConfig should be provided when dnsPolicy is None" }}
{{ end }}

{{- if .Values.presets.clusterMetrics.enabled }}
{{- if eq .Values.mode "daemonset"}}
{{- fail "Cluster Metrics preset is not suitable for daemonset mode. Please use statefulset or deployment mode with replicaCount: 1"}}
{{ end }}
{{- if gt (int .Values.replicaCount) 1 }}
{{- fail "Cluster Metrics preset is not suitable for replicaCount greater than one. Please change replica count to one." }}
{{ end }}
{{ end }}

{{- if not .Values.configMap.create }}
[WARNING] "configMap" wil not be created and "config" will not take effect.
{{ end }}

{{- if not .Values.resources }}
[WARNING] No resource limits or requests were set. Consider setter resource requests and limits for your collector(s) via the `resources` field.
{{ end }}

{{- if and (eq .Values.mode "daemonset") (eq .Values.service.internalTrafficPolicy "Cluster") }}
[WARNING] Setting internalTrafficPolicy to 'Cluster' on Daemonset is not recommended. Consider using 'Local' instead.
{{ end }}

{{- if and (.Values.useGOMEMLIMIT) (not ((((.Values.resources).limits).memory))) }}
[WARNING] "useGOMEMLIMIT" is enabled but memory limits have not been supplied, which means no GOMEMLIMIT env var was configured but the Memory Ballast Extension was removed. It is highly recommended to only use "useGOMEMLIMIT" when memory limits have been set.
{{ end }}

{{- if .Values.configMap.create }}
{{- range $key, $value := (((.Values.config).service).pipelines) }}
{{- if has "logging" ($value.exporters) }}
[WARNING] The logging exporter is deprecated.  Use the debug exporter instead.
{{- end }}
{{- end }}
{{- end }}
