Helmize
GitHub Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto mode Back to homepage

Identifiers

Example https://github.com/buttahtoast/helmize/tree/main/examples/example-identifiers

Identifiers are used to identify a file or a partial file. Based on identifiers files are merged together. File Configurations may influence the behavior. The subpath is not relevant in the identifier evaluation.

Predefined

Regardless if you are using the default identifier template or your own. If the template returns an empty ID the file name where the resource originate from is used. Should there be multiple resources in that file which don’t evaluate dedicated identifiers, they are both assigned the same identifier (filename) and therefor merged.

Custom IDs are always used. If a manifest has the field kind and metadata.name it’s combined to {kind}-{metadata.name}.yaml which is added as identifier. If no custom IDs are set or those two data fields, the filename is used. The current template for identifiert evaluation can be found here:

You can change the identifier template

Reference

The identifier template which should be used is defined in the helmize configuration

Outcomes

Here are different outcomes for identifiers.


Kind and Name

In this example the kind and metadata.name are set.

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
data:
  game.properties: |
    enemy:
      types:
      - alien
      - monsters
    player:
      maximumLives:5

Results in the following IDs:

  • configmap-my-configmap.yaml

Outcome with multiple YAMLs in one file

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
data:
  game.properties: |
    enemy:
      types:
      - alien
      - monsters
    player:
      maximumLives:5
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap2
data:
  game.properties: |
    enemy:
      types:
      - imps
      - warriors
    player:
      maximumLives:10

Results in two dedicated elements. First one has ID:

  • configmap-my-configmap.yaml

Second one has ID:

  • configmap-my-configmap2.yaml

Without Kind and Name

In this example the kind and metadata.name are not set. In this case the filename is used as id.

data:
  game.properties: |
    enemy:
      types:
      - alien
      - monsters
    player:
      maximumLives:5    

Results in the following IDs:

  • configmap.yaml
Make sure to use same kinds when you don’t explicit define ids or if they don’t resolve via filename. If you have eg. a kind service and deployment in the same file they will be merged, which is not valid in kubernetes terms

Outcome with multiple YAMLs in one file

---
data:
  game.properties: |
    enemy:
      types:
      - alien
      - monsters
    player:
      maximumLives:5
---
data:
  game.properties: |
    enemy:
      types:
      - imps
      - warriors
    player:
      maximumLives:10

Both elements have the same ID and merged:

  • configmap.yaml

Custom ID

In this example we define custom identifiers via the id field.

helmize:
  id:
    - custom-id-1
    - custom-id-2
data:
  game.properties: |
    enemy:
      types:
      - alien
      - monsters
    player:
      maximumLives:5    

Results in the following IDs:

  • custom-id-1
  • custom-id-2

Outcome with multiple YAMLs in one file

---
helmize:
  id:
  - custom-id-1
  - custom-id-2
data:
  game.properties: |
    enemy:
      types:
      - alien
      - monsters
    player:
      maximumLives:5
---
helmize:
  id:
    - custom-id-3
    - custom-id-4
data:
  game.properties: |
    enemy:
      types:
      - imps
      - warriors
    player:
      maximumLives:10

Results in two dedicated elements. First one has ID:

  • custom-id-1
  • custom-id-2

Second one has ID:

  • custom-id-3
  • custom-id-4

Custom ID + Kind and Name

In this example we define custom identifiers via the id field. In addition the kind and metadata.name are set.

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
id:
  - custom-id-1
  - custom-id-2
data:
  game.properties: |
    enemy:
      types:
      - alien
      - monsters
    player:
      maximumLives:5    

Results in the following IDs:

  • configmap-my-configmap.yaml
  • custom-id-1
  • custom-id-2

Outcome with multiple YAMLs in one file

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
helmize:  
  id:
    - custom-id-1
    - custom-id-2
data:
  game.properties: |
    enemy:
      types:
      - alien
      - monsters
    player:
      maximumLives:5
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
helmize:
  id:
    - custom-id-3
    - custom-id-4
data:
  game.properties: |
    enemy:
      types:
      - imps
      - warriors
    player:
      maximumLives:10

Results in two dedicated elements. First one has ID:

  • configmap-my-configmap.yaml
  • custom-id-1
  • custom-id-2

Second one has ID:

  • configmap-my-configmap.yaml
  • custom-id-3
  • custom-id-4