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
87760d4f
Commit
87760d4f
authored
Jun 04, 2019
by
Mario Trangoni
Committed by
Carl Bergquist
Jun 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Codestyle: Fix govet issues (#17178)
ref #10381 Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
parent
574a37e4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
30 additions
and
35 deletions
+30
-35
pkg/api/metrics.go
+1
-0
pkg/api/pluginproxy/pluginproxy.go
+0
-5
pkg/bus/bus.go
+20
-1
pkg/bus/bus_test.go
+4
-4
pkg/cmd/grafana-cli/services/services.go
+0
-8
pkg/components/imguploader/azureblobuploader.go
+0
-4
pkg/infra/remotecache/redis_storage.go
+1
-7
pkg/services/alerting/notifiers/slack.go
+0
-3
pkg/setting/setting.go
+3
-3
scripts/backend-lint.sh
+1
-0
No files found.
pkg/api/metrics.go
View file @
87760d4f
...
...
@@ -89,6 +89,7 @@ func GetTestDataScenarios(c *m.ReqContext) Response {
// Generates a index out of range error
func
GenerateError
(
c
*
m
.
ReqContext
)
Response
{
var
array
[]
string
// nolint: govet
return
JSON
(
200
,
array
[
20
])
}
...
...
pkg/api/pluginproxy/pluginproxy.go
View file @
87760d4f
...
...
@@ -129,11 +129,6 @@ func NewApiPluginProxy(ctx *m.ReqContext, proxyPath string, route *plugins.AppPl
req
.
URL
.
Host
=
targetURL
.
Host
req
.
Host
=
targetURL
.
Host
req
.
URL
.
Path
=
util
.
JoinURLFragments
(
targetURL
.
Path
,
proxyPath
)
if
err
!=
nil
{
ctx
.
JsonApiErr
(
500
,
"Could not interpolate plugin route url"
,
err
)
return
}
}
// reqBytes, _ := httputil.DumpRequestOut(req, true);
...
...
pkg/bus/bus.go
View file @
87760d4f
...
...
@@ -6,16 +6,24 @@ import (
"reflect"
)
// HandlerFunc defines a handler function interface.
type
HandlerFunc
interface
{}
// CtxHandlerFunc defines a context handler function.
type
CtxHandlerFunc
func
()
// Msg defines a message interface.
type
Msg
interface
{}
// ErrHandlerNotFound defines an error if a handler is not found
var
ErrHandlerNotFound
=
errors
.
New
(
"handler not found"
)
// TransactionManager defines a transaction interface
type
TransactionManager
interface
{
InTransaction
(
ctx
context
.
Context
,
fn
func
(
ctx
context
.
Context
)
error
)
error
}
// Bus type defines the bus interface structure
type
Bus
interface
{
Dispatch
(
msg
Msg
)
error
DispatchCtx
(
ctx
context
.
Context
,
msg
Msg
)
error
...
...
@@ -38,10 +46,12 @@ type Bus interface {
SetTransactionManager
(
tm
TransactionManager
)
}
// InTransaction defines an in transaction function
func
(
b
*
InProcBus
)
InTransaction
(
ctx
context
.
Context
,
fn
func
(
ctx
context
.
Context
)
error
)
error
{
return
b
.
txMng
.
InTransaction
(
ctx
,
fn
)
}
// InProcBus defines the bus structure
type
InProcBus
struct
{
handlers
map
[
string
]
HandlerFunc
handlersWithCtx
map
[
string
]
HandlerFunc
...
...
@@ -53,6 +63,7 @@ type InProcBus struct {
// temp stuff, not sure how to handle bus instance, and init yet
var
globalBus
=
New
()
// New initialize the bus
func
New
()
Bus
{
bus
:=
&
InProcBus
{}
bus
.
handlers
=
make
(
map
[
string
]
HandlerFunc
)
...
...
@@ -69,10 +80,12 @@ func GetBus() Bus {
return
globalBus
}
// SetTransactionManager function assign a transaction manager to the bus.
func
(
b
*
InProcBus
)
SetTransactionManager
(
tm
TransactionManager
)
{
b
.
txMng
=
tm
}
// DispatchCtx function dispatch a message to the bus context.
func
(
b
*
InProcBus
)
DispatchCtx
(
ctx
context
.
Context
,
msg
Msg
)
error
{
var
msgName
=
reflect
.
TypeOf
(
msg
)
.
Elem
()
.
Name
()
...
...
@@ -93,6 +106,7 @@ func (b *InProcBus) DispatchCtx(ctx context.Context, msg Msg) error {
return
err
.
(
error
)
}
// Dispatch function dispatch a message to the bus.
func
(
b
*
InProcBus
)
Dispatch
(
msg
Msg
)
error
{
var
msgName
=
reflect
.
TypeOf
(
msg
)
.
Elem
()
.
Name
()
...
...
@@ -122,6 +136,7 @@ func (b *InProcBus) Dispatch(msg Msg) error {
return
err
.
(
error
)
}
// Publish function publish a message to the bus listener.
func
(
b
*
InProcBus
)
Publish
(
msg
Msg
)
error
{
var
msgName
=
reflect
.
TypeOf
(
msg
)
.
Elem
()
.
Name
()
var
listeners
=
b
.
listeners
[
msgName
]
...
...
@@ -174,21 +189,25 @@ func (b *InProcBus) AddEventListener(handler HandlerFunc) {
b
.
listeners
[
eventName
]
=
append
(
b
.
listeners
[
eventName
],
handler
)
}
// Package level functions
// AddHandler attach a handler function to the global bus
// Package level function
func
AddHandler
(
implName
string
,
handler
HandlerFunc
)
{
globalBus
.
AddHandler
(
handler
)
}
// AddHandlerCtx attach a handler function to the global bus context
// Package level functions
func
AddHandlerCtx
(
implName
string
,
handler
HandlerFunc
)
{
globalBus
.
AddHandlerCtx
(
handler
)
}
// AddEventListener attach a handler function to the event listener
// Package level functions
func
AddEventListener
(
handler
HandlerFunc
)
{
globalBus
.
AddEventListener
(
handler
)
}
// AddWildcardListener attach a handler function to the wildcard listener
func
AddWildcardListener
(
handler
HandlerFunc
)
{
globalBus
.
AddWildcardListener
(
handler
)
}
...
...
pkg/bus/bus_test.go
View file @
87760d4f
...
...
@@ -8,7 +8,7 @@ import (
)
type
testQuery
struct
{
I
d
int64
I
D
int64
Resp
string
}
...
...
@@ -64,9 +64,9 @@ func TestQueryHandlerReturnsError(t *testing.T) {
err
:=
bus
.
Dispatch
(
&
testQuery
{})
if
err
==
nil
{
t
.
Fatal
(
"Send query failed
"
+
err
.
Error
()
)
t
.
Fatal
(
"Send query failed
"
)
}
else
{
t
.
Log
(
"Handler error received ok
"
)
t
.
Log
(
"Handler error received ok
"
+
err
.
Error
()
)
}
}
...
...
@@ -93,7 +93,7 @@ func TestEventListeners(t *testing.T) {
count
:=
0
bus
.
AddEventListener
(
func
(
query
*
testQuery
)
error
{
count
+=
1
count
++
return
nil
})
...
...
pkg/cmd/grafana-cli/services/services.go
View file @
87760d4f
...
...
@@ -56,10 +56,6 @@ func ListAllPlugins(repoUrl string) (m.PluginRepo, error) {
return
m
.
PluginRepo
{},
fmt
.
Errorf
(
"Failed to send request. error: %v"
,
err
)
}
if
err
!=
nil
{
return
m
.
PluginRepo
{},
err
}
var
data
m
.
PluginRepo
err
=
json
.
Unmarshal
(
body
,
&
data
)
if
err
!=
nil
{
...
...
@@ -137,10 +133,6 @@ func GetPlugin(pluginId, repoUrl string) (m.Plugin, error) {
return
m
.
Plugin
{},
fmt
.
Errorf
(
"Failed to send request. error: %v"
,
err
)
}
if
err
!=
nil
{
return
m
.
Plugin
{},
err
}
var
data
m
.
Plugin
err
=
json
.
Unmarshal
(
body
,
&
data
)
if
err
!=
nil
{
...
...
pkg/components/imguploader/azureblobuploader.go
View file @
87760d4f
...
...
@@ -72,10 +72,6 @@ func (az *AzureBlobUploader) Upload(ctx context.Context, imageDiskPath string) (
return
""
,
aerr
}
if
err
!=
nil
{
return
""
,
err
}
url
:=
fmt
.
Sprintf
(
"https://%s.blob.core.windows.net/%s/%s"
,
az
.
account_name
,
az
.
container_name
,
randomFileName
)
return
url
,
nil
}
...
...
pkg/infra/remotecache/redis_storage.go
View file @
87760d4f
...
...
@@ -43,16 +43,10 @@ func (s *redisStorage) Get(key string) (interface{}, error) {
if
err
==
nil
{
return
item
.
Val
,
nil
}
if
err
.
Error
()
==
"EOF"
{
return
nil
,
ErrCacheItemNotFound
}
if
err
!=
nil
{
return
nil
,
err
}
return
item
.
Val
,
nil
return
nil
,
err
}
// Delete delete a key from session.
...
...
pkg/services/alerting/notifiers/slack.go
View file @
87760d4f
...
...
@@ -244,9 +244,6 @@ func slackFileUpload(evalContext *alerting.EvalContext, log log.Logger, url stri
log
.
Error
(
"Failed to upload slack image"
,
"error"
,
err
,
"webhook"
,
"file.upload"
)
return
err
}
if
err
!=
nil
{
return
err
}
return
nil
}
...
...
pkg/setting/setting.go
View file @
87760d4f
...
...
@@ -488,9 +488,9 @@ func (cfg *Cfg) loadConfiguration(args *CommandLineArgs) (*ini.File, error) {
// load specified config file
err
=
loadSpecifedConfigFile
(
args
.
Config
,
parsedFile
)
if
err
!=
nil
{
err
=
cfg
.
initLogging
(
parsedFile
)
if
err
!=
nil
{
return
nil
,
err
err
2
:
=
cfg
.
initLogging
(
parsedFile
)
if
err
2
!=
nil
{
return
nil
,
err
2
}
log
.
Fatal
(
3
,
err
.
Error
())
}
...
...
scripts/backend-lint.sh
View file @
87760d4f
...
...
@@ -28,6 +28,7 @@ exit_if_fail golangci-lint run --deadline 10m --disable-all \
--enable
=
deadcode
\
--enable
=
gofmt
\
--enable
=
gosimple
\
--enable
=
govet
\
--enable
=
ineffassign
\
--enable
=
structcheck
\
--enable
=
unconvert
\
...
...
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