-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to use YAML instead of TOML for configuration #2999
Comments
Switching to YAML would also help reduce repetition when creating multiple frontends to handle differing routes (#3026). There's no equivalent to YAML anchors in TOML, which leads to a lot of repeated configuration. |
I see two general issues with YAML:
In a nutshell: YAML is nicer to read, but TOML is easier to write. From a technical perspective, I guess I'm okay with considering support if it's cheap to maintain. (That is, we can automatically and easily transform between the formats.) From a end-user support perspective, I am somewhat concerned that YAML will open up a whole new dimension of headaches ("why is my configuration not working?" -- "you are missing an indent in line 43"). |
While TOML doesn't require indentation, I find a lot of TOML is indented anyways, because it can be hard to comprehend without it. All of Traefik's documentation shows indented TOML, for example. Personally, I find TOML harder to write than YAML. YAML is definitely easier to read. |
This is debatable, but the industry seems to have adopted it - so why shouldn't it be supported in Træfik? @timoreimann Actually, I am a dev and I personally find it easier to read and write. I use an IDE with great YAML support. But I get your concern for the indentation problems on user-end but I think you should validate the config before using it - whether it's YAML or TOML. |
Sure, we do that to improve readability, which indentation definitely helps with. Unlike YAML, however, I find that TOML makes it fairly easy to indent correctly as the explicitly required table specifiers provide the necessary scaffolding (at the price of added verbosity, no question). Furthermore, the cost of misaligning is just a minor cosmetic issue in TOML, whereas in YAML such a mistake can turn into an wrong configuration.
I also use a plugin to assist with writing YAML. In fact, it's the only way for me to effectively write complex YAML files. I consider that to be a sign that the syntax and format is too complicated to be handled with simple editors. With TOML, I don't feel that pain. Validating configurations in-code is a non-trivial problem. Strictly speaking, you'd have to treat every unknown configuration option as an error and report it to the user. Traefik doesn't do this at the moment -- instead, it tries hard to bootstrap into a somehow working mode. Whether that's desirable or not is debatable. But even if we had some kind of strict mode, I believe a broken YAML configuration is still harder to debug and get right, again based on my experience with working on Kubernetes manifests. That said, I do understand the value for supporting a well-known format like YAML: a larger group is familiar with it, lots of tools exist, etc. TOML certainly isn't free of issues either -- the fact that any non-table option must go before the first table option has been a continuous source of end-user support questions ever since. So I'm not super opposed to the idea, I just think that it comes with a price we shouldn't underestimate when we make a decision. |
Maybe abstract the settings loader in a way that we could use either (or other types) through adapters? YAML, Toml, json and XML are all quite easy to convert to the same data output (not sure about toml, due to not being that used to it yet), and it's often more of a question of taste. |
One awesome pro with YAML: It has so called anchors which makes your config DRY. |
Have the ability to repeat something can be useful for the dynamic configuration but it's not really useful for the static configuration. With this PR #2991 (v1.6) you will be able to use Go Template syntax (functions, loops, variables, ...) in the TOML configuration (for the dynamic configuration). |
So much this. I don't understand how TOML has become as popular as it has. I'd love to see Traefik support both toml and yaml, these "dsl language arguments" never go anywhere constructive, there's always pros and cons. |
@containous/traefik thoughts? At least by looking at the number of thumbs up on the issue description, there seems to be a desire to support YAML. |
I was excited to find out about traefik as a replacement for the deprecated dockercloud-haproxy, but the config examples in TOML immediately put me off big time. I personally find YAML is infinitely easier to read and write, even without any special linters. Although I'm a Python developer, so I'm used to indentation being important (and I think that's a good thing). And yes, everything is YAML these days. There's little to be gained by going against the grain on this one. |
Obviously TOML is harder to read and understand. |
go templates are overkill for something that yaml anchors fix trivially. Its an even more complicated solution than the yaml one. It's also not trivial to merge/compose some configuration in it. Those templates are even uglier and harder to use than yaml. Traefik config is repetitive and ugly. Toml is intended for simple configurations like old school windows ini files, not emulating tree structures with dot seperated names. Also [[]] is ugly to look at and comprehend. |
Put your confid in yaml, then convert with remarshal, a python util... |
relying on https://github.com/spf13/viper would allow to support both toml and yaml, + json, hcl, and even java properties (!) |
Any update on this? I hoped to find some additional labels / milestones associated with this issue when YAML support was mentioned in the v2 blog post: |
This comment has been minimized.
This comment has been minimized.
Can we close this issue now that #4935 is merged? |
In fact Traefik don't really support YAML: current (alpha7) we only added YAML support for the static configuration, the dynamic configuration still use TOML only. This is why we have not communicated on this subject, nor added documentation, nor closed the issue. |
Closed by #5024. |
Do you want to request a feature or report a bug?
feature
Description
YAML is becoming the industry standard configuration format. Docker uses it for Compose/Stack, Kubernetes, GitLab CI, Travis CI, Drone CI, Google App Engine, etc. Wouldn't it be ok to support both configuration formats, for those who prefer YAML instead of TOML.
Let's take the following example, a configuration in both TOML and YAML from here. In my opinion YAML is more readable, better structured (with indent as context) and with less noise (less repetitions of parent elements).
TOML
YAML
Output of
traefik version
: (What version of Traefik are you using?)The text was updated successfully, but these errors were encountered: