Commit 17f36d04 by Kyle Brandt Committed by GitHub

sdk: update to latest (#20182)

which removes an unused field from the Transform api
parent dca84145
...@@ -31,7 +31,7 @@ require ( ...@@ -31,7 +31,7 @@ require (
github.com/gorilla/websocket v1.4.0 github.com/gorilla/websocket v1.4.0
github.com/gosimple/slug v1.4.2 github.com/gosimple/slug v1.4.2
github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4 github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4
github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191029155514-4d93894a3f7a github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191105165811-c4e9ecfec89f
github.com/hashicorp/go-hclog v0.8.0 github.com/hashicorp/go-hclog v0.8.0
github.com/hashicorp/go-plugin v1.0.1 github.com/hashicorp/go-plugin v1.0.1
github.com/hashicorp/go-version v1.1.0 github.com/hashicorp/go-version v1.1.0
......
...@@ -112,6 +112,8 @@ github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4 h1:SP ...@@ -112,6 +112,8 @@ github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4 h1:SP
github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4/go.mod h1:nc0XxBzjeGcrMltCDw269LoWF9S8ibhgxolCdA1R8To= github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4/go.mod h1:nc0XxBzjeGcrMltCDw269LoWF9S8ibhgxolCdA1R8To=
github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191029155514-4d93894a3f7a h1:4xgIDiu73n83pb5z835OL/33+DGPGs4M94UBdm7lbJc= github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191029155514-4d93894a3f7a h1:4xgIDiu73n83pb5z835OL/33+DGPGs4M94UBdm7lbJc=
github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191029155514-4d93894a3f7a/go.mod h1:cq0Q7VKEJhlo81CrNexlOZ3VuqmaP/z2rq6lQAydtBo= github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191029155514-4d93894a3f7a/go.mod h1:cq0Q7VKEJhlo81CrNexlOZ3VuqmaP/z2rq6lQAydtBo=
github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191105165811-c4e9ecfec89f h1:x4B65juB5agGJCQpLVlMVdrscdpb1WcraRPNn6O7p/s=
github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191105165811-c4e9ecfec89f/go.mod h1:cq0Q7VKEJhlo81CrNexlOZ3VuqmaP/z2rq6lQAydtBo=
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI=
github.com/hashicorp/go-hclog v0.8.0 h1:z3ollgGRg8RjfJH6UVBaG54R70GFd++QOkvnJH3VSBY= github.com/hashicorp/go-hclog v0.8.0 h1:z3ollgGRg8RjfJH6UVBaG54R70GFd++QOkvnJH3VSBY=
github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
......
...@@ -137,8 +137,6 @@ type TransformWrapper struct { ...@@ -137,8 +137,6 @@ type TransformWrapper struct {
func (tw *TransformWrapper) Transform(ctx context.Context, query *tsdb.TsdbQuery) (*tsdb.Response, error) { func (tw *TransformWrapper) Transform(ctx context.Context, query *tsdb.TsdbQuery) (*tsdb.Response, error) {
pbQuery := &pluginv2.TransformRequest{ pbQuery := &pluginv2.TransformRequest{
// TODO Not sure Datasource property needs be on this?
Datasource: &pluginv2.DatasourceInfo{},
TimeRange: &pluginv2.TimeRange{ TimeRange: &pluginv2.TimeRange{
FromRaw: query.TimeRange.From, FromRaw: query.TimeRange.From,
ToRaw: query.TimeRange.To, ToRaw: query.TimeRange.To,
......
...@@ -241,15 +241,13 @@ func UnMarshalArrow(b []byte) (*Frame, error) { ...@@ -241,15 +241,13 @@ func UnMarshalArrow(b []byte) (*Frame, error) {
v := array.NewFloat64Data(col.Data()) v := array.NewFloat64Data(col.Data())
for _, f := range v.Float64Values() { for _, f := range v.Float64Values() {
vF := f vF := f
vec := append(*frame.Fields[i].Vector.(*floatVector), &vF) frame.Fields[i].Vector.Append(&vF)
frame.Fields[i].Vector = &vec
} }
case arrow.TIMESTAMP: case arrow.TIMESTAMP:
v := array.NewTimestampData(col.Data()) v := array.NewTimestampData(col.Data())
for _, ts := range v.TimestampValues() { for _, ts := range v.TimestampValues() {
t := time.Unix(0, int64(ts)) // nanosecond assumption t := time.Unix(0, int64(ts)) // nanosecond assumption
vec := append(*frame.Fields[i].Vector.(*timeVector), &t) frame.Fields[i].Vector.Append(&t)
frame.Fields[i].Vector = &vec
} }
default: default:
return nil, fmt.Errorf("unsupported arrow type %s for conversion", col.DataType().ID()) return nil, fmt.Errorf("unsupported arrow type %s for conversion", col.DataType().ID())
......
...@@ -7,6 +7,18 @@ func newBoolVector(l int) *boolVector { ...@@ -7,6 +7,18 @@ func newBoolVector(l int) *boolVector {
return &v return &v
} }
func (v *boolVector) Set(i int, val interface{}) { (*v)[i] = val.(*bool) } func (v *boolVector) Set(i int, val interface{}) {
func (v *boolVector) At(i int) interface{} { return (*v)[i] } (*v)[i] = val.(*bool)
func (v *boolVector) Len() int { return len(*v) } }
func (v *boolVector) Append(val interface{}) {
*v = append(*v, val.(*bool))
}
func (v *boolVector) At(i int) interface{} {
return (*v)[i]
}
func (v *boolVector) Len() int {
return len(*v)
}
...@@ -6,6 +6,15 @@ func newFloatVector(l int) *floatVector { ...@@ -6,6 +6,15 @@ func newFloatVector(l int) *floatVector {
v := make(floatVector, l) v := make(floatVector, l)
return &v return &v
} }
func (v *floatVector) Set(i int, val interface{}) { (*v)[i] = val.(*float64) }
func (v *floatVector) Set(i int, val interface{}) {
(*v)[i] = val.(*float64)
}
func (v *floatVector) Append(val interface{}) {
*v = append(*v, val.(*float64))
}
func (v *floatVector) At(i int) interface{} { return (*v)[i] } func (v *floatVector) At(i int) interface{} { return (*v)[i] }
func (v *floatVector) Len() int { return len(*v) } func (v *floatVector) Len() int { return len(*v) }
...@@ -7,6 +7,18 @@ func newStringVector(l int) *stringVector { ...@@ -7,6 +7,18 @@ func newStringVector(l int) *stringVector {
return &v return &v
} }
func (v *stringVector) Set(i int, val interface{}) { (*v)[i] = val.(*string) } func (v *stringVector) Set(i int, val interface{}) {
func (v *stringVector) At(i int) interface{} { return (*v)[i] } (*v)[i] = val.(*string)
func (v *stringVector) Len() int { return len(*v) } }
func (v *stringVector) Append(val interface{}) {
*v = append(*v, val.(*string))
}
func (v *stringVector) At(i int) interface{} {
return (*v)[i]
}
func (v *stringVector) Len() int {
return len(*v)
}
package dataframe package dataframe
import "time" import (
"time"
)
type timeVector []*time.Time type timeVector []*time.Time
...@@ -9,6 +11,18 @@ func newTimeVector(l int) *timeVector { ...@@ -9,6 +11,18 @@ func newTimeVector(l int) *timeVector {
return &v return &v
} }
func (v *timeVector) Set(i int, val interface{}) { (*v)[i] = val.(*time.Time) } func (v *timeVector) Set(i int, val interface{}) {
func (v *timeVector) At(i int) interface{} { return (*v)[i] } (*v)[i] = val.(*time.Time)
func (v *timeVector) Len() int { return len(*v) } }
func (v *timeVector) Append(val interface{}) {
*v = append(*v, val.(*time.Time))
}
func (v *timeVector) At(i int) interface{} {
return (*v)[i]
}
func (v *timeVector) Len() int {
return len(*v)
}
...@@ -3,6 +3,7 @@ package dataframe ...@@ -3,6 +3,7 @@ package dataframe
// Vector represents a collection of Elements. // Vector represents a collection of Elements.
type Vector interface { type Vector interface {
Set(idx int, i interface{}) Set(idx int, i interface{})
Append(i interface{})
At(i int) interface{} At(i int) interface{}
Len() int Len() int
} }
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
package pluginv2 package pluginv2
import proto "github.com/golang/protobuf/proto" import (
import fmt "fmt" fmt "fmt"
import math "math" proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
...@@ -16,7 +18,7 @@ var _ = math.Inf ...@@ -16,7 +18,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against. // is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the // A compilation error at this line likely means your copy of the
// proto package needs to be updated. // proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type TimeRange struct { type TimeRange struct {
FromRaw string `protobuf:"bytes,1,opt,name=fromRaw,proto3" json:"fromRaw,omitempty"` FromRaw string `protobuf:"bytes,1,opt,name=fromRaw,proto3" json:"fromRaw,omitempty"`
...@@ -32,16 +34,17 @@ func (m *TimeRange) Reset() { *m = TimeRange{} } ...@@ -32,16 +34,17 @@ func (m *TimeRange) Reset() { *m = TimeRange{} }
func (m *TimeRange) String() string { return proto.CompactTextString(m) } func (m *TimeRange) String() string { return proto.CompactTextString(m) }
func (*TimeRange) ProtoMessage() {} func (*TimeRange) ProtoMessage() {}
func (*TimeRange) Descriptor() ([]byte, []int) { func (*TimeRange) Descriptor() ([]byte, []int) {
return fileDescriptor_common_efe63640b8634961, []int{0} return fileDescriptor_555bd8c177793206, []int{0}
} }
func (m *TimeRange) XXX_Unmarshal(b []byte) error { func (m *TimeRange) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TimeRange.Unmarshal(m, b) return xxx_messageInfo_TimeRange.Unmarshal(m, b)
} }
func (m *TimeRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { func (m *TimeRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_TimeRange.Marshal(b, m, deterministic) return xxx_messageInfo_TimeRange.Marshal(b, m, deterministic)
} }
func (dst *TimeRange) XXX_Merge(src proto.Message) { func (m *TimeRange) XXX_Merge(src proto.Message) {
xxx_messageInfo_TimeRange.Merge(dst, src) xxx_messageInfo_TimeRange.Merge(m, src)
} }
func (m *TimeRange) XXX_Size() int { func (m *TimeRange) XXX_Size() int {
return xxx_messageInfo_TimeRange.Size(m) return xxx_messageInfo_TimeRange.Size(m)
...@@ -97,16 +100,17 @@ func (m *DatasourceInfo) Reset() { *m = DatasourceInfo{} } ...@@ -97,16 +100,17 @@ func (m *DatasourceInfo) Reset() { *m = DatasourceInfo{} }
func (m *DatasourceInfo) String() string { return proto.CompactTextString(m) } func (m *DatasourceInfo) String() string { return proto.CompactTextString(m) }
func (*DatasourceInfo) ProtoMessage() {} func (*DatasourceInfo) ProtoMessage() {}
func (*DatasourceInfo) Descriptor() ([]byte, []int) { func (*DatasourceInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_common_efe63640b8634961, []int{1} return fileDescriptor_555bd8c177793206, []int{1}
} }
func (m *DatasourceInfo) XXX_Unmarshal(b []byte) error { func (m *DatasourceInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DatasourceInfo.Unmarshal(m, b) return xxx_messageInfo_DatasourceInfo.Unmarshal(m, b)
} }
func (m *DatasourceInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { func (m *DatasourceInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DatasourceInfo.Marshal(b, m, deterministic) return xxx_messageInfo_DatasourceInfo.Marshal(b, m, deterministic)
} }
func (dst *DatasourceInfo) XXX_Merge(src proto.Message) { func (m *DatasourceInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_DatasourceInfo.Merge(dst, src) xxx_messageInfo_DatasourceInfo.Merge(m, src)
} }
func (m *DatasourceInfo) XXX_Size() int { func (m *DatasourceInfo) XXX_Size() int {
return xxx_messageInfo_DatasourceInfo.Size(m) return xxx_messageInfo_DatasourceInfo.Size(m)
...@@ -172,9 +176,9 @@ func init() { ...@@ -172,9 +176,9 @@ func init() {
proto.RegisterMapType((map[string]string)(nil), "pluginv2.DatasourceInfo.DecryptedSecureJsonDataEntry") proto.RegisterMapType((map[string]string)(nil), "pluginv2.DatasourceInfo.DecryptedSecureJsonDataEntry")
} }
func init() { proto.RegisterFile("common.proto", fileDescriptor_common_efe63640b8634961) } func init() { proto.RegisterFile("common.proto", fileDescriptor_555bd8c177793206) }
var fileDescriptor_common_efe63640b8634961 = []byte{ var fileDescriptor_555bd8c177793206 = []byte{
// 296 bytes of a gzipped FileDescriptorProto // 296 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xcf, 0x4a, 0xc3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xcf, 0x4a, 0xc3, 0x40,
0x10, 0xc6, 0x49, 0xb6, 0xff, 0x32, 0x95, 0x22, 0x8b, 0x60, 0x28, 0x3d, 0x84, 0x9e, 0x72, 0xca, 0x10, 0xc6, 0x49, 0xb6, 0xff, 0x32, 0x95, 0x22, 0x8b, 0x60, 0x28, 0x3d, 0x84, 0x9e, 0x72, 0xca,
......
...@@ -31,7 +31,7 @@ type QueryResult struct { ...@@ -31,7 +31,7 @@ type QueryResult struct {
// TransformHandler handles data source queries. // TransformHandler handles data source queries.
// Note: Arguments are sdk.Datasource objects // Note: Arguments are sdk.Datasource objects
type TransformHandler interface { type TransformHandler interface {
Transform(ctx context.Context, tr datasource.TimeRange, ds datasource.DataSourceInfo, queries []Query, api GrafanaAPIHandler) ([]QueryResult, error) Transform(ctx context.Context, tr datasource.TimeRange, queries []Query, api GrafanaAPIHandler) ([]QueryResult, error)
} }
// transformPluginWrapper converts protobuf types to sdk go types. // transformPluginWrapper converts protobuf types to sdk go types.
...@@ -52,15 +52,6 @@ func (p *transformPluginWrapper) Transform(ctx context.Context, req *pluginv2.Tr ...@@ -52,15 +52,6 @@ func (p *transformPluginWrapper) Transform(ctx context.Context, req *pluginv2.Tr
To: time.Unix(0, req.TimeRange.ToEpochMs*int64(time.Millisecond)), To: time.Unix(0, req.TimeRange.ToEpochMs*int64(time.Millisecond)),
} }
dsi := datasource.DataSourceInfo{
ID: req.Datasource.Id,
OrgID: req.Datasource.OrgId,
Name: req.Datasource.Name,
Type: req.Datasource.Type,
URL: req.Datasource.Url,
JSONData: json.RawMessage(req.Datasource.JsonData),
}
var queries []Query var queries []Query
for _, q := range req.Queries { for _, q := range req.Queries {
queries = append(queries, Query{ queries = append(queries, Query{
...@@ -72,7 +63,7 @@ func (p *transformPluginWrapper) Transform(ctx context.Context, req *pluginv2.Tr ...@@ -72,7 +63,7 @@ func (p *transformPluginWrapper) Transform(ctx context.Context, req *pluginv2.Tr
} }
// Makes SDK request, get SDK response // Makes SDK request, get SDK response
results, err := p.handler.Transform(ctx, tr, dsi, queries, &grafanaAPIWrapper{api: api}) results, err := p.handler.Transform(ctx, tr, queries, &grafanaAPIWrapper{api: api})
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -131,7 +131,7 @@ github.com/gosimple/slug ...@@ -131,7 +131,7 @@ github.com/gosimple/slug
# github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4 # github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4
github.com/grafana/grafana-plugin-model/go/datasource github.com/grafana/grafana-plugin-model/go/datasource
github.com/grafana/grafana-plugin-model/go/renderer github.com/grafana/grafana-plugin-model/go/renderer
# github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191029155514-4d93894a3f7a # github.com/grafana/grafana-plugin-sdk-go v0.0.0-20191105165811-c4e9ecfec89f
github.com/grafana/grafana-plugin-sdk-go/common github.com/grafana/grafana-plugin-sdk-go/common
github.com/grafana/grafana-plugin-sdk-go/dataframe github.com/grafana/grafana-plugin-sdk-go/dataframe
github.com/grafana/grafana-plugin-sdk-go/datasource github.com/grafana/grafana-plugin-sdk-go/datasource
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment