Convert Axis Bounds to []string

Due to various limitations with the previous implementation of Bounds as
a [2]int64{}, we've decided to change this to a []string{}. This will
allow clients to store arbitrary data specifying a bound and interpret
it as they wish.
pull/10616/head
Tim Raymond 2017-07-26 15:45:17 -04:00
parent 6a9bc36395
commit 2ff3e27e1f
7 changed files with 165 additions and 80 deletions

View File

@ -2,6 +2,7 @@ package internal
import (
"encoding/json"
"strconv"
"github.com/gogo/protobuf/proto"
"github.com/influxdata/chronograf"
@ -181,14 +182,14 @@ func MarshalDashboard(d chronograf.Dashboard) ([]byte, error) {
axes := make(map[string]*Axis, len(c.Axes))
for a, r := range c.Axes {
// need to explicitly allocate a new array because r.Bounds is
// over-written and the resulting slices from previous iterations will
// point to later iteration's data. It is _not_ enough to simply re-slice
// r.Bounds
// we only marshal LegacyBounds for a data migration test. This should
// not be used by anything in production.
axis := [2]int64{}
copy(axis[:], r.Bounds[:2])
copy(axis[:], r.LegacyBounds[:2])
axes[a] = &Axis{
Bounds: axis[:],
Bounds: r.Bounds,
LegacyBounds: axis[:],
}
}
@ -268,7 +269,14 @@ func UnmarshalDashboard(data []byte, d *chronograf.Dashboard) error {
axes := make(map[string]chronograf.Axis, len(c.Axes))
for a, r := range c.Axes {
axis := chronograf.Axis{}
copy(axis.Bounds[:], r.Bounds[:2])
// repair legacy bounds
for _, bound := range r.LegacyBounds {
axis.Bounds = append(axis.Bounds, strconv.FormatInt(bound, 10))
}
if len(r.Bounds) > 0 {
axis.Bounds = r.Bounds
}
axes[a] = axis
}

View File

@ -117,7 +117,8 @@ func (m *DashboardCell) GetAxes() map[string]*Axis {
}
type Axis struct {
Bounds []int64 `protobuf:"varint,1,rep,name=bounds" json:"bounds,omitempty"`
LegacyBounds []int64 `protobuf:"varint,1,rep,name=legacyBounds" json:"legacyBounds,omitempty"`
Bounds []string `protobuf:"bytes,2,rep,name=bounds" json:"bounds,omitempty"`
}
func (m *Axis) Reset() { *m = Axis{} }
@ -312,64 +313,65 @@ func init() {
func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) }
var fileDescriptorInternal = []byte{
// 935 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x56, 0xdd, 0x8e, 0xdb, 0x44,
0x14, 0xd6, 0xc4, 0x76, 0x12, 0x9f, 0x6d, 0x17, 0x34, 0xaa, 0xa8, 0x29, 0x12, 0x0a, 0x16, 0x48,
0x01, 0x89, 0x05, 0xb5, 0x42, 0x42, 0xdc, 0x65, 0x37, 0xa8, 0x0a, 0xbb, 0x2d, 0xcb, 0x64, 0x77,
0xb9, 0x42, 0xd5, 0x24, 0x39, 0xd9, 0xb5, 0xea, 0xd8, 0x66, 0x6c, 0x6f, 0xe2, 0x57, 0xe0, 0x8a,
0x27, 0x40, 0x42, 0xe2, 0x8a, 0x4b, 0x5e, 0x80, 0x87, 0xe0, 0x85, 0xd0, 0x99, 0x19, 0xff, 0x84,
0x6e, 0x51, 0xaf, 0x7a, 0x37, 0xdf, 0x39, 0x93, 0xef, 0x78, 0xbe, 0xf3, 0x9d, 0xa3, 0xc0, 0x61,
0x94, 0x14, 0xa8, 0x12, 0x19, 0x1f, 0x65, 0x2a, 0x2d, 0x52, 0x3e, 0xac, 0x71, 0xf8, 0x4b, 0x0f,
0xfa, 0xf3, 0xb4, 0x54, 0x4b, 0xe4, 0x87, 0xd0, 0x9b, 0x4d, 0x03, 0x36, 0x62, 0x63, 0x47, 0xf4,
0x66, 0x53, 0xce, 0xc1, 0x7d, 0x2e, 0x37, 0x18, 0xf4, 0x46, 0x6c, 0xec, 0x0b, 0x7d, 0xa6, 0xd8,
0x45, 0x95, 0x61, 0xe0, 0x98, 0x18, 0x9d, 0xf9, 0x23, 0x18, 0x5e, 0xe6, 0xc4, 0xb6, 0xc1, 0xc0,
0xd5, 0xf1, 0x06, 0x53, 0xee, 0x5c, 0xe6, 0xf9, 0x36, 0x55, 0xab, 0xc0, 0x33, 0xb9, 0x1a, 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 0x9b, 0xb1, 0x45, 0x5f, 0xff, 0x9b, 0x78, 0xf2, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa1,
0xf4, 0x45, 0x04, 0x5f, 0x08, 0x00, 0x00,
// 950 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x8e, 0xe3, 0x44,
0x10, 0x56, 0xc7, 0x76, 0x12, 0xd7, 0xcc, 0x0e, 0xa8, 0xb5, 0x62, 0xcd, 0x72, 0x09, 0x16, 0x48,
0x01, 0x89, 0x01, 0xed, 0x0a, 0x09, 0x71, 0x4b, 0x26, 0x68, 0x15, 0x66, 0x76, 0x19, 0x3a, 0x33,
0xc3, 0x09, 0xad, 0x3a, 0x49, 0x25, 0x63, 0xad, 0x13, 0x9b, 0xb6, 0x3d, 0x89, 0x5f, 0x81, 0x13,
0x4f, 0x80, 0x84, 0xc4, 0x89, 0x23, 0x2f, 0xc0, 0x43, 0xf0, 0x42, 0xa8, 0xba, 0xdb, 0x3f, 0x61,
0x67, 0xd1, 0x9e, 0xb8, 0xf5, 0x57, 0xd5, 0xf9, 0xda, 0xf5, 0xd5, 0x57, 0xa5, 0xc0, 0x49, 0xb4,
0xcd, 0x51, 0x6d, 0x65, 0x7c, 0x9a, 0xaa, 0x24, 0x4f, 0x78, 0xbf, 0xc2, 0xe1, 0xcf, 0x1d, 0xe8,
0xce, 0x92, 0x42, 0x2d, 0x90, 0x9f, 0x40, 0x67, 0x3a, 0x09, 0xd8, 0x80, 0x0d, 0x1d, 0xd1, 0x99,
0x4e, 0x38, 0x07, 0xf7, 0x85, 0xdc, 0x60, 0xd0, 0x19, 0xb0, 0xa1, 0x2f, 0xf4, 0x99, 0x62, 0x57,
0x65, 0x8a, 0x81, 0x63, 0x62, 0x74, 0xe6, 0x8f, 0xa1, 0x7f, 0x9d, 0x11, 0xdb, 0x06, 0x03, 0x57,
0xc7,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8c, 0x83,
0xfb, 0xed, 0xec, 0xbb, 0x17, 0xd5, 0x24, 0xd0, 0xb9, 0xf1, 0xaf, 0xf3, 0x2f, 0xff, 0x9e, 0xcb,
0x54, 0x4e, 0x27, 0xba, 0xb1, 0x8e, 0xb0, 0x28, 0xfc, 0x14, 0x5c, 0x9a, 0x93, 0x16, 0xb3, 0xfb,
0xa6, 0x19, 0x9b, 0x77, 0xf5, 0x3f, 0x8e, 0xa7, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x33, 0xaf,
0xb8, 0xb8, 0x83, 0x08, 0x00, 0x00,
}

View File

@ -34,7 +34,8 @@ message DashboardCell {
}
message Axis {
repeated int64 bounds = 1; // bounds are an ordered 2-tuple consisting of lower and upper axis extents, respectively
repeated int64 legacyBounds = 1; // legacyBounds are an ordered 2-tuple consisting of lower and upper axis extents, respectively
repeated string bounds = 2; // bounds are an arbitrary list of client-defined bounds.
}
message Template {

View File

@ -128,7 +128,7 @@ func Test_MarshalDashboard(t *testing.T) {
},
Axes: map[string]chronograf.Axis{
"y": chronograf.Axis{
Bounds: [2]int64{0, 100},
Bounds: []string{"0", "3", "1-7", "foo"},
},
},
Type: "line",
@ -147,3 +147,76 @@ func Test_MarshalDashboard(t *testing.T) {
t.Fatalf("Dashboard protobuf copy error: diff follows:\n%s", cmp.Diff(dashboard, actual))
}
}
func Test_MarshalDashboard_WithLegacyBounds(t *testing.T) {
dashboard := chronograf.Dashboard{
ID: 1,
Cells: []chronograf.DashboardCell{
{
ID: "9b5367de-c552-4322-a9e8-7f384cbd235c",
X: 0,
Y: 0,
W: 4,
H: 4,
Name: "Super awesome query",
Queries: []chronograf.DashboardQuery{
{
Command: "select * from cpu",
Label: "CPU Utilization",
Range: &chronograf.Range{
Upper: int64(100),
},
},
},
Axes: map[string]chronograf.Axis{
"y": chronograf.Axis{
LegacyBounds: [2]int64{0, 5},
},
},
Type: "line",
},
},
Templates: []chronograf.Template{},
Name: "Dashboard",
}
expected := chronograf.Dashboard{
ID: 1,
Cells: []chronograf.DashboardCell{
{
ID: "9b5367de-c552-4322-a9e8-7f384cbd235c",
X: 0,
Y: 0,
W: 4,
H: 4,
Name: "Super awesome query",
Queries: []chronograf.DashboardQuery{
{
Command: "select * from cpu",
Label: "CPU Utilization",
Range: &chronograf.Range{
Upper: int64(100),
},
},
},
Axes: map[string]chronograf.Axis{
"y": chronograf.Axis{
Bounds: []string{"0", "5"},
},
},
Type: "line",
},
},
Templates: []chronograf.Template{},
Name: "Dashboard",
}
var actual chronograf.Dashboard
if buf, err := internal.MarshalDashboard(dashboard); err != nil {
t.Fatal("Error marshaling dashboard: err", err)
} else if err := internal.UnmarshalDashboard(buf, &actual); err != nil {
t.Fatal("Error unmarshaling dashboard: err:", err)
} else if !cmp.Equal(expected, actual) {
t.Fatalf("Dashboard protobuf copy error: diff follows:\n%s", cmp.Diff(expected, actual))
}
}

View File

@ -568,7 +568,8 @@ type Dashboard struct {
// Axis represents the visible extents of a visualization
type Axis struct {
Bounds [2]int64 `json:"bounds"` // bounds are an ordered 2-tuple consisting of lower and upper axis extents, respectively
Bounds []string `json:"bounds"` // bounds are an arbitrary list of client-defined strings that specify the viewport for a cell
LegacyBounds [2]int64 `json:"-"` // legacy bounds are for testing a migration from an earlier version of axis
}
// DashboardCell holds visual and query information for a cell

View File

@ -20,13 +20,13 @@ func Test_Cells_CorrectAxis(t *testing.T) {
&chronograf.DashboardCell{
Axes: map[string]chronograf.Axis{
"x": chronograf.Axis{
Bounds: [2]int64{0, 100},
Bounds: []string{"0", "100"},
},
"y": chronograf.Axis{
Bounds: [2]int64{0, 100},
Bounds: []string{"0", "100"},
},
"y2": chronograf.Axis{
Bounds: [2]int64{0, 100},
Bounds: []string{"0", "100"},
},
},
},
@ -37,10 +37,10 @@ func Test_Cells_CorrectAxis(t *testing.T) {
&chronograf.DashboardCell{
Axes: map[string]chronograf.Axis{
"axis of evil": chronograf.Axis{
Bounds: [2]int64{666, 666},
Bounds: []string{"666", "666"},
},
"axis of awesome": chronograf.Axis{
Bounds: [2]int64{1337, 31337},
Bounds: []string{"1337", "31337"},
},
},
},

View File

@ -222,10 +222,10 @@ func Test_newDashboardResponse(t *testing.T) {
},
Axes: map[string]chronograf.Axis{
"x": chronograf.Axis{
Bounds: [2]int64{0, 100},
Bounds: []string{"0", "100"},
},
"y": chronograf.Axis{
Bounds: [2]int64{2, 95},
Bounds: []string{"2", "95"},
},
},
},
@ -268,10 +268,10 @@ func Test_newDashboardResponse(t *testing.T) {
},
Axes: map[string]chronograf.Axis{
"x": chronograf.Axis{
Bounds: [2]int64{0, 100},
Bounds: []string{"0", "100"},
},
"y": chronograf.Axis{
Bounds: [2]int64{2, 95},
Bounds: []string{"2", "95"},
},
},
},