Skip to main content

priv/templates/helm/configmap_files.yaml.eex

<%!--
  configmap_files — ConfigMap with arbitrary file payloads.

  For each entry in `@values`, the value is the basename of a file
  under `marea.d/configs/`; its raw contents are placed under the
  ConfigMap's `data:` block as a literal-block scalar (`|-`), keyed by
  the entry's key. Mount the ConfigMap as a volume to get one file per
  key on disk inside the pod (config snippets, nginx.conf, prom.yaml,
  …).

  Wiring (marea.yaml):

      releases:
        api:
          helm:
            template: configmap_files.yaml
            values:
              nginx.conf: nginx.conf        # <data key>: <file basename>
              prometheus.yml: prom.yml

  Assigns used: @name, @values, @config_files.
--%>
<%
  import Marea.Templates, only: [to_dashes: 1, indent: 2]
  files =
    for {key, file} <- @values do
      {key, Map.fetch!(@config_files, file)}
    end
%>
apiVersion: v1
kind: ConfigMap
metadata:
  name: <%= to_dashes(@name) %>
data:
  <%= for {key, data} <- files do %>
  <%= key %>: |-
<%= indent(data, 4) %>
<% end %>