| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | package plugins | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2016-03-12 17:13:49 +08:00
										 |  |  | 	"encoding/json" | 
					
						
							| 
									
										
										
										
											2016-03-12 06:28:33 +08:00
										 |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"regexp" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/bus" | 
					
						
							| 
									
										
										
										
											2016-03-12 07:13:06 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/components/simplejson" | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	m "github.com/grafana/grafana/pkg/models" | 
					
						
							| 
									
										
										
										
											2018-02-19 18:12:56 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/dashboards" | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type ImportDashboardCommand struct { | 
					
						
							| 
									
										
										
										
											2016-05-14 16:00:43 +08:00
										 |  |  | 	Dashboard *simplejson.Json | 
					
						
							| 
									
										
										
										
											2016-04-26 18:52:44 +08:00
										 |  |  | 	Path      string | 
					
						
							|  |  |  | 	Inputs    []ImportDashboardInput | 
					
						
							|  |  |  | 	Overwrite bool | 
					
						
							| 
									
										
										
										
											2018-06-05 02:29:14 +08:00
										 |  |  | 	FolderId  int64 | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-26 18:52:44 +08:00
										 |  |  | 	OrgId    int64 | 
					
						
							| 
									
										
										
										
											2018-02-19 18:12:56 +08:00
										 |  |  | 	User     *m.SignedInUser | 
					
						
							| 
									
										
										
										
											2016-04-26 18:52:44 +08:00
										 |  |  | 	PluginId string | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	Result   *PluginDashboardInfoDTO | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type ImportDashboardInput struct { | 
					
						
							|  |  |  | 	Type     string `json:"type"` | 
					
						
							|  |  |  | 	PluginId string `json:"pluginId"` | 
					
						
							|  |  |  | 	Name     string `json:"name"` | 
					
						
							|  |  |  | 	Value    string `json:"value"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 06:28:33 +08:00
										 |  |  | type DashboardInputMissingError struct { | 
					
						
							|  |  |  | 	VariableName string | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (e DashboardInputMissingError) Error() string { | 
					
						
							| 
									
										
										
										
											2018-02-19 21:44:20 +08:00
										 |  |  | 	return fmt.Sprintf("Dashboard input variable: %v missing from import command", e.VariableName) | 
					
						
							| 
									
										
										
										
											2016-03-12 06:28:33 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | func init() { | 
					
						
							|  |  |  | 	bus.AddHandler("plugins", ImportDashboard) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func ImportDashboard(cmd *ImportDashboardCommand) error { | 
					
						
							|  |  |  | 	var dashboard *m.Dashboard | 
					
						
							|  |  |  | 	var err error | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 16:00:43 +08:00
										 |  |  | 	if cmd.PluginId != "" { | 
					
						
							|  |  |  | 		if dashboard, err = loadPluginDashboard(cmd.PluginId, cmd.Path); err != nil { | 
					
						
							|  |  |  | 			return err | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		dashboard = m.NewDashboardFromJson(cmd.Dashboard) | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 06:28:33 +08:00
										 |  |  | 	evaluator := &DashTemplateEvaluator{ | 
					
						
							| 
									
										
										
										
											2016-03-12 07:13:06 +08:00
										 |  |  | 		template: dashboard.Data, | 
					
						
							| 
									
										
										
										
											2016-03-12 06:28:33 +08:00
										 |  |  | 		inputs:   cmd.Inputs, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	generatedDash, err := evaluator.Eval() | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	saveCmd := m.SaveDashboardCommand{ | 
					
						
							| 
									
										
										
										
											2016-03-12 07:13:06 +08:00
										 |  |  | 		Dashboard: generatedDash, | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 		OrgId:     cmd.OrgId, | 
					
						
							| 
									
										
										
										
											2018-02-19 18:12:56 +08:00
										 |  |  | 		UserId:    cmd.User.UserId, | 
					
						
							| 
									
										
										
										
											2016-04-26 18:52:44 +08:00
										 |  |  | 		Overwrite: cmd.Overwrite, | 
					
						
							| 
									
										
										
										
											2016-07-08 18:26:51 +08:00
										 |  |  | 		PluginId:  cmd.PluginId, | 
					
						
							| 
									
										
										
										
											2018-06-05 02:29:14 +08:00
										 |  |  | 		FolderId:  cmd.FolderId, | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-19 18:12:56 +08:00
										 |  |  | 	dto := &dashboards.SaveDashboardDTO{ | 
					
						
							|  |  |  | 		OrgId:     cmd.OrgId, | 
					
						
							|  |  |  | 		Dashboard: saveCmd.GetDashboardModel(), | 
					
						
							|  |  |  | 		Overwrite: saveCmd.Overwrite, | 
					
						
							|  |  |  | 		User:      cmd.User, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-14 21:24:56 +08:00
										 |  |  | 	savedDash, err := dashboards.NewService().ImportDashboard(dto) | 
					
						
							| 
									
										
										
										
											2018-02-19 18:12:56 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 		return err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	cmd.Result = &PluginDashboardInfoDTO{ | 
					
						
							| 
									
										
										
										
											2016-05-14 16:00:43 +08:00
										 |  |  | 		PluginId:         cmd.PluginId, | 
					
						
							| 
									
										
										
										
											2018-02-19 18:12:56 +08:00
										 |  |  | 		Title:            savedDash.Title, | 
					
						
							| 
									
										
										
										
											2016-05-14 16:00:43 +08:00
										 |  |  | 		Path:             cmd.Path, | 
					
						
							| 
									
										
										
										
											2018-02-19 18:12:56 +08:00
										 |  |  | 		Revision:         savedDash.Data.Get("revision").MustInt64(1), | 
					
						
							| 
									
										
										
										
											2018-06-05 02:29:14 +08:00
										 |  |  | 		FolderId:         savedDash.FolderId, | 
					
						
							| 
									
										
										
										
											2018-02-19 18:12:56 +08:00
										 |  |  | 		ImportedUri:      "db/" + savedDash.Slug, | 
					
						
							|  |  |  | 		ImportedUrl:      savedDash.GetUrl(), | 
					
						
							| 
									
										
										
										
											2016-05-14 16:00:43 +08:00
										 |  |  | 		ImportedRevision: dashboard.Data.Get("revision").MustInt64(1), | 
					
						
							|  |  |  | 		Imported:         true, | 
					
						
							| 
									
										
										
										
											2019-10-08 23:47:18 +08:00
										 |  |  | 		DashboardId:      savedDash.Id, | 
					
						
							|  |  |  | 		Slug:             savedDash.Slug, | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type DashTemplateEvaluator struct { | 
					
						
							| 
									
										
										
										
											2016-03-12 07:13:06 +08:00
										 |  |  | 	template  *simplejson.Json | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	inputs    []ImportDashboardInput | 
					
						
							|  |  |  | 	variables map[string]string | 
					
						
							| 
									
										
										
										
											2016-03-12 07:13:06 +08:00
										 |  |  | 	result    *simplejson.Json | 
					
						
							| 
									
										
										
										
											2016-03-12 06:28:33 +08:00
										 |  |  | 	varRegex  *regexp.Regexp | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 17:40:55 +08:00
										 |  |  | func (this *DashTemplateEvaluator) findInput(varName string, varType string) *ImportDashboardInput { | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for _, input := range this.inputs { | 
					
						
							| 
									
										
										
										
											2016-03-12 17:40:55 +08:00
										 |  |  | 		if varType == input.Type && (input.Name == varName || input.Name == "*") { | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 			return &input | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 07:13:06 +08:00
										 |  |  | func (this *DashTemplateEvaluator) Eval() (*simplejson.Json, error) { | 
					
						
							|  |  |  | 	this.result = simplejson.New() | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	this.variables = make(map[string]string) | 
					
						
							| 
									
										
										
										
											2016-05-17 16:29:57 +08:00
										 |  |  | 	this.varRegex, _ = regexp.Compile(`(\$\{.+\})`) | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// check that we have all inputs we need
 | 
					
						
							| 
									
										
										
										
											2016-03-12 17:40:55 +08:00
										 |  |  | 	for _, inputDef := range this.template.Get("__inputs").MustArray() { | 
					
						
							|  |  |  | 		inputDefJson := simplejson.NewFromAny(inputDef) | 
					
						
							|  |  |  | 		inputName := inputDefJson.Get("name").MustString() | 
					
						
							|  |  |  | 		inputType := inputDefJson.Get("type").MustString() | 
					
						
							|  |  |  | 		input := this.findInput(inputName, inputType) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if input == nil { | 
					
						
							|  |  |  | 			return nil, &DashboardInputMissingError{VariableName: inputName} | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-03-12 17:40:55 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		this.variables["${"+inputName+"}"] = input.Value | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 17:13:49 +08:00
										 |  |  | 	return simplejson.NewFromAny(this.evalObject(this.template)), nil | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 17:13:49 +08:00
										 |  |  | func (this *DashTemplateEvaluator) evalValue(source *simplejson.Json) interface{} { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sourceValue := source.Interface() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch v := sourceValue.(type) { | 
					
						
							|  |  |  | 	case string: | 
					
						
							|  |  |  | 		interpolated := this.varRegex.ReplaceAllStringFunc(v, func(match string) string { | 
					
						
							| 
									
										
											  
											
												Outdent code after if block that ends with return (golint)
This commit fixes the following golint warnings:
pkg/bus/bus.go:64:9: if block ends with a return statement, so drop this else and outdent its block
pkg/bus/bus.go:84:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:137:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:177:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:183:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:199:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:208:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/components/dynmap/dynmap.go:236:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:242:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:257:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:263:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:278:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:284:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:299:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:331:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:350:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:356:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:366:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:390:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:396:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:405:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:427:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:433:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:442:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:459:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:465:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:474:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:491:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:497:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:506:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:523:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:529:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:538:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:555:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:561:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:570:12: if block ends with a return statement, so drop this else and outdent its block
pkg/login/ldap.go:55:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/login/ldap_test.go:372:10: if block ends with a return statement, so drop this else and outdent its block
pkg/middleware/middleware_test.go:213:12: if block ends with a return statement, so drop this else and outdent its block
pkg/plugins/dashboard_importer.go:153:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/dashboards_updater.go:39:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/dashboards_updater.go:121:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/plugins.go:210:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/plugins.go:235:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/eval_context.go:111:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:92:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:98:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:122:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:108:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:118:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:121:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifiers/telegram.go:94:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/annotation.go:34:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/annotation.go:99:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/dashboard_test.go:107:13: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/plugin_setting.go:78:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/preferences.go:91:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/user.go:50:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/migrator/migrator.go:106:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/migrator/postgres_dialect.go:48:10: if block ends with a return statement, so drop this else and outdent its block
pkg/tsdb/time_range.go:59:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/tsdb/time_range.go:67:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/tsdb/cloudwatch/metric_find_query.go:225:9: if block ends with a return statement, so drop this else and outdent its block
pkg/util/filepath.go:68:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
											
										 
											2018-04-28 04:42:49 +08:00
										 |  |  | 			replacement, exists := this.variables[match] | 
					
						
							|  |  |  | 			if exists { | 
					
						
							| 
									
										
										
										
											2016-03-12 17:40:55 +08:00
										 |  |  | 				return replacement | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
											  
											
												Outdent code after if block that ends with return (golint)
This commit fixes the following golint warnings:
pkg/bus/bus.go:64:9: if block ends with a return statement, so drop this else and outdent its block
pkg/bus/bus.go:84:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:137:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:177:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:183:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:199:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:208:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/components/dynmap/dynmap.go:236:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:242:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:257:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:263:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:278:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:284:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:299:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:331:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:350:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:356:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:366:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:390:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:396:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:405:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:427:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:433:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:442:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:459:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:465:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:474:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:491:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:497:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:506:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:523:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:529:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:538:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:555:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:561:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:570:12: if block ends with a return statement, so drop this else and outdent its block
pkg/login/ldap.go:55:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/login/ldap_test.go:372:10: if block ends with a return statement, so drop this else and outdent its block
pkg/middleware/middleware_test.go:213:12: if block ends with a return statement, so drop this else and outdent its block
pkg/plugins/dashboard_importer.go:153:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/dashboards_updater.go:39:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/dashboards_updater.go:121:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/plugins.go:210:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/plugins.go:235:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/eval_context.go:111:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:92:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:98:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:122:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:108:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:118:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:121:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifiers/telegram.go:94:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/annotation.go:34:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/annotation.go:99:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/dashboard_test.go:107:13: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/plugin_setting.go:78:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/preferences.go:91:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/user.go:50:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/migrator/migrator.go:106:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/migrator/postgres_dialect.go:48:10: if block ends with a return statement, so drop this else and outdent its block
pkg/tsdb/time_range.go:59:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/tsdb/time_range.go:67:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/tsdb/cloudwatch/metric_find_query.go:225:9: if block ends with a return statement, so drop this else and outdent its block
pkg/util/filepath.go:68:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
											
										 
											2018-04-28 04:42:49 +08:00
										 |  |  | 			return match | 
					
						
							| 
									
										
										
										
											2016-03-12 17:13:49 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 		return interpolated | 
					
						
							|  |  |  | 	case bool: | 
					
						
							|  |  |  | 		return v | 
					
						
							|  |  |  | 	case json.Number: | 
					
						
							|  |  |  | 		return v | 
					
						
							|  |  |  | 	case map[string]interface{}: | 
					
						
							|  |  |  | 		return this.evalObject(source) | 
					
						
							|  |  |  | 	case []interface{}: | 
					
						
							|  |  |  | 		array := make([]interface{}, 0) | 
					
						
							|  |  |  | 		for _, item := range v { | 
					
						
							|  |  |  | 			array = append(array, this.evalValue(simplejson.NewFromAny(item))) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return array | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (this *DashTemplateEvaluator) evalObject(source *simplejson.Json) interface{} { | 
					
						
							|  |  |  | 	result := make(map[string]interface{}) | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 07:13:06 +08:00
										 |  |  | 	for key, value := range source.MustMap() { | 
					
						
							| 
									
										
										
										
											2016-03-12 06:28:33 +08:00
										 |  |  | 		if key == "__inputs" { | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 			continue | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-03-12 17:13:49 +08:00
										 |  |  | 		result[key] = this.evalValue(simplejson.NewFromAny(value)) | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-03-12 17:13:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return result | 
					
						
							| 
									
										
										
										
											2016-03-12 00:31:57 +08:00
										 |  |  | } |