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
c55e6016
Unverified
Commit
c55e6016
authored
May 15, 2019
by
Carl Bergquist
Committed by
GitHub
May 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backend: replace /pkg/errors with errutil (#17065)
parent
fdd421e2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
22 deletions
+42
-22
go.mod
+1
-1
pkg/services/notifications/mailer.go
+6
-6
pkg/services/provisioning/dashboards/dashboard.go
+6
-5
pkg/services/provisioning/provisioning.go
+5
-5
pkg/services/provisioning/values/values.go
+3
-2
pkg/util/errutil/errors.go
+19
-1
vendor/github.com/robfig/cron/README.md
+1
-1
vendor/github.com/robfig/cron/doc.go
+1
-1
No files found.
go.mod
View file @
c55e6016
...
...
@@ -48,7 +48,7 @@ require (
github.com/onsi/gomega v1.5.0 // indirect
github.com/opentracing/opentracing-go v1.1.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.8.1
github.com/pkg/errors v0.8.1
// indirect
github.com/prometheus/client_golang v0.9.2
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
github.com/prometheus/common v0.2.0
...
...
pkg/services/notifications/mailer.go
View file @
c55e6016
...
...
@@ -12,9 +12,9 @@ import (
"net"
"strconv"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/
pkg/errors
"
"github.com/
grafana/grafana/pkg/util/errutil
"
gomail
"gopkg.in/mail.v2"
)
...
...
@@ -38,11 +38,11 @@ func (ns *NotificationService) send(msg *Message) (int, error) {
e
:=
dialer
.
DialAndSend
(
m
)
if
e
!=
nil
{
err
=
err
ors
.
Wrapf
(
e
,
"Failed to send notification to email address: %s"
,
address
)
err
=
err
util
.
Wrapf
(
e
,
"Failed to send notification to email address: %s"
,
address
)
continue
}
num
+=
1
num
++
}
return
num
,
err
...
...
@@ -83,9 +83,9 @@ func (ns *NotificationService) createDialer() (*gomail.Dialer, error) {
return
d
,
nil
}
func
(
ns
*
NotificationService
)
buildEmailMessage
(
cmd
*
m
.
SendEmailCommand
)
(
*
Message
,
error
)
{
func
(
ns
*
NotificationService
)
buildEmailMessage
(
cmd
*
m
odels
.
SendEmailCommand
)
(
*
Message
,
error
)
{
if
!
ns
.
Cfg
.
Smtp
.
Enabled
{
return
nil
,
m
.
ErrSmtpNotEnabled
return
nil
,
m
odels
.
ErrSmtpNotEnabled
}
var
buffer
bytes
.
Buffer
...
...
pkg/services/provisioning/dashboards/dashboard.go
View file @
c55e6016
...
...
@@ -3,8 +3,9 @@ package dashboards
import
(
"context"
"fmt"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/
pkg/errors
"
"github.com/
grafana/grafana/pkg/util/errutil
"
)
type
DashboardProvisionerImpl
struct
{
...
...
@@ -18,13 +19,13 @@ func NewDashboardProvisionerImpl(configDirectory string) (*DashboardProvisionerI
configs
,
err
:=
cfgReader
.
readConfig
()
if
err
!=
nil
{
return
nil
,
err
ors
.
Wrap
(
err
,
"Failed to read dashboards config"
)
return
nil
,
err
util
.
Wrap
(
"Failed to read dashboards config"
,
err
)
}
fileReaders
,
err
:=
getFileReaders
(
configs
,
logger
)
if
err
!=
nil
{
return
nil
,
err
ors
.
Wrap
(
err
,
"Failed to initialize file readers"
)
return
nil
,
err
util
.
Wrap
(
"Failed to initialize file readers"
,
err
)
}
d
:=
&
DashboardProvisionerImpl
{
...
...
@@ -39,7 +40,7 @@ func (provider *DashboardProvisionerImpl) Provision() error {
for
_
,
reader
:=
range
provider
.
fileReaders
{
err
:=
reader
.
startWalkingDisk
()
if
err
!=
nil
{
return
err
ors
.
Wrapf
(
err
,
"Failed to provision config %v"
,
reader
.
Cfg
.
Name
)
return
err
util
.
Wrapf
(
err
,
"Failed to provision config %v"
,
reader
.
Cfg
.
Name
)
}
}
...
...
@@ -73,7 +74,7 @@ func getFileReaders(configs []*DashboardsAsConfig, logger log.Logger) ([]*fileRe
case
"file"
:
fileReader
,
err
:=
NewDashboardFileReader
(
config
,
logger
.
New
(
"type"
,
config
.
Type
,
"name"
,
config
.
Name
))
if
err
!=
nil
{
return
nil
,
err
ors
.
Wrapf
(
err
,
"Failed to create file reader for config %v"
,
config
.
Name
)
return
nil
,
err
util
.
Wrapf
(
err
,
"Failed to create file reader for config %v"
,
config
.
Name
)
}
readers
=
append
(
readers
,
fileReader
)
default
:
...
...
pkg/services/provisioning/provisioning.go
View file @
c55e6016
...
...
@@ -6,7 +6,7 @@ import (
"sync"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/
pkg/errors
"
"github.com/
grafana/grafana/pkg/util/errutil
"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/services/provisioning/dashboards"
...
...
@@ -103,20 +103,20 @@ func (ps *provisioningServiceImpl) Run(ctx context.Context) error {
func
(
ps
*
provisioningServiceImpl
)
ProvisionDatasources
()
error
{
datasourcePath
:=
path
.
Join
(
ps
.
Cfg
.
ProvisioningPath
,
"datasources"
)
err
:=
ps
.
provisionDatasources
(
datasourcePath
)
return
err
ors
.
Wrap
(
err
,
"Datasource provisioning error"
)
return
err
util
.
Wrap
(
"Datasource provisioning error"
,
err
)
}
func
(
ps
*
provisioningServiceImpl
)
ProvisionNotifications
()
error
{
alertNotificationsPath
:=
path
.
Join
(
ps
.
Cfg
.
ProvisioningPath
,
"notifiers"
)
err
:=
ps
.
provisionNotifiers
(
alertNotificationsPath
)
return
err
ors
.
Wrap
(
err
,
"Alert notification provisioning error"
)
return
err
util
.
Wrap
(
"Alert notification provisioning error"
,
err
)
}
func
(
ps
*
provisioningServiceImpl
)
ProvisionDashboards
()
error
{
dashboardPath
:=
path
.
Join
(
ps
.
Cfg
.
ProvisioningPath
,
"dashboards"
)
dashProvisioner
,
err
:=
ps
.
newDashboardProvisioner
(
dashboardPath
)
if
err
!=
nil
{
return
err
ors
.
Wrap
(
err
,
"Failed to create provisioner"
)
return
err
util
.
Wrap
(
"Failed to create provisioner"
,
err
)
}
ps
.
mutex
.
Lock
()
...
...
@@ -127,7 +127,7 @@ func (ps *provisioningServiceImpl) ProvisionDashboards() error {
if
err
:=
dashProvisioner
.
Provision
();
err
!=
nil
{
// If we fail to provision with the new provisioner, mutex will unlock and the polling we restart with the
// old provisioner as we did not switch them yet.
return
err
ors
.
Wrap
(
err
,
"Failed to provision dashboards"
)
return
err
util
.
Wrap
(
"Failed to provision dashboards"
,
err
)
}
ps
.
dashboardProvisioner
=
dashProvisioner
return
nil
...
...
pkg/services/provisioning/values/values.go
View file @
c55e6016
...
...
@@ -11,10 +11,11 @@
package
values
import
(
"github.com/pkg/errors"
"os"
"reflect"
"strconv"
"github.com/grafana/grafana/pkg/util/errutil"
)
type
IntValue
struct
{
...
...
@@ -33,7 +34,7 @@ func (val *IntValue) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
val
.
Raw
=
interpolated
.
raw
val
.
value
,
err
=
strconv
.
Atoi
(
interpolated
.
value
)
return
err
ors
.
Wrap
(
err
,
"cannot convert value int"
)
return
err
util
.
Wrap
(
"cannot convert value int"
,
err
)
}
func
(
val
*
IntValue
)
Value
()
int
{
...
...
pkg/util/errutil/errors.go
View file @
c55e6016
package
errutil
import
"golang.org/x/xerrors"
import
(
"fmt"
"golang.org/x/xerrors"
)
// Wrap is a simple wrapper around Errorf that is doing error wrapping. You can read how that works in
// https://godoc.org/golang.org/x/xerrors#Errorf but its API is very implicit which is a reason for this wrapper.
// There is also a discussion (https://github.com/golang/go/issues/29934) where many comments make arguments for such
// wrapper so hopefully it will be added in the standard lib later.
func
Wrap
(
message
string
,
err
error
)
error
{
if
err
==
nil
{
return
nil
}
return
xerrors
.
Errorf
(
"%v: %w"
,
message
,
err
)
}
// Wrapf is a simple wrapper around Errorf that is doing error wrapping
// Wrapf allows you to send a format and args instead of just a message.
func
Wrapf
(
err
error
,
message
string
,
a
...
interface
{})
error
{
if
err
==
nil
{
return
nil
}
return
Wrap
(
fmt
.
Sprintf
(
message
,
a
...
),
err
)
}
vendor/github.com/robfig/cron/README.md
View file @
c55e6016
[
![GoDoc
](
http://godoc.org/github.com/robfig/cron?status.png
)
](http://godoc.org/github.com/robfig/cron)
[
![GoDoc
](
http://godoc.org/github.com/robfig/cron?status.png
)
](http://godoc.org/github.com/robfig/cron)
[
![Build Status
](
https://travis-ci.org/robfig/cron.svg?branch=master
)
](https://travis-ci.org/robfig/cron)
# cron
...
...
vendor/github.com/robfig/cron/doc.go
View file @
c55e6016
...
...
@@ -84,7 +84,7 @@ You may use one of several pre-defined schedules in place of a cron expression.
Intervals
You may also schedule a job to execute at fixed intervals, starting at the time it's added
You may also schedule a job to execute at fixed intervals, starting at the time it's added
or cron is run. This is supported by formatting the cron spec like this:
@every <duration>
...
...
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