go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.25k stars 192 forks source link

Why toml? #958

Open wroge opened 7 months ago

wroge commented 7 months ago

Thanks for the good work, I really like tegola to create vector tiles. But I don't understand why you use toml for configuration.

I have a large number of configurations, so I use external tools to validate and generate the configuration. Many tools don't understand toml so I have to convert to json and then to toml. This leads to the problem that float values are converted to int values and toml can't handle that.

[[maps]]
...
center = [10.023321918554046, 52.44665611695578, 11]
...
type %!t(int64=11) could not be converted

Since tegola is written in go, it is very easy to accept other configuration formats such as json or yaml.
So the question is: why toml?

wroge commented 7 months ago

If I convert to yaml, I don't have this problem (so its a json thing). But the general question remains...

ARolek commented 7 months ago

@wroge good question. We actually debated between JSON and TOML a bit early in the development of tegola and we opted for TOML as we expected config files to generally be authored by people instead of machines. TOML is easier to write by hand, and also supports comments which can be useful. YAML also has this capability, but TOML has less features than YAML so it's a bit more straight forward.

Recently we have had a few people reach out discussing how they're auto generating configs for tegola so this use case is more common than we anticipated. That considered, tegola's config layer currently parses TOML into a config struct, and this could be extended to support other config formats like JSON / YAML. Would you be interested in tackling this?

wroge commented 7 months ago

I will take a look at this.

EDIT: It's not that easy because env.Dict is used. It would therefore only be possible after refactoring.

wroge commented 7 months ago

An update to v1.3.2 would probably fix the Int-Float issue of he BurntSushi/toml package. But I dont dare to edit the modules.txt file :weary:

ARolek commented 7 months ago

@wroge want to give upgrading a try? If you clone the source code you can run the following from the repo root to upgrade:

go get -u <path to package>
go mod vendor
go mod tidy

You can then follow the build instructions.

jchamberlain commented 6 months ago

FYI, in my fork I've already updated Tegola to use JSON in addition to TOML and we're using it in production right now. My work has been focused on updating our other systems that talk to Tegola, but I'll be back to finishing up my Tegola PRs later this month (dynamic config, config-in-redis, JSON config).