weaveworks / grafanalib

Python library for building Grafana dashboards
Apache License 2.0
1.86k stars 309 forks source link

All field values should be saved as Enums and saved in isolated modules. #576

Open tiansu-yu-idealo opened 1 year ago

tiansu-yu-idealo commented 1 year ago

A general observation is that the acceptable values for almost all fields are either saved as plain constants or not at all, this gives a huge amount of headache when one tries to configure each field. Often times I find myself toggle editor generated JSON and grafana docs for configuring panel styles.

In general, all such values should be saved as Enums in a separate module and quoted as e.g. ReduceCalcs.Last.value and all validations can be done via in ReduceCalcs.values. This should be a preferred approach.

Looking forward to hear your opinions and would love to contribute some PRs for this.