grafana / grizzly

A utility for managing Jsonnet dashboards against the Grafana API

Home Page:https://grafana.github.io/grizzly/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle panic gracefully when passing JSON as string in the spec

basvdl opened this issue · comments

As a first time user I was a bit puzzled how to add JSON to the spec when creating a dashboard. My first attempt was passing the JSON as string, resulting in a panic.

Can we handle the panic more gracefully and as bonus, add an example to the docs.

./grr-darwin-amd64 apply gel-dashboards.yaml
panic: interface conversion: interface {} is string, not map[string]interface {}

goroutine 1 [running]:
github.com/grafana/grizzly/pkg/grizzly.(*Resource).SetSpecString(...)
	/drone/src/pkg/grizzly/providers.go:90
...
github.com/go-clix/cli.(*Command).Execute(0xc0002c72c0, 0xc0008dff28, 0xa)
	/go/pkg/mod/github.com/go-clix/cli@v0.2.0/command.go:76 +0x105
main.main()
	/drone/src/cmd/grr/main.go:44 +0x26b

Content of gel-dashboards.yaml

apiVersion: grizzly.grafana.com/v1alpha1
kind: Dashboard
metadata:
    name: loki-writes
    folder: gel-system-monitoring
spec: |
  {
    "timezone": "utc",
    "title": "Loki / Writes",
    "uid": "writes",
    "version": 0
  }