Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 "") -}}
Expand Down Expand Up @@ -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 }}
17 changes: 14 additions & 3 deletions charts/templates/configmap-adapter-task.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@


{{- if .Values.adapterTaskConfig.create }}
{{- include "hyperfleet-adapter.validateTaskConfigKeys" . }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -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 }}
23 changes: 18 additions & 5 deletions charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name>.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:
Expand Down