Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
6eb00000
Commit
6eb00000
authored
Apr 23, 2018
by
Mario Trangoni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/services: fix ineffassign issues
parent
3a48ea8d
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
28 additions
and
35 deletions
+28
-35
pkg/services/alerting/notifiers/telegram.go
+7
-3
pkg/services/alerting/notifiers/victorops.go
+0
-21
pkg/services/guardian/guardian_test.go
+3
-0
pkg/services/provisioning/dashboards/file_reader.go
+0
-1
pkg/services/sqlstore/annotation_test.go
+1
-0
pkg/services/sqlstore/dashboard.go
+1
-1
pkg/services/sqlstore/dashboard_acl_test.go
+1
-0
pkg/services/sqlstore/migrations/migrations_test.go
+2
-2
pkg/services/sqlstore/playlist.go
+3
-0
pkg/services/sqlstore/plugin_setting.go
+3
-0
pkg/services/sqlstore/preferences.go
+3
-0
pkg/services/sqlstore/team_test.go
+2
-1
pkg/services/sqlstore/user.go
+2
-6
No files found.
pkg/services/alerting/notifiers/telegram.go
View file @
6eb00000
...
...
@@ -3,13 +3,14 @@ package notifiers
import
(
"bytes"
"fmt"
"io"
"mime/multipart"
"os"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/alerting"
"io"
"mime/multipart"
"os"
)
const
(
...
...
@@ -133,6 +134,9 @@ func (this *TelegramNotifier) buildMessageInlineImage(evalContext *alerting.Eval
}
ruleUrl
,
err
:=
evalContext
.
GetRuleUrl
()
if
err
!=
nil
{
return
nil
,
err
}
metrics
:=
generateMetricsMessage
(
evalContext
)
message
:=
generateImageCaption
(
evalContext
,
ruleUrl
,
metrics
)
...
...
pkg/services/alerting/notifiers/victorops.go
View file @
6eb00000
...
...
@@ -83,27 +83,6 @@ func (this *VictoropsNotifier) Notify(evalContext *alerting.EvalContext) error {
return
nil
}
fields
:=
make
([]
map
[
string
]
interface
{},
0
)
fieldLimitCount
:=
4
for
index
,
evt
:=
range
evalContext
.
EvalMatches
{
fields
=
append
(
fields
,
map
[
string
]
interface
{}{
"title"
:
evt
.
Metric
,
"value"
:
evt
.
Value
,
"short"
:
true
,
})
if
index
>
fieldLimitCount
{
break
}
}
if
evalContext
.
Error
!=
nil
{
fields
=
append
(
fields
,
map
[
string
]
interface
{}{
"title"
:
"Error message"
,
"value"
:
evalContext
.
Error
.
Error
(),
"short"
:
false
,
})
}
messageType
:=
evalContext
.
Rule
.
State
if
evalContext
.
Rule
.
State
==
models
.
AlertStateAlerting
{
// translate 'Alerting' to 'CRITICAL' (Victorops analog)
messageType
=
AlertStateCritical
...
...
pkg/services/guardian/guardian_test.go
View file @
6eb00000
...
...
@@ -649,6 +649,9 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsWithOverrideShou
}
_
,
err
:=
sc
.
g
.
CheckPermissionBeforeUpdate
(
m
.
PERMISSION_ADMIN
,
permissionList
)
if
err
!=
nil
{
sc
.
reportFailure
(
tc
,
nil
,
err
)
}
sc
.
updatePermissions
=
permissionList
ok
,
err
:=
sc
.
g
.
CheckPermissionBeforeUpdate
(
m
.
PERMISSION_ADMIN
,
permissionList
)
...
...
pkg/services/provisioning/dashboards/file_reader.go
View file @
6eb00000
...
...
@@ -235,7 +235,6 @@ func getOrCreateFolderId(cfg *DashboardsAsConfig, service dashboards.DashboardPr
func
resolveSymlink
(
fileinfo
os
.
FileInfo
,
path
string
)
(
os
.
FileInfo
,
error
)
{
checkFilepath
,
err
:=
filepath
.
EvalSymlinks
(
path
)
if
path
!=
checkFilepath
{
path
=
checkFilepath
fi
,
err
:=
os
.
Lstat
(
checkFilepath
)
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/services/sqlstore/annotation_test.go
View file @
6eb00000
...
...
@@ -256,6 +256,7 @@ func TestAnnotations(t *testing.T) {
annotationId
:=
items
[
0
]
.
Id
err
=
repo
.
Delete
(
&
annotations
.
DeleteParams
{
Id
:
annotationId
})
So
(
err
,
ShouldBeNil
)
items
,
err
=
repo
.
Find
(
query
)
So
(
err
,
ShouldBeNil
)
...
...
pkg/services/sqlstore/dashboard.go
View file @
6eb00000
...
...
@@ -77,7 +77,7 @@ func saveDashboard(sess *DBSession, cmd *m.SaveDashboardCommand) error {
}
parentVersion
:=
dash
.
Version
affectedRows
:=
int64
(
0
)
var
affectedRows
int64
var
err
error
if
dash
.
Id
==
0
{
...
...
pkg/services/sqlstore/dashboard_acl_test.go
View file @
6eb00000
...
...
@@ -154,6 +154,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
DashboardId
:
savedFolder
.
Id
,
Permission
:
m
.
PERMISSION_EDIT
,
})
So
(
err
,
ShouldBeNil
)
q1
:=
&
m
.
GetDashboardAclInfoListQuery
{
DashboardId
:
savedFolder
.
Id
,
OrgId
:
1
}
err
=
GetDashboardAclInfoList
(
q1
)
...
...
pkg/services/sqlstore/migrations/migrations_test.go
View file @
6eb00000
...
...
@@ -27,7 +27,7 @@ func TestMigrations(t *testing.T) {
sqlutil
.
CleanDB
(
x
)
has
,
err
:
=
x
.
SQL
(
sql
)
.
Get
(
&
r
)
_
,
err
=
x
.
SQL
(
sql
)
.
Get
(
&
r
)
So
(
err
,
ShouldNotBeNil
)
mg
:=
NewMigrator
(
x
)
...
...
@@ -36,7 +36,7 @@ func TestMigrations(t *testing.T) {
err
=
mg
.
Start
()
So
(
err
,
ShouldBeNil
)
has
,
err
=
x
.
SQL
(
sql
)
.
Get
(
&
r
)
has
,
err
:
=
x
.
SQL
(
sql
)
.
Get
(
&
r
)
So
(
err
,
ShouldBeNil
)
So
(
has
,
ShouldBeTrue
)
expectedMigrations
:=
mg
.
MigrationsCount
()
-
2
//we currently skip to migrations. We should rewrite skipped migrations to write in the log as well. until then we have to keep this
...
...
pkg/services/sqlstore/playlist.go
View file @
6eb00000
...
...
@@ -22,6 +22,9 @@ func CreatePlaylist(cmd *m.CreatePlaylistCommand) error {
}
_
,
err
:=
x
.
Insert
(
&
playlist
)
if
err
!=
nil
{
return
err
}
playlistItems
:=
make
([]
m
.
PlaylistItem
,
0
)
for
_
,
item
:=
range
cmd
.
Items
{
...
...
pkg/services/sqlstore/plugin_setting.go
View file @
6eb00000
...
...
@@ -48,6 +48,9 @@ func UpdatePluginSetting(cmd *m.UpdatePluginSettingCmd) error {
var
pluginSetting
m
.
PluginSetting
exists
,
err
:=
sess
.
Where
(
"org_id=? and plugin_id=?"
,
cmd
.
OrgId
,
cmd
.
PluginId
)
.
Get
(
&
pluginSetting
)
if
err
!=
nil
{
return
err
}
sess
.
UseBool
(
"enabled"
)
sess
.
UseBool
(
"pinned"
)
if
!
exists
{
...
...
pkg/services/sqlstore/preferences.go
View file @
6eb00000
...
...
@@ -72,6 +72,9 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
var
prefs
m
.
Preferences
exists
,
err
:=
sess
.
Where
(
"org_id=? AND user_id=?"
,
cmd
.
OrgId
,
cmd
.
UserId
)
.
Get
(
&
prefs
)
if
err
!=
nil
{
return
err
}
if
!
exists
{
prefs
=
m
.
Preferences
{
...
...
pkg/services/sqlstore/team_test.go
View file @
6eb00000
...
...
@@ -74,6 +74,7 @@ func TestTeamCommandsAndQueries(t *testing.T) {
Convey
(
"Should be able to return all teams a user is member of"
,
func
()
{
groupId
:=
group2
.
Result
.
Id
err
:=
AddTeamMember
(
&
m
.
AddTeamMemberCommand
{
OrgId
:
testOrgId
,
TeamId
:
groupId
,
UserId
:
userIds
[
0
]})
So
(
err
,
ShouldBeNil
)
query
:=
&
m
.
GetTeamsByUserQuery
{
OrgId
:
testOrgId
,
UserId
:
userIds
[
0
]}
err
=
GetTeamsByUser
(
query
)
...
...
@@ -103,7 +104,7 @@ func TestTeamCommandsAndQueries(t *testing.T) {
err
=
AddTeamMember
(
&
m
.
AddTeamMemberCommand
{
OrgId
:
testOrgId
,
TeamId
:
groupId
,
UserId
:
userIds
[
2
]})
So
(
err
,
ShouldBeNil
)
err
=
testHelperUpdateDashboardAcl
(
1
,
m
.
DashboardAcl
{
DashboardId
:
1
,
OrgId
:
testOrgId
,
Permission
:
m
.
PERMISSION_EDIT
,
TeamId
:
groupId
})
So
(
err
,
ShouldBeNil
)
err
=
DeleteTeam
(
&
m
.
DeleteTeamCommand
{
OrgId
:
testOrgId
,
Id
:
groupId
})
So
(
err
,
ShouldBeNil
)
...
...
pkg/services/sqlstore/user.go
View file @
6eb00000
...
...
@@ -168,11 +168,9 @@ func GetUserByLogin(query *m.GetUserByLoginQuery) error {
return
m
.
ErrUserNotFound
}
user
:=
new
(
m
.
User
)
// Try and find the user by login first.
// It's not sufficient to assume that a LoginOrEmail with an "@" is an email.
user
=
&
m
.
User
{
Login
:
query
.
LoginOrEmail
}
user
:
=
&
m
.
User
{
Login
:
query
.
LoginOrEmail
}
has
,
err
:=
x
.
Get
(
user
)
if
err
!=
nil
{
...
...
@@ -202,9 +200,7 @@ func GetUserByEmail(query *m.GetUserByEmailQuery) error {
return
m
.
ErrUserNotFound
}
user
:=
new
(
m
.
User
)
user
=
&
m
.
User
{
Email
:
query
.
Email
}
user
:=
&
m
.
User
{
Email
:
query
.
Email
}
has
,
err
:=
x
.
Get
(
user
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment