I'm trying to define a config file structure that can mostly be shared across operating systems and hostnames, but also supports exceptions when needed.
For example, the TOML below might work if I make the runtime code look up the keys
That would give a default server value of 192.168.1.100, FreeBSD machines a server value of 10.0.0.100, and the host named Jupiter a server value of 10.0.0.1.
It seems like this would work, but these things get complicated beyond the naive first-pass.
Can anyone recommend a good approach to this from their own experience so I don't have to make all of my own mistakes?
Everything is on the table here (maybe even an embedded interpreter). I'm writing in
For example, the TOML below might work if I make the runtime code look up the keys
hostname.<hostname>.server
, os.<uname>.server
, and server
, and then use the value from the first key that exists.That would give a default server value of 192.168.1.100, FreeBSD machines a server value of 10.0.0.100, and the host named Jupiter a server value of 10.0.0.1.
YAML:
[hostname]
[#.jupiter]
server = "10.0.0.1"
[os]
[#.freebsd]
server = "10.0.0.100"
server = "192.168.1.100"
It seems like this would work, but these things get complicated beyond the naive first-pass.
Can anyone recommend a good approach to this from their own experience so I don't have to make all of my own mistakes?
Everything is on the table here (maybe even an embedded interpreter). I'm writing in
go
if it matters.