diff --git a/charts/templates/_helpers.tpl b/charts/templates/_helpers.tpl index 114251a..1cc6111 100644 --- a/charts/templates/_helpers.tpl +++ b/charts/templates/_helpers.tpl @@ -137,10 +137,14 @@ true {{- if .Values.adapterTaskConfig.create -}} {{- $hasYaml := not (empty .Values.adapterTaskConfig.yaml) -}} {{- $hasFiles := not (empty .Values.adapterTaskConfig.files) -}} - {{- if or $hasYaml $hasFiles -}} + {{- $hasExternal := not (empty .Values.adapterTaskConfig.external) -}} + {{- if and $hasYaml (or $hasFiles $hasExternal) -}} +{{- fail "Cannot set .Values.adapterTaskConfig.yaml with .Values.adapterTaskConfig.files or .Values.adapterTaskConfig.external - these modes are mutually exclusive." -}} + {{- end -}} + {{- if or $hasYaml $hasFiles $hasExternal -}} true {{- else -}} -{{- fail "When .Values.adapterTaskConfig.create is true, either .Values.adapterTaskConfig.yaml or .Values.adapterTaskConfig.files must be provided." -}} +{{- fail "When .Values.adapterTaskConfig.create is true, at least one of .Values.adapterTaskConfig.yaml, .Values.adapterTaskConfig.files, or .Values.adapterTaskConfig.external must be provided." -}} {{- end -}} {{- else if (hasKey .Values.adapterTaskConfig "configMapName") -}} {{- if and .Values.adapterTaskConfig.configMapName (ne .Values.adapterTaskConfig.configMapName "") -}} @@ -296,3 +300,27 @@ googlepubsub rabbitmq {{- end -}} {{- end }} + + +{{/* +Validate no key collisions between adapterTaskConfig.external and adapterTaskConfig.files +Also validate that all file paths in adapterTaskConfig.files actually exist +*/}} +{{- define "hyperfleet-adapter.validateTaskConfigKeys" -}} +{{- if and .Values.adapterTaskConfig.external .Values.adapterTaskConfig.files }} + {{- range $name, $value := .Values.adapterTaskConfig.external }} + {{- $externalKey := printf "%s.yaml" $name }} + {{- if hasKey $.Values.adapterTaskConfig.files $externalKey }} + {{- fail (printf "ConfigMap key collision: '%s' exists in both adapterTaskConfig.external and adapterTaskConfig.files" $externalKey) }} + {{- end }} + {{- end }} +{{- end }} +{{- if .Values.adapterTaskConfig.files }} + {{- range $key, $path := .Values.adapterTaskConfig.files }} + {{- $content := $.Files.Get $path }} + {{- if not $content }} + {{- fail (printf "adapterTaskConfig.files.%s: file not found or empty at path '%s'" $key $path) }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/templates/configmap-adapter-task.yaml b/charts/templates/configmap-adapter-task.yaml index 0355679..31bdf67 100644 --- a/charts/templates/configmap-adapter-task.yaml +++ b/charts/templates/configmap-adapter-task.yaml @@ -1,4 +1,7 @@ + + {{- if .Values.adapterTaskConfig.create }} +{{- include "hyperfleet-adapter.validateTaskConfigKeys" . }} apiVersion: v1 kind: ConfigMap metadata: @@ -16,9 +19,17 @@ data: {{ toYaml .Values.adapterTaskConfig.yaml | nindent 4 }} {{- end }} {{- else }} - {{- range $key, $path := .Values.adapterTaskConfig.files }} + {{- if .Values.adapterTaskConfig.external }} + {{- range $name, $value := .Values.adapterTaskConfig.external }} + {{ $name }}.yaml: | +{{ $value | nindent 4 }} + {{- end }} + {{- end }} + {{- if .Values.adapterTaskConfig.files }} + {{- range $key, $path := .Values.adapterTaskConfig.files }} {{ $key }}: | - {{ $.Files.Get $path | nindent 4 }} - {{- end }} +{{ $.Files.Get $path | nindent 4 }} + {{- end }} + {{- end }} {{- end }} {{- end }} diff --git a/charts/values.yaml b/charts/values.yaml index 0da8ba2..c165ace 100644 --- a/charts/values.yaml +++ b/charts/values.yaml @@ -32,21 +32,34 @@ adapterConfig: level: info # AdapterTaskConfig (business logic) can be created: # - option1: from an existing ConfigMap by setting configMapName -# - option2: from a YAML file by setting yaml -# - option3: from a set of files by setting files +# - option2: from inline YAML by setting yaml (mutually exclusive with files/external) +# - option3: from chart-packaged files by setting files (can be combined with external) +# - option4: from external content by setting external (can be combined with files) adapterTaskConfig: create: true # option1: ConfigMap name (if different from default, and set create: false) #configMapName: "" # option2: AdapterTaskConfig YAML (creates task-config.yaml key in ConfigMap) + # Mutually exclusive with files and external # yaml: - # params: [] - # resources: [] + # params: [] + # resources: [] # option3: AdapterTaskConfig YAML files packaged with the chart + # Files are loaded from the chart directory via $.Files.Get + # Can be combined with external for site-specific overrides # files: - # task-config.yaml: examples/kubernetes/adapter-task-config.yaml + # task-config.yaml: examples/kubernetes/adapter-task-config.yaml + + # option4: External content passed in (e.g., via --set-file) + # Creates ConfigMap keys as .yaml with the provided content + # Can be combined with files (collision detection enforced) + # external: + # myconfig: | + # params: [] + # resources: [] + # Or use: --set-file adapterTaskConfig.external.myconfig=/path/to/config.yaml affinity: {} # Override default args args: