con2 / emrichen

A Template engine for YAML & JSON
MIT License
107 stars 11 forks source link

Unable to merge(?) an array with !Includes #75

Closed mrambossek closed 3 months ago

mrambossek commented 3 months ago

sorry if this is just pebcak but .. i tried for 2 hours now and cant get anything to work.. i am trying to do something similar to https://github.com/con2/emrichen/issues/42 where my input is

!Defaults
butane_version: 1.1.0
---
variant: flatcar
version: !Var butane_version

storage:
  links: 
    !Include "links-ALL.yaml"
    !Include "links-docker_compose.yaml"
    - path: /tmp/test
      target: /tmp/blubb
      hard: false

links-ALL.yaml:

---
- path: /etc/localtime
  overwrite: true
  target: /usr/share/zoneinfo/Europe/Vienna
- path: /etc/systemd/system/multi-user.target.wants/docker.service
  target: /usr/lib/systemd/system/docker.service
  hard: false
  overwrite: true

links-docker_compose.yaml:

---
- path: /etc/extensions/docker_compose.raw
  target: /opt/extensions/docker_compose/docker_compose.raw
  hard: false

the expected outcome would be (reduced to relevant part):

storage:
  links: 
  - path: /etc/localtime
    overwrite: true
    target: /usr/share/zoneinfo/Europe/Vienna
  - path: /etc/systemd/system/multi-user.target.wants/docker.service
    target: /usr/lib/systemd/system/docker.service
    hard: false
    overwrite: true
  - path: /etc/extensions/docker_compose.raw
    target: /opt/extensions/docker_compose/docker_compose.raw
    hard: false
    - path: /tmp/test
      target: /tmp/blubb
      hard: false

however, regardless of what i try, nothing seems to work. i tried various combinations of !Merge and !Concat and !IncludeGlob (with a non wildcard specific filename) but all of it just throws various errors..

can someone enlighten me what the right way to do this would be? :) much appreciated...

japsu commented 3 months ago
storage:
  links: !Concat
    - !Include "links-ALL.yaml"
    - !Include "links-docker_compose.yaml"
    - - path: /tmp/test
        target: /tmp/blubb
        hard: false
mrambossek commented 3 months ago

and that one, i did not try. thanks for the fast response as well :)