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

Panic when dashboard folder is undefined

tenstad opened this issue · comments

Error

panic: interface conversion: interface {} is nil, not string
goroutine 1 [running]:
github.com/grafana/grizzly/pkg/grizzly.(*Resource).GetMetadata(...)
	/app/pkg/grizzly/providers.go:72
github.com/grafana/grizzly/pkg/grafana.postDashboard(0xc000a6c4e0, 0x18e1200, 0xc00007fae0)
	/app/pkg/grafana/dashboards.go:99 +0xc99
github.com/grafana/grizzly/pkg/grafana.(*DashboardHandler).Add(0x2c02968, 0xc000a6c4e0, 0x0, 0x0)
	/app/pkg/grafana/dashboard-handler.go:117 +0x2b
github.com/grafana/grizzly/pkg/grizzly.Apply(0xc000391820, 0x4, 0x4, 0xc000185ce0, 0x3)
	/app/pkg/grizzly/workflow.go:240 +0x49e
main.applyCmd.func1(0xc000280960, 0xc0003837b0, 0x1, 0x1, 0x0, 0x0)
	/app/cmd/grr/workflow.go:122 +0x111
github.com/go-clix/cli.(*Command).execute(0xc000280960, 0xc000383790, 0x1, 0x1, 0xc000280960, 0xc000383790)
	/go/pkg/mod/github.com/go-clix/cli@v0.2.0/command.go:118 +0x34e
github.com/go-clix/cli.(*Command).Execute(0xc0003b55e0, 0xc0008bff28, 0xa)
	/go/pkg/mod/github.com/go-clix/cli@v0.2.0/command.go:76 +0x105
main.main()
	/app/cmd/grr/main.go:44 +0x26b

How to reproduce

In the examples/ folder, modify grr.jsonnet as shown below, and run grr apply grr.jsonnet.

local dashboard = import 'dashboard-simple.libsonnet';
local grr = import 'grizzly/grizzly.libsonnet';

{
  dashboards: [
    grr.dashboard.new('prod-overview', dashboard),
  ],
}

Suggested solution

It would be nice if the general folder is used as a default when metadata.folder is undefined.
If, however, a folder should be required, I would expect an error saying so, not a stack trace.

Personally, I strongly prefer making general the default, rather than metadata.folder beeing a required field. 😄