From b900fead753504246f49596c684ee0a03e8df112 Mon Sep 17 00:00:00 2001 From: ebb-tide Date: Mon, 2 Jul 2018 17:45:44 -0700 Subject: [PATCH] Add map as a template variable value type to the backend --- bolt/internal/internal.proto | 2 +- chronograf.go | 4 ++-- server/swagger.json | 2 +- server/templates.go | 2 +- server/templates_test.go | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bolt/internal/internal.proto b/bolt/internal/internal.proto index 27dec2513c..f11b3bc833 100644 --- a/bolt/internal/internal.proto +++ b/bolt/internal/internal.proto @@ -97,7 +97,7 @@ message Template { } message TemplateValue { - string type = 1; // Type can be tagKey, tagValue, fieldKey, csv, measurement, database, constant + string type = 1; // Type can be tagKey, tagValue, fieldKey, csv, map, measurement, database, constant string value = 2; // Value is the specific value used to replace a template in an InfluxQL query bool selected = 3; // Selected states that this variable has been picked to use for replacement string key = 4; // Key is the key for a specific Value if the Template Type is map (optional) diff --git a/chronograf.go b/chronograf.go index 8a1c54f47d..3f83f8f950 100644 --- a/chronograf.go +++ b/chronograf.go @@ -159,7 +159,7 @@ type Range struct { // TemplateValue is a value use to replace a template in an InfluxQL query type TemplateValue struct { Value string `json:"value"` // Value is the specific value used to replace a template in an InfluxQL query - Type string `json:"type"` // Type can be tagKey, tagValue, fieldKey, csv, measurement, database, constant, influxql + Type string `json:"type"` // Type can be tagKey, tagValue, fieldKey, csv, map, measurement, database, constant, influxql Selected bool `json:"selected"` // Selected states that this variable has been picked to use for replacement Key string `json:"key,omitempty"` // Key is the key for the Value if the Template Type is 'map' } @@ -177,7 +177,7 @@ type TemplateID string type Template struct { TemplateVar ID TemplateID `json:"id"` // ID is the unique ID associated with this template - Type string `json:"type"` // Type can be fieldKeys, tagKeys, tagValues, CSV, constant, measurements, databases, map, influxql + Type string `json:"type"` // Type can be fieldKeys, tagKeys, tagValues, csv, constant, measurements, databases, map, influxql Label string `json:"label"` // Label is a user-facing description of the Template Query *TemplateQuery `json:"query,omitempty"` // Query is used to generate the choices for a template } diff --git a/server/swagger.json b/server/swagger.json index bb591d4927..968ef9b2c8 100644 --- a/server/swagger.json +++ b/server/swagger.json @@ -4178,7 +4178,7 @@ }, "type": { "type": "string", - "enum": ["csv", "tagKey", "tagValue", "fieldKey", "timeStamp"], + "enum": ["csv", "tagKey", "tagValue", "fieldKey", "timeStamp", "map"], "description": "The type will change the format of the output value. tagKey/fieldKey are double quoted; tagValue are single quoted; csv and timeStamp are not quoted." }, diff --git a/server/templates.go b/server/templates.go index 6f158ac3c3..fcb7a365e1 100644 --- a/server/templates.go +++ b/server/templates.go @@ -22,7 +22,7 @@ func ValidTemplateRequest(template *chronograf.Template) error { switch v.Type { default: return fmt.Errorf("Unknown template variable type %s", v.Type) - case "csv", "fieldKey", "tagKey", "tagValue", "measurement", "database", "constant", "influxql": + case "csv", "map", "fieldKey", "tagKey", "tagValue", "measurement", "database", "constant", "influxql": } if template.Type == "map" && v.Key == "" { diff --git a/server/templates_test.go b/server/templates_test.go index cd775acea9..4a23fefefd 100644 --- a/server/templates_test.go +++ b/server/templates_test.go @@ -69,7 +69,7 @@ func TestValidTemplateRequest(t *testing.T) { { Key: "key", Value: "value", - Type: "constant", + Type: "map", }, }, }, @@ -84,7 +84,7 @@ func TestValidTemplateRequest(t *testing.T) { Values: []chronograf.TemplateValue{ { Value: "value", - Type: "constant", + Type: "map", }, }, },