Skip to content
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

Allow configuration by config file #133

Closed
paulgb opened this issue Sep 1, 2022 · 3 comments
Closed

Allow configuration by config file #133

paulgb opened this issue Sep 1, 2022 · 3 comments
Assignees
Labels
deploy-breaking Changes that may require infrastructure/config changes when deployed.

Comments

@paulgb
Copy link
Member

paulgb commented Sep 1, 2022

We've outgrown command-line only configuration.

When it comes to configuration files there's a tricky balance; on one hand we don't want to stray too far from expected practices; on the other hand, common practices are fractured and leave a lot to be desired.

Some things to consider:

  • It's common to have a fairly static configuration but want to set some values at runtime. How should this be accomplished?
    • Caddy approach: env var templating in configuration file
    • Nginx approach doesn't have built-in env var substitution, but the docker image implements it based on envsubst
    • docker registry allows overriding individual yaml leaves by turning the full path to that leaf into a variable name. This is good for overriding string values, but is awkward for list/array/set values.
  • It's important to be able to automatically generate configuration from popular languages, so it should be a relatively common format.
  • It's important to be able to add comments to configuration, so if we were to go with something like JSON, we'd want to use a flavor that supported comments. And trailing commas.

Some options:

  • TOML: Rust projects tend to favor it.
  • YAML: Popular with Go/CNCF projects, but No Body Wants To Write YAML. Superficially a superset of JSON, making it very easy to generate universally, but not without footguns.
  • JSON: Good for generating but not for human-generated configuration.
  • Dhall: Has some nice neat ideas but overcomplicated for our use case and still pretty obscure.
  • CUE: Exposes less complexity than Dhall although it has a similarly thoughtful design. It could be a nice user experience with the right tooling, but I don't think the tooling is mature enough yet. Mostly targets the Go ecosystem currently.
  • Nickel: Cool but too programming-languagey
@paulgb
Copy link
Member Author

paulgb commented Sep 3, 2022

There are Rust libraries that allow us to read from multiple formats and also to allow environment overrides.

https://github.com/SergioBenitez/Figment
https://crates.io/crates/config

A minimal feature set for us probably includes:

  • Ability to use toml (for human-created) and json (for machine-created)
  • Reasonable errors on schema validation
  • Ability to override with env or cli options
  • Serde, ideally

@paulgb
Copy link
Member Author

paulgb commented Sep 3, 2022

I've evaluated Figment and config-rs and written up my thoughts in this issue comment.

I find some of figment's design decisions more aligned with my expectations, but it hasn't been touched in over a year and has some out-of-date dependencies. I'm inclined to fork it and update the deps ourselves and then use it.

@paulgb paulgb added this to the initial-release milestone Sep 4, 2022
@paulgb paulgb added the deploy-breaking Changes that may require infrastructure/config changes when deployed. label Sep 4, 2022
@paulgb paulgb self-assigned this Sep 4, 2022
paulgb added a commit that referenced this issue Sep 6, 2022
* Replace CLI-based configuration with file-based (#133)

* Use default for Docker connection
@paulgb
Copy link
Member Author

paulgb commented Sep 6, 2022

Closed by #149

@paulgb paulgb closed this as completed Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-breaking Changes that may require infrastructure/config changes when deployed.
Projects
None yet
Development

No branches or pull requests

1 participant