<p>So I have a mariadb subchart. The mariadb charts fills a config map from diffrent init files with:</p>

<pre><code>{{ (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|sql|sql.gz]").AsConfig | indent 2 }}
</code></pre>

<p>So is there anyway I can inject the init files ?</p>

<p>Is it possible to overwrite the context of <code>.Files.Glob</code> so it access my parent directory ? or is there another recommended way to create initial sql files ?</p>

<p>the maridb subchart is implented like this in the <code>requirements.yaml</code>:</p>

<pre><code>dependencies:
- name: mariadb
  version: 5.x.x
  repository: https://kubernetes-charts.storage.googleapis.com/
  condition: mariadb.enabled
</code></pre>

<p>Since your mariadb is a subchart managed by third party, <code>.Files.Glob</code> refers only to files inside mariadb directory. </p>

<p>If you want to place any startup scripts inside subchart, you have to unarchive it.</p>

<p>Let's say you have <strong>custom-init-scripts</strong> directory with all init scripts in your parent chart.</p>

<pre><code>$ ls custom-init-scripts/
init.sh  insert.sql

# download mariadb chart package in charts directory
$ helm dependency update

# unarchive and delete package
$ tar -xvf charts/mariadb-5.*.tgz -C charts &amp;&amp; rm charts/mariadb-5.*.tgz

# copy init scripts to mariadb subchart
$ cp -a custom-init-scripts/. charts/mariadb/files/docker-entrypoint-initdb.d/
</code></pre>

<p>Now your init files are present in mariadb subchart</p>

<pre><code>helm install --debug --dry-run --set mariadb.enabled=true .

...
---
# Source: mychart/charts/mariadb/templates/initialization-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: elevated-dragonfly-mariadb-master-init-scripts
  labels:
    app: mariadb
    component: "master"
    chart: mariadb-5.2.5
    release: "elevated-dragonfly"
    heritage: "Tiller"
binaryData:
data:
  init.sh: "echo \"hi\"\r\n"
  insert.sql: INSERT INT Users (FirstName, LastName) VALUES ('A', 'B');
</code></pre>
