-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support links to dashboards in yaml decoder
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package decoder | ||
|
||
import ( | ||
"github.com/K-Phoen/grabana/dashboard" | ||
) | ||
|
||
type DashboardInternalLink struct { | ||
Title string `yaml:"title"` | ||
Tags []string `yaml:"tags"` | ||
AsDropdown bool `yaml:"as_dropdown,omitempty"` | ||
IncludeTimeRange bool `yaml:"include_time_range,omitempty"` | ||
IncludeVariableValues bool `yaml:"include_variable_values,omitempty"` | ||
OpenInNewTab bool `yaml:"open_in_new_tab,omitempty"` | ||
} | ||
|
||
func (l DashboardInternalLink) toModel() dashboard.DashboardLink { | ||
return dashboard.DashboardLink{ | ||
Title: l.Title, | ||
Tags: l.Tags, | ||
AsDropdown: l.AsDropdown, | ||
IncludeTimeRange: l.IncludeTimeRange, | ||
IncludeVariableValues: l.IncludeVariableValues, | ||
OpenInNewTab: l.OpenInNewTab, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package decoder | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDashboardLink(t *testing.T) { | ||
req := require.New(t) | ||
|
||
yamlLink := DashboardInternalLink{ | ||
Title: "joe", | ||
Tags: []string{"my-service"}, | ||
AsDropdown: true, | ||
IncludeTimeRange: true, | ||
IncludeVariableValues: true, | ||
OpenInNewTab: true, | ||
} | ||
|
||
model := yamlLink.toModel() | ||
|
||
req.Equal("joe", model.Title) | ||
req.ElementsMatch([]string{"my-service"}, model.Tags) | ||
req.True(model.AsDropdown) | ||
req.True(model.IncludeTimeRange) | ||
req.True(model.IncludeVariableValues) | ||
req.True(model.OpenInNewTab) | ||
} |