Enable easy plugin loading (#859)
* Enable easy plugin loading customPluings have to be loaded into the main container somehow. Extend the existing cel plugin loader to allow users to easily specify an image to load it from. Signed-off-by: Kevin Fox <[email protected]> * Add some missing bits Signed-off-by: Kevin Fox <[email protected]> * Incorperate feedback Signed-off-by: Kevin Fox <[email protected]> * Fix formatting Signed-off-by: Kevin Fox <[email protected]> * Fix formatting Signed-off-by: Kevin Fox <[email protected]> --------- Signed-off-by: Kevin Fox <[email protected]>
This commit is contained in:
@@ -200,14 +200,20 @@ Take a copy of the config and merge in .Values.customPlugins and .Values.unsuppo
|
||||
*/}}
|
||||
{{- define "spire-lib.config_merge" }}
|
||||
{{- $pluginsToMerge := dict "plugins" dict }}
|
||||
{{- range $type, $val := .root.Values.customPlugins }}
|
||||
{{- if . }}
|
||||
{{- if eq $type "svidStore" }}
|
||||
{{- $_ := set $pluginsToMerge.plugins "SVIDStore" (deepCopy $val) }}
|
||||
{{- else }}
|
||||
{{- $nt := printf "%s%s" (substr 0 1 $type | upper) (substr 1 -1 $type) }}
|
||||
{{- $_ := set $pluginsToMerge.plugins $nt (deepCopy $val) }}
|
||||
{{- range $type, $instances := .root.Values.customPlugins }}
|
||||
{{- if $instances }}
|
||||
{{- $nt := (eq $type "svidStore") | ternary "SVIDStore" (printf "%s%s" (substr 0 1 $type | upper) (substr 1 -1 $type)) }}
|
||||
{{- $processedInstances := dict }}
|
||||
{{- range $instanceName, $config := $instances }}
|
||||
{{- $pluginData := deepCopy $config }}
|
||||
{{- $hasImage := hasKey $pluginData "image" }}
|
||||
{{- $_ := unset $pluginData "image" }}
|
||||
{{- if and $hasImage $pluginData.plugin_cmd }}
|
||||
{{- $_ := set $pluginData "plugin_cmd" (printf "/plugins/%s/%s" $type $instanceName) }}
|
||||
{{- end }}
|
||||
{{- $_ := set $processedInstances $instanceName $pluginData }}
|
||||
{{- end }}
|
||||
{{- $_ := set $pluginsToMerge.plugins $nt $processedInstances }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $type, $val := .root.Values.unsupportedBuiltInPlugins }}
|
||||
@@ -224,6 +230,22 @@ Take a copy of the config and merge in .Values.customPlugins and .Values.unsuppo
|
||||
{{- $newConfig | toYaml }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Find all customPlugins that specify an image, and build a list of binaries to copy into the plugin volume in the plugin loader.
|
||||
*/}}
|
||||
{{- define "spire-lib.extract_custom_plugin_images" }}
|
||||
{{- $pluginList := list }}
|
||||
{{- range $type, $instances := .Values.customPlugins }}
|
||||
{{- range $instanceName, $config := $instances }}
|
||||
{{- if $config.image }}
|
||||
{{- $entry := dict "plugin_cmd" $config.plugin_cmd "image" $config.image "name" (printf "%s/%s" $type $instanceName) }}
|
||||
{{- $pluginList = append $pluginList $entry }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $pluginList | toYaml }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Take a copy of the plugin section and return a yaml string based version
|
||||
reformatted from a dict of dicts to a dict of lists of dicts
|
||||
|
||||
Reference in New Issue
Block a user