goraz / onion

Layer based configuration for golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add the possibility to load the configurations from multiple file in the same directory

amreo opened this issue · comments

commented

I want to read all configurations file in the numeric (sort -n) order present in a certain directory.
For example, in /etc/sysctl.d/ I have these files:

10-console-messages.toml  
10-link-restrictions.toml
101-zeropage.conf
README
99-sysctl.toml

I want to read all /etc/sysctl.d/*.toml files. e.g

  • 10-console-messages.toml
  • 10-link-restrictions.toml
  • 99-sysctl.toml
  • 101-zeropage.conf
commented

There was a folder loader in the first version of onion, this : https://github.com/goraz/onion/blob/41058360e9ef644b4b1b3cc52174804796bd5ddb/folder_layer.go but then I decided to drop the loader, I can not remember why, It is good to add it again I think.

I want to read all configurations file in the numeric (sort -n) order present in a certain directory.
For example, in /etc/sysctl.d/ I have these files:

10-console-messages.toml  
10-link-restrictions.toml
101-zeropage.conf
README
99-sysctl.toml

I want to read all /etc/sysctl.d/*.toml files. e.g

* `10-console-messages.toml`

* `10-link-restrictions.toml`

* `99-sysctl.toml`

* `101-zeropage.conf`

What if is there an another.toml file? Before or after the numbered ones?

commented

They should be read before.

amreo@amreo-ubuntu-pc:~$ echo -e "10-pippo\n90-oo\naaa" | sort -n
aaa
10-pippo
90-oo
commented

fixed via #19