Skip to content

Commit

Permalink
Merge pull request #216 from K-Phoen/fix-hidden-legend-handling
Browse files Browse the repository at this point in the history
Fix hidden legends handling on newer grafana versions
  • Loading branch information
K-Phoen authored Mar 21, 2023
2 parents d1f4e8a + e62a837 commit 0f33970
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 71 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module github.com/K-Phoen/dark
go 1.19

require (
github.com/K-Phoen/grabana v0.21.16
github.com/K-Phoen/sdk v0.12.0
github.com/K-Phoen/grabana v0.21.17
github.com/K-Phoen/sdk v0.12.2
github.com/go-logr/logr v1.2.3
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.27.1
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.2
go.uber.org/zap v1.24.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.26.1
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/K-Phoen/grabana v0.21.16 h1:IxZKPqrQyt3Yq00p/YMhexCtPAxJJpAEfMQorRVG7+0=
github.com/K-Phoen/grabana v0.21.16/go.mod h1:HDl99djdna5Auu7RcOgxE64HnvQ9UBIpqc+A2A5XnL8=
github.com/K-Phoen/sdk v0.12.0 h1:+0QqHoDZbO6zetFMggM3zKF48GKRu744Ycc9w4oyY0E=
github.com/K-Phoen/sdk v0.12.0/go.mod h1:wp7qXARaIhCYktmoOjRZ+TDMlek5nbayC+waN7vigxI=
github.com/K-Phoen/grabana v0.21.17 h1:mO/9DvJWC/qpTF/X5jQDm5eKgCBaCGypP/tEfXAvKfg=
github.com/K-Phoen/grabana v0.21.17/go.mod h1:vbASQt9UiQhX4lC3/opLpJMJ8m+hsTUU2FwkQMytHK4=
github.com/K-Phoen/sdk v0.12.2 h1:0QofDlKE+lloyBOzhjEEMW21061zts/WIpfpQ5NLLAs=
github.com/K-Phoen/sdk v0.12.2/go.mod h1:qmM0wO23CtoDux528MXPpYvS4XkRWkWX6rvX9Za8EVU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
Expand Down Expand Up @@ -175,7 +175,6 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/gosimple/slug v1.12.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
github.com/gosimple/slug v1.13.1 h1:bQ+kpX9Qa6tHRaK+fZR0A0M2Kd7Pa5eHPPsb1JpHD+Q=
github.com/gosimple/slug v1.13.1/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=
Expand Down Expand Up @@ -283,8 +282,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand Down
31 changes: 18 additions & 13 deletions internal/pkg/converter/timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,26 @@ func (converter *JSON) convertTimeSeriesLineInterpolation(panel sdk.Panel) strin
func (converter *JSON) convertTimeSeriesLegend(legend sdk.TimeseriesLegendOptions) []string {
options := []string{}

// Display mode
switch legend.DisplayMode {
case "list":
options = append(options, "as_list")
case "hidden":
// Hidden legend?
if legend.Show != nil && !*legend.Show {
options = append(options, "hide")
default:
options = append(options, "as_table")
}

// Placement
if legend.Placement == "right" {
options = append(options, "to_the_right")
} else {
options = append(options, "to_bottom")
// Display mode
switch legend.DisplayMode {
case "list":
options = append(options, "as_list")
case "hidden":
options = append(options, "hide")
default:
options = append(options, "as_table")
}

// Placement
if legend.Placement == "right" {
options = append(options, "to_the_right")
} else {
options = append(options, "to_bottom")
}
}

// Automatic calculations
Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/K-Phoen/grabana/timeseries/timeseries.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/K-Phoen/sdk/panel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 33 additions & 45 deletions vendor/github.com/stretchr/testify/assert/assertions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# github.com/K-Phoen/grabana v0.21.16
# github.com/K-Phoen/grabana v0.21.17
## explicit; go 1.19
github.com/K-Phoen/grabana
github.com/K-Phoen/grabana/alert
Expand Down Expand Up @@ -50,8 +50,8 @@ github.com/K-Phoen/grabana/variable/datasource
github.com/K-Phoen/grabana/variable/interval
github.com/K-Phoen/grabana/variable/query
github.com/K-Phoen/grabana/variable/text
# github.com/K-Phoen/sdk v0.12.0
## explicit; go 1.16
# github.com/K-Phoen/sdk v0.12.2
## explicit; go 1.19
github.com/K-Phoen/sdk
# github.com/beorn7/perks v1.0.1
## explicit; go 1.11
Expand Down Expand Up @@ -279,7 +279,7 @@ github.com/spf13/viper/internal/encoding/javaproperties
github.com/spf13/viper/internal/encoding/json
github.com/spf13/viper/internal/encoding/toml
github.com/spf13/viper/internal/encoding/yaml
# github.com/stretchr/testify v1.8.1
# github.com/stretchr/testify v1.8.2
## explicit; go 1.13
github.com/stretchr/testify/assert
github.com/stretchr/testify/require
Expand Down

0 comments on commit 0f33970

Please sign in to comment.