Commit 9dac602e by Carl Bergquist Committed by GitHub

Merge pull request #9191 from wgliang/master

Optimize some wrong usage and spelling
parents e98254e1 652fce7e
...@@ -166,9 +166,7 @@ func handleGetNamespaces(req *cwRequest, c *middleware.Context) { ...@@ -166,9 +166,7 @@ func handleGetNamespaces(req *cwRequest, c *middleware.Context) {
customNamespaces := req.DataSource.JsonData.Get("customMetricsNamespaces").MustString() customNamespaces := req.DataSource.JsonData.Get("customMetricsNamespaces").MustString()
if customNamespaces != "" { if customNamespaces != "" {
for _, key := range strings.Split(customNamespaces, ",") { keys = append(keys, strings.Split(customNamespaces, ",")...)
keys = append(keys, key)
}
} }
sort.Sort(sort.StringSlice(keys)) sort.Sort(sort.StringSlice(keys))
......
...@@ -231,7 +231,7 @@ func (b *BasicDiff) Basic(lines []*JSONLine) []*BasicBlock { ...@@ -231,7 +231,7 @@ func (b *BasicDiff) Basic(lines []*JSONLine) []*BasicBlock {
// in the JSON document to a top level key. // in the JSON document to a top level key.
// //
// In order to produce distinct "blocks" when rendering the basic diff, // In order to produce distinct "blocks" when rendering the basic diff,
// we need a way to distinguish between differnt sections of data. // we need a way to distinguish between different sections of data.
// To do this, we consider the value(s) of each top-level JSON key to // To do this, we consider the value(s) of each top-level JSON key to
// represent a distinct block for Grafana's JSON data structure, so // represent a distinct block for Grafana's JSON data structure, so
// we perform this check to see if we've entered a new "block". If we // we perform this check to see if we've entered a new "block". If we
......
...@@ -302,16 +302,16 @@ func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, posi ...@@ -302,16 +302,16 @@ func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, posi
return nil return nil
} }
func (f *JSONFormatter) searchDeltas(deltas []diff.Delta, postion diff.Position) (results []diff.Delta) { func (f *JSONFormatter) searchDeltas(deltas []diff.Delta, position diff.Position) (results []diff.Delta) {
results = make([]diff.Delta, 0) results = make([]diff.Delta, 0)
for _, delta := range deltas { for _, delta := range deltas {
switch delta.(type) { switch delta.(type) {
case diff.PostDelta: case diff.PostDelta:
if delta.(diff.PostDelta).PostPosition() == postion { if delta.(diff.PostDelta).PostPosition() == position {
results = append(results, delta) results = append(results, delta)
} }
case diff.PreDelta: case diff.PreDelta:
if delta.(diff.PreDelta).PrePosition() == postion { if delta.(diff.PreDelta).PrePosition() == position {
results = append(results, delta) results = append(results, delta)
} }
default: default:
......
...@@ -33,8 +33,8 @@ func AuthenticateUser(query *LoginUserQuery) error { ...@@ -33,8 +33,8 @@ func AuthenticateUser(query *LoginUserQuery) error {
if setting.LdapEnabled { if setting.LdapEnabled {
for _, server := range LdapCfg.Servers { for _, server := range LdapCfg.Servers {
auther := NewLdapAuthenticator(server) author := NewLdapAuthenticator(server)
err = auther.Login(query) err = author.Login(query)
if err == nil || err != ErrInvalidCredentials { if err == nil || err != ErrInvalidCredentials {
return err return err
} }
......
...@@ -67,7 +67,7 @@ func initContextWithAuthProxy(ctx *Context, orgId int64) bool { ...@@ -67,7 +67,7 @@ func initContextWithAuthProxy(ctx *Context, orgId int64) bool {
if getRequestUserId(ctx) > 0 && getRequestUserId(ctx) != query.Result.UserId { if getRequestUserId(ctx) > 0 && getRequestUserId(ctx) != query.Result.UserId {
// remove session // remove session
if err := ctx.Session.Destory(ctx); err != nil { if err := ctx.Session.Destory(ctx); err != nil {
log.Error(3, "Failed to destory session, err") log.Error(3, "Failed to destroy session, err")
} }
// initialize a new session // initialize a new session
...@@ -107,8 +107,8 @@ var syncGrafanaUserWithLdapUser = func(ctx *Context, query *m.GetSignedInUserQue ...@@ -107,8 +107,8 @@ var syncGrafanaUserWithLdapUser = func(ctx *Context, query *m.GetSignedInUserQue
ldapCfg := login.LdapCfg ldapCfg := login.LdapCfg
for _, server := range ldapCfg.Servers { for _, server := range ldapCfg.Servers {
auther := login.NewLdapAuthenticator(server) author := login.NewLdapAuthenticator(server)
if err := auther.SyncSignedInUser(query.Result); err != nil { if err := author.SyncSignedInUser(query.Result); err != nil {
return err return err
} }
} }
......
...@@ -71,7 +71,7 @@ func TestWildcardExpansion(t *testing.T) { ...@@ -71,7 +71,7 @@ func TestWildcardExpansion(t *testing.T) {
So(expandeQueries[0].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.3.idle`|aggregate.min|aggregate.max where cluster in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to)) So(expandeQueries[0].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.3.idle`|aggregate.min|aggregate.max where cluster in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to))
}) })
Convey("Containg wildcard series", func() { Convey("Containing wildcard series", func() {
query := &Query{ query := &Query{
Metrics: []Metric{ Metrics: []Metric{
{Metric: "os.cpu*", Alias: ""}, {Metric: "os.cpu*", Alias: ""},
......
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