diff --git a/go.mod b/go.mod index 0b7ff6868..fbeba5294 100644 --- a/go.mod +++ b/go.mod @@ -265,7 +265,7 @@ require ( // Use fork of gocql that has gokit logs and Prometheus metrics - required replace github.com/gocql/gocql => github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 -replace github.com/grafana-tools/sdk => github.com/colega/grafana-tools-sdk v0.0.0-20220323154849-711bca56d13f +replace github.com/grafana-tools/sdk => github.com/colega/grafana-tools-sdk v0.0.0-20220401112130-163cd43fb5e4 replace github.com/prometheus/prometheus => github.com/prometheus/prometheus v0.43.1-0.20230419161410-69155c6ba1e9 diff --git a/go.sum b/go.sum index 27e5ef192..a3daded08 100644 --- a/go.sum +++ b/go.sum @@ -832,8 +832,8 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+g github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/colega/grafana-tools-sdk v0.0.0-20220323154849-711bca56d13f h1:Mc/WpMhT0pzDD5zGjhge7PiO7nkrMME4GuGS1y4HGwk= -github.com/colega/grafana-tools-sdk v0.0.0-20220323154849-711bca56d13f/go.mod h1:AHHlOEv1+GGQ3ktHMlhuTUwo3zljV3QJbC0+8o2kn+4= +github.com/colega/grafana-tools-sdk v0.0.0-20220401112130-163cd43fb5e4 h1:u75LBGHfI1jW4gY3gM5h0WFizp7Yues4go+z6ope6vk= +github.com/colega/grafana-tools-sdk v0.0.0-20220401112130-163cd43fb5e4/go.mod h1:AHHlOEv1+GGQ3ktHMlhuTUwo3zljV3QJbC0+8o2kn+4= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= diff --git a/vendor/github.com/grafana-tools/sdk/panel.go b/vendor/github.com/grafana-tools/sdk/panel.go index 34479bd6f..073ea9a2b 100644 --- a/vendor/github.com/grafana-tools/sdk/panel.go +++ b/vendor/github.com/grafana-tools/sdk/panel.go @@ -23,6 +23,7 @@ import ( "bytes" "encoding/json" "errors" + "fmt" ) // Each panel may be one of these types. @@ -1030,78 +1031,85 @@ type probePanel struct { func (p *Panel) UnmarshalJSON(b []byte) (err error) { var probe probePanel - if err = json.Unmarshal(b, &probe); err == nil { - p.CommonPanel = probe.CommonPanel - switch probe.Type { - case "graph": - var graph GraphPanel - p.OfType = GraphType - if err = json.Unmarshal(b, &graph); err == nil { - p.GraphPanel = &graph - } - case "table": - var table TablePanel - p.OfType = TableType - if err = json.Unmarshal(b, &table); err == nil { - p.TablePanel = &table - } - case "text": - var text TextPanel - p.OfType = TextType - if err = json.Unmarshal(b, &text); err == nil { - p.TextPanel = &text - } - case "singlestat": - var singlestat SinglestatPanel - p.OfType = SinglestatType - if err = json.Unmarshal(b, &singlestat); err == nil { - p.SinglestatPanel = &singlestat - } - case "stat": - var stat StatPanel - p.OfType = StatType - if err = json.Unmarshal(b, &stat); err == nil { - p.StatPanel = &stat - } - case "dashlist": - var dashlist DashlistPanel - p.OfType = DashlistType - if err = json.Unmarshal(b, &dashlist); err == nil { - p.DashlistPanel = &dashlist - } - case "bargauge": - var bargauge BarGaugePanel - p.OfType = BarGaugeType - if err = json.Unmarshal(b, &bargauge); err == nil { - p.BarGaugePanel = &bargauge - } - case "heatmap": - var heatmap HeatmapPanel - p.OfType = HeatmapType - if err = json.Unmarshal(b, &heatmap); err == nil { - p.HeatmapPanel = &heatmap - } - case "timeseries": - var timeseries TimeseriesPanel - p.OfType = TimeseriesType - if err = json.Unmarshal(b, ×eries); err == nil { - p.TimeseriesPanel = ×eries - } - case "row": - var rowpanel RowPanel - p.OfType = RowType - if err = json.Unmarshal(b, &rowpanel); err == nil { - p.RowPanel = &rowpanel - } - default: - var custom = make(CustomPanel) - p.OfType = CustomType - if err = json.Unmarshal(b, &custom); err == nil { - p.CustomPanel = &custom - } + if err = json.Unmarshal(b, &probe); err != nil { + return err + } + + p.CommonPanel = probe.CommonPanel + switch probe.Type { + case "graph": + var graph GraphPanel + p.OfType = GraphType + if err = json.Unmarshal(b, &graph); err == nil { + p.GraphPanel = &graph + } + case "table": + var table TablePanel + p.OfType = TableType + if err = json.Unmarshal(b, &table); err == nil { + p.TablePanel = &table + } + case "text": + var text TextPanel + p.OfType = TextType + if err = json.Unmarshal(b, &text); err == nil { + p.TextPanel = &text + } + case "singlestat": + var singlestat SinglestatPanel + p.OfType = SinglestatType + if err = json.Unmarshal(b, &singlestat); err == nil { + p.SinglestatPanel = &singlestat + } + case "stat": + var stat StatPanel + p.OfType = StatType + if err = json.Unmarshal(b, &stat); err == nil { + p.StatPanel = &stat + } + case "dashlist": + var dashlist DashlistPanel + p.OfType = DashlistType + if err = json.Unmarshal(b, &dashlist); err == nil { + p.DashlistPanel = &dashlist + } + case "bargauge": + var bargauge BarGaugePanel + p.OfType = BarGaugeType + if err = json.Unmarshal(b, &bargauge); err == nil { + p.BarGaugePanel = &bargauge + } + case "heatmap": + var heatmap HeatmapPanel + p.OfType = HeatmapType + if err = json.Unmarshal(b, &heatmap); err == nil { + p.HeatmapPanel = &heatmap + } + case "timeseries": + var timeseries TimeseriesPanel + p.OfType = TimeseriesType + if err = json.Unmarshal(b, ×eries); err == nil { + p.TimeseriesPanel = ×eries + } + case "row": + var rowpanel RowPanel + p.OfType = RowType + if err = json.Unmarshal(b, &rowpanel); err == nil { + p.RowPanel = &rowpanel + } + default: + var custom = make(CustomPanel) + p.OfType = CustomType + if err = json.Unmarshal(b, &custom); err == nil { + p.CustomPanel = &custom } } - return + + if err != nil && (probe.Title != "" || probe.Type != "") { + err = fmt.Errorf("%w (panel %q of type %q)", err, probe.Title, probe.Type) + } + + return err } func (p *Panel) MarshalJSON() ([]byte, error) { diff --git a/vendor/modules.txt b/vendor/modules.txt index c38713286..bed2722ce 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -759,7 +759,7 @@ github.com/gorilla/mux # github.com/gosimple/slug v1.1.1 ## explicit github.com/gosimple/slug -# github.com/grafana-tools/sdk v0.0.0-20220203092117-edae16afa87b => github.com/colega/grafana-tools-sdk v0.0.0-20220323154849-711bca56d13f +# github.com/grafana-tools/sdk v0.0.0-20220203092117-edae16afa87b => github.com/colega/grafana-tools-sdk v0.0.0-20220401112130-163cd43fb5e4 ## explicit; go 1.13 github.com/grafana-tools/sdk # github.com/grafana/dskit v0.0.0-20230908075806-579cf66fbf9b @@ -1757,7 +1757,7 @@ gotest.tools/internal/source rsc.io/binaryregexp rsc.io/binaryregexp/syntax # github.com/gocql/gocql => github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 -# github.com/grafana-tools/sdk => github.com/colega/grafana-tools-sdk v0.0.0-20220323154849-711bca56d13f +# github.com/grafana-tools/sdk => github.com/colega/grafana-tools-sdk v0.0.0-20220401112130-163cd43fb5e4 # github.com/prometheus/prometheus => github.com/prometheus/prometheus v0.43.1-0.20230419161410-69155c6ba1e9 # google.golang.org/grpc => google.golang.org/grpc v1.56.3 # github.com/sercand/kuberesolver/v4 => github.com/sercand/kuberesolver/v4 v4.0.0-20230228224450-d8a3bdc2c3f7