-
Notifications
You must be signed in to change notification settings - Fork 675
Closed
Labels
Description
Someone else brought it up, but I don't remember where, so I apologize in advance for lack of proper attribution.
Summary
We have a config struct for the server, located here, it looks like this:
type Server struct {
LogLevel string `def:"info", desc:"debug|info|warn|error"`
BadgerLogLevel string `def:"error", desc:"debug|info|warn|error"`
StoragePath string `def:"<installPrefix>/var/lib/pyroscope" desc:"directory where pyroscope stores profiling data"`
ApiBindAddr string `def:":4040" desc:"port for the HTTP server used for data ingestion and web UI"`
...
It would be cool to write a script that would take this struct and generate a self-documented sample config file, for example:
---
# debug|info|warn|error
log-level: "info"
# debug|info|warn|error
badger-log-level: "error"
# directory where pyroscope stores profiling data
storage-path: "/var/lib/pyroscope"
# port for the HTTP server used for data ingestion and web UI
api-bind-addr: ":4040"
...
More Details
We have this code here that turns a struct into a flagSet
. Flag sets are much easier to work with. There's also this DefaultUsageFunc
function (link) that takes a flagSet and prints usage info from it. So basically for this issue we could have a function that does more or less the same thing but generates a self documented yaml file.
TODO:
- write a go program that would turn a struct into a self documented yaml, it's gonna be pretty simple so I think we can put it into
scripts/packages/<some name>.go
and then run it via go run:go run scripts/packages/<some name>.go
- make a job in Makefile that would run it and update
scripts/packages/server.yml
file
Later we'll also put it somewhere on our docs website.