Tool to help you manage your Grafana dashboards using Git.

main.go 671B

12345678910111213141516171819202122232425262728293031323334353637
  1. package main
  2. import (
  3. "flag"
  4. "config"
  5. "grafana"
  6. "logger"
  7. )
  8. // The Grafana API client and the config need to be global to the package since
  9. // we need them in the webhook handlers.
  10. // TODO: Find a better way to pass it to the handlers
  11. var (
  12. grafanaClient *grafana.Client
  13. cfg *config.Config
  14. )
  15. func main() {
  16. var err error
  17. configFile := flag.String("config", "config.yaml", "Path to the configuration file")
  18. flag.Parse()
  19. logger.LogConfig()
  20. cfg, err = config.Load(*configFile)
  21. if err != nil {
  22. panic(err)
  23. }
  24. grafanaClient = grafana.NewClient(cfg.Grafana.BaseURL, cfg.Grafana.APIKey)
  25. if err = SetupWebhook(cfg); err != nil {
  26. panic(err)
  27. }
  28. }