{{- $app := .Values.vmsingle }}
{{- if $app.enabled }}
{{- if or .Values.vmdistributed.enabled .Values.vmcluster.enabled }}
  {{- fail "Only one of .Values.vmsingle.enabled, .Values.vmdistributed.enabled and .Values.vmcluster.enabled can be true" }}
{{- end }}
{{- $ctx := dict "helm" . "appKey" (list "vmsingle" "spec") }}
{{- $fullname := include "vm.cr.fullname" $ctx }}
{{- $ns := include "vm.namespace" $ctx }}
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMSingle
metadata:
  {{- with $app.annotations }}
  annotations: {{ toYaml . | nindent 4 }}
  {{- end  }}
  name: {{ $fullname }}
  namespace: {{ $ns }}
  {{- $_ := set $ctx "style" "managed" }}
  {{- $_ := set $ctx "extraLabels" ($app.labels | default dict) }}
  labels: {{ include "vm.labels" $ctx | nindent 4 }}
  {{- $_ := unset $ctx "extraLabels" }}
spec: {{ include "vm.single.spec" $ctx | nindent 2 }}
{{- end }}
