Skip to content

Commit

Permalink
Fix a panic when diffing on LibraryElement resources (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen authored Sep 19, 2024
1 parent 4cf8f3d commit d15bc92
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/grafana/library-element-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,22 @@ const (

// ResourceFilePath returns the location on disk where a resource should be updated
func (h *LibraryElementHandler) ResourceFilePath(resource grizzly.Resource, filetype string) string {
var kindCode int
kind := "element"
t := resource.GetSpecValue("kind").(float64)

switch t {
if t, ok := resource.GetSpecValue("kind").(int); ok {
kindCode = t
} else if t, ok := resource.GetSpecValue("kind").(float64); ok {
kindCode = int(t)
}

switch kindCode {
case 1:
kind = "panel"
case 2:
kind = "variable"
}

return fmt.Sprintf(libraryElementPattern, kind, resource.Name(), filetype)
}

Expand Down

0 comments on commit d15bc92

Please sign in to comment.