'How do you add multiple config files to configMap with kustomize configMapGenerator by using a pattern/regex/...?

Currently I do this:

configMapGenerator:
  - name: sql-config-map
    files:
      - "someDirectory/one.sql"
      - "someDirectory/two.sql"
      - "someDirectory/three.sql"

and I would like to do sth. like this:

configMapGenerator:
  - name: sql-config-map
    files:
      - "someDirectory/*.sql"

Is this somehow possible?



Solution 1:[1]

Nope.

See discussion around that feature in comment on "configMapGenerator should allow directories as input"

The main reason:

To move towards explicit dependency declaration, we're moving away from allowing globs in the kustomization file

Solution 2:[2]

This command works fine and will edit your kustomization.yaml:

kustomize edit add configmap my-configmap --from-file="$PWD/my-files/*"

The my-files directory has to be in the same folder that the kustomization.yaml file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jonas
Solution 2 Fabrice Jammes