-
-
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.
Merge pull request #94 from K-Phoen/graph-override-series
Support some graph override series
- Loading branch information
Showing
25 changed files
with
332 additions
and
28 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
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
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
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,48 @@ | ||
package series | ||
|
||
import ( | ||
"github.com/grafana-tools/sdk" | ||
) | ||
|
||
// OverrideOption represents an option that can be used alter a graph panel series. | ||
type OverrideOption func(series *sdk.SeriesOverride) | ||
|
||
// Alis defines an alias/regex used to identify the series to override. | ||
func Alias(alias string) OverrideOption { | ||
return func(series *sdk.SeriesOverride) { | ||
series.Alias = alias | ||
} | ||
} | ||
|
||
// Color overrides the color for the matched series. | ||
func Color(color string) OverrideOption { | ||
return func(series *sdk.SeriesOverride) { | ||
series.Color = &color | ||
} | ||
} | ||
|
||
// Dashes enables/disables display of the series using dashes instead of lines. | ||
func Dashes(enabled bool) OverrideOption { | ||
return func(series *sdk.SeriesOverride) { | ||
series.Dashes = &enabled | ||
} | ||
} | ||
|
||
// Lines enables/disables display of the series using dashes instead of dashes. | ||
func Lines(enabled bool) OverrideOption { | ||
return func(series *sdk.SeriesOverride) { | ||
series.Lines = &enabled | ||
} | ||
} | ||
|
||
func Fill(opacity int) OverrideOption { | ||
return func(series *sdk.SeriesOverride) { | ||
series.Fill = &opacity | ||
} | ||
} | ||
|
||
func LineWidth(width int) OverrideOption { | ||
return func(series *sdk.SeriesOverride) { | ||
series.LineWidth = &width | ||
} | ||
} |
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,67 @@ | ||
package series | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/grafana-tools/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAliasCanBeDefined(t *testing.T) { | ||
req := require.New(t) | ||
series := &sdk.SeriesOverride{} | ||
|
||
Alias("Error - .*")(series) | ||
|
||
req.Equal("Error - .*", series.Alias) | ||
} | ||
|
||
func TestColorCanBeDefined(t *testing.T) { | ||
req := require.New(t) | ||
series := &sdk.SeriesOverride{} | ||
|
||
Color("#65c5db")(series) | ||
|
||
req.NotNil(series.Color) | ||
req.Equal("#65c5db", *series.Color) | ||
} | ||
|
||
func TestDashesCanBeEnabled(t *testing.T) { | ||
req := require.New(t) | ||
series := &sdk.SeriesOverride{} | ||
|
||
Dashes(true)(series) | ||
|
||
req.NotNil(series.Dashes) | ||
req.True(*series.Dashes) | ||
} | ||
|
||
func TestLinesCanBeEnabled(t *testing.T) { | ||
req := require.New(t) | ||
series := &sdk.SeriesOverride{} | ||
|
||
Lines(true)(series) | ||
|
||
req.NotNil(series.Lines) | ||
req.True(*series.Lines) | ||
} | ||
|
||
func TestFillOpacityCanBeDefined(t *testing.T) { | ||
req := require.New(t) | ||
series := &sdk.SeriesOverride{} | ||
|
||
Fill(2)(series) | ||
|
||
req.NotNil(*series.Fill) | ||
req.Equal(2, *series.Fill) | ||
} | ||
|
||
func TestLineWidthCanBeDefined(t *testing.T) { | ||
req := require.New(t) | ||
series := &sdk.SeriesOverride{} | ||
|
||
LineWidth(3)(series) | ||
|
||
req.NotNil(*series.LineWidth) | ||
req.Equal(3, *series.LineWidth) | ||
} |
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
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
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
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
Oops, something went wrong.