Add map as a template variable value type to the backend

pull/10616/head
ebb-tide 2018-07-02 17:45:44 -07:00
parent 475ab5ed5f
commit b900fead75
5 changed files with 7 additions and 7 deletions

View File

@ -97,7 +97,7 @@ message Template {
} }
message TemplateValue { 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 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 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) string key = 4; // Key is the key for a specific Value if the Template Type is map (optional)

View File

@ -159,7 +159,7 @@ type Range struct {
// TemplateValue is a value use to replace a template in an InfluxQL query // TemplateValue is a value use to replace a template in an InfluxQL query
type TemplateValue struct { type TemplateValue struct {
Value string `json:"value"` // Value is the specific value used to replace a template in an InfluxQL query 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 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' 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 { type Template struct {
TemplateVar TemplateVar
ID TemplateID `json:"id"` // ID is the unique ID associated with this template 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 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 Query *TemplateQuery `json:"query,omitempty"` // Query is used to generate the choices for a template
} }

View File

@ -4178,7 +4178,7 @@
}, },
"type": { "type": {
"type": "string", "type": "string",
"enum": ["csv", "tagKey", "tagValue", "fieldKey", "timeStamp"], "enum": ["csv", "tagKey", "tagValue", "fieldKey", "timeStamp", "map"],
"description": "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." "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."
}, },

View File

@ -22,7 +22,7 @@ func ValidTemplateRequest(template *chronograf.Template) error {
switch v.Type { switch v.Type {
default: default:
return fmt.Errorf("Unknown template variable type %s", v.Type) 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 == "" { if template.Type == "map" && v.Key == "" {

View File

@ -69,7 +69,7 @@ func TestValidTemplateRequest(t *testing.T) {
{ {
Key: "key", Key: "key",
Value: "value", Value: "value",
Type: "constant", Type: "map",
}, },
}, },
}, },
@ -84,7 +84,7 @@ func TestValidTemplateRequest(t *testing.T) {
Values: []chronograf.TemplateValue{ Values: []chronograf.TemplateValue{
{ {
Value: "value", Value: "value",
Type: "constant", Type: "map",
}, },
}, },
}, },