Merge pull request #13679 from mjtrangoni/fix-megacheck-issues
Fix megacheck issues
This commit is contained in:
+1
-1
@@ -185,7 +185,7 @@ func (a *ldapAuther) GetGrafanaUserFor(ctx *m.ReqContext, ldapUser *LdapUserInfo
|
||||
|
||||
if ldapUser.isMemberOf(group.GroupDN) {
|
||||
extUser.OrgRoles[group.OrgId] = group.OrgRole
|
||||
if extUser.IsGrafanaAdmin == nil || *extUser.IsGrafanaAdmin == false {
|
||||
if extUser.IsGrafanaAdmin == nil || !*extUser.IsGrafanaAdmin {
|
||||
extUser.IsGrafanaAdmin = group.IsGrafanaAdmin
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,12 +43,13 @@ func GetContextHandler() macaron.Handler {
|
||||
// then init session and look for userId in session
|
||||
// then look for api key in session (special case for render calls via api)
|
||||
// then test if anonymous access is enabled
|
||||
if initContextWithRenderAuth(ctx) ||
|
||||
initContextWithApiKey(ctx) ||
|
||||
initContextWithBasicAuth(ctx, orgId) ||
|
||||
initContextWithAuthProxy(ctx, orgId) ||
|
||||
initContextWithUserSessionCookie(ctx, orgId) ||
|
||||
initContextWithAnonymousUser(ctx) {
|
||||
switch {
|
||||
case initContextWithRenderAuth(ctx):
|
||||
case initContextWithApiKey(ctx):
|
||||
case initContextWithBasicAuth(ctx, orgId):
|
||||
case initContextWithAuthProxy(ctx, orgId):
|
||||
case initContextWithUserSessionCookie(ctx, orgId):
|
||||
case initContextWithAnonymousUser(ctx):
|
||||
}
|
||||
|
||||
ctx.Logger = log.New("context", "userId", ctx.UserId, "orgId", ctx.OrgId, "uname", ctx.Login)
|
||||
|
||||
@@ -121,7 +121,6 @@ func (pm *PluginManager) Run(ctx context.Context) error {
|
||||
pm.checkForUpdates()
|
||||
case <-ctx.Done():
|
||||
run = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,8 @@ func NewRuleReader() *DefaultRuleReader {
|
||||
func (arr *DefaultRuleReader) initReader() {
|
||||
heartbeat := time.NewTicker(time.Second * 10)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-heartbeat.C:
|
||||
arr.heartbeat()
|
||||
}
|
||||
for range heartbeat.C {
|
||||
arr.heartbeat()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,14 +164,12 @@ func formatTimeRange(input string) string {
|
||||
|
||||
func fixIntervalFormat(target string) string {
|
||||
rMinute := regexp.MustCompile(`'(\d+)m'`)
|
||||
rMin := regexp.MustCompile("m")
|
||||
target = rMinute.ReplaceAllStringFunc(target, func(m string) string {
|
||||
return rMin.ReplaceAllString(m, "min")
|
||||
return strings.Replace(m, "m", "min", -1)
|
||||
})
|
||||
rMonth := regexp.MustCompile(`'(\d+)M'`)
|
||||
rMon := regexp.MustCompile("M")
|
||||
target = rMonth.ReplaceAllStringFunc(target, func(M string) string {
|
||||
return rMon.ReplaceAllString(M, "mon")
|
||||
return strings.Replace(M, "M", "mon", -1)
|
||||
})
|
||||
return target
|
||||
}
|
||||
|
||||
@@ -186,8 +186,7 @@ func reverse(s string) string {
|
||||
}
|
||||
|
||||
func interpolateFilterWildcards(value string) string {
|
||||
re := regexp.MustCompile("[*]")
|
||||
matches := len(re.FindAllStringIndex(value, -1))
|
||||
matches := strings.Count(value, "*")
|
||||
if matches == 2 && strings.HasSuffix(value, "*") && strings.HasPrefix(value, "*") {
|
||||
value = strings.Replace(value, "*", "", -1)
|
||||
value = fmt.Sprintf(`has_substring("%s")`, value)
|
||||
|
||||
Reference in New Issue
Block a user