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
415638cd
Unverified
Commit
415638cd
authored
Jul 23, 2020
by
Arve Knudsen
Committed by
GitHub
Jul 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chore: Use interfaces where possible (#26392)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent
3a8854b1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
17 deletions
+23
-17
pkg/components/imguploader/s3uploader.go
+3
-2
pkg/infra/metrics/graphitebridge/graphite.go
+1
-1
pkg/services/alerting/alerting_usage.go
+2
-3
pkg/services/alerting/alerting_usage_test.go
+10
-6
pkg/services/alerting/extractor.go
+2
-1
pkg/services/alerting/testdata/settings/invalid_format.json
+0
-0
pkg/tsdb/cloudwatch/cloudwatch.go
+3
-1
pkg/tsdb/cloudwatch/credentials.go
+2
-2
scripts/go/configs/.golangci.toml
+0
-1
No files found.
pkg/components/imguploader/s3uploader.go
View file @
415638cd
...
...
@@ -7,6 +7,7 @@ import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
"github.com/aws/aws-sdk-go/aws/credentials/endpointcreds"
...
...
@@ -99,7 +100,7 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
return
result
.
Location
,
nil
}
func
webIdentityProvider
(
sess
*
session
.
Session
)
credentials
.
Provider
{
func
webIdentityProvider
(
sess
client
.
ConfigProvider
)
credentials
.
Provider
{
svc
:=
sts
.
New
(
sess
)
roleARN
:=
os
.
Getenv
(
"AWS_ROLE_ARN"
)
...
...
@@ -128,6 +129,6 @@ func ecsCredProvider(sess *session.Session, uri string) credentials.Provider {
func
(
p
*
endpointcreds
.
Provider
)
{
p
.
ExpiryWindow
=
5
*
time
.
Minute
})
}
func
ec2RoleProvider
(
sess
*
session
.
Session
)
credentials
.
Provider
{
func
ec2RoleProvider
(
sess
client
.
ConfigProvider
)
credentials
.
Provider
{
return
&
ec2rolecreds
.
EC2RoleProvider
{
Client
:
ec2metadata
.
New
(
sess
),
ExpiryWindow
:
5
*
time
.
Minute
}
}
pkg/infra/metrics/graphitebridge/graphite.go
View file @
415638cd
...
...
@@ -295,7 +295,7 @@ func writeMetric(buf *bufio.Writer, m model.Metric, mf *dto.MetricFamily) error
return
addExtensionConventionForRollups
(
buf
,
mf
,
m
)
}
func
addExtensionConventionForRollups
(
buf
*
buf
io
.
Writer
,
mf
*
dto
.
MetricFamily
,
m
model
.
Metric
)
error
{
func
addExtensionConventionForRollups
(
buf
io
.
Writer
,
mf
*
dto
.
MetricFamily
,
m
model
.
Metric
)
error
{
// Adding `.count` `.sum` suffix makes it possible to configure
// different rollup strategies based on metric type
...
...
pkg/services/alerting/alerting_usage.go
View file @
415638cd
...
...
@@ -3,7 +3,6 @@ package alerting
import
(
"encoding/json"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/models"
)
...
...
@@ -75,7 +74,7 @@ func (ae *AlertEngine) mapRulesToUsageStats(rules []*models.Alert) (DatasourceAl
return
result
,
nil
}
func
(
ae
*
AlertEngine
)
parseAlertRuleModel
(
settings
*
simplejson
.
Json
)
([]
int64
,
error
)
{
func
(
ae
*
AlertEngine
)
parseAlertRuleModel
(
settings
json
.
Marshaler
)
([]
int64
,
error
)
{
datasourceIDs
:=
[]
int64
{}
model
:=
alertJSONModel
{}
...
...
@@ -85,7 +84,7 @@ func (ae *AlertEngine) parseAlertRuleModel(settings *simplejson.Json) ([]int64,
bytes
,
err
:=
settings
.
MarshalJSON
()
if
err
!=
nil
{
return
datasourceIDs
,
err
return
nil
,
err
}
err
=
json
.
Unmarshal
(
bytes
,
&
model
)
...
...
pkg/services/alerting/alerting_usage_test.go
View file @
415638cd
package
alerting
import
(
"encoding/json"
"io/ioutil"
"testing"
...
...
@@ -95,8 +96,7 @@ func TestParsingAlertRuleSettings(t *testing.T) {
shouldErr
:
require
.
NoError
,
},
{
name
:
"can parse blank content"
,
file
:
"testdata/settings/invalid_format.json"
,
name
:
"can handle nil content"
,
expected
:
[]
int64
{},
shouldErr
:
require
.
NoError
,
},
...
...
@@ -108,12 +108,16 @@ func TestParsingAlertRuleSettings(t *testing.T) {
for
_
,
tc
:=
range
tcs
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
content
,
err
:=
ioutil
.
ReadFile
(
tc
.
file
)
require
.
NoError
(
t
,
err
,
"expected to be able to read file"
)
var
settings
json
.
Marshaler
if
tc
.
file
!=
""
{
content
,
err
:=
ioutil
.
ReadFile
(
tc
.
file
)
require
.
NoError
(
t
,
err
,
"expected to be able to read file"
)
j
,
_
:=
simplejson
.
NewJson
(
content
)
settings
,
err
=
simplejson
.
NewJson
(
content
)
require
.
NoError
(
t
,
err
)
}
result
,
err
:=
ae
.
parseAlertRuleModel
(
j
)
result
,
err
:=
ae
.
parseAlertRuleModel
(
settings
)
tc
.
shouldErr
(
t
,
err
)
diff
:=
cmp
.
Diff
(
tc
.
expected
,
result
)
...
...
pkg/services/alerting/extractor.go
View file @
415638cd
package
alerting
import
(
"encoding/json"
"errors"
"fmt"
"time"
...
...
@@ -64,7 +65,7 @@ func findPanelQueryByRefID(panel *simplejson.Json, refID string) *simplejson.Jso
return
nil
}
func
copyJSON
(
in
*
simplejson
.
Json
)
(
*
simplejson
.
Json
,
error
)
{
func
copyJSON
(
in
json
.
Marshaler
)
(
*
simplejson
.
Json
,
error
)
{
rawJSON
,
err
:=
in
.
MarshalJSON
()
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/services/alerting/testdata/settings/invalid_format.json
deleted
100644 → 0
View file @
3a8854b1
pkg/tsdb/cloudwatch/cloudwatch.go
View file @
415638cd
...
...
@@ -12,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs/cloudwatchlogsiface"
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
"github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi/resourcegroupstaggingapiiface"
"github.com/grafana/grafana/pkg/components/simplejson"
...
...
@@ -115,7 +116,8 @@ func (e *cloudWatchExecutor) getCWLogsClient(region string) (*cloudwatchlogs.Clo
return
newLogsClient
,
nil
}
func
(
e
*
cloudWatchExecutor
)
alertQuery
(
ctx
context
.
Context
,
logsClient
*
cloudwatchlogs
.
CloudWatchLogs
,
queryContext
*
tsdb
.
TsdbQuery
)
(
*
cloudwatchlogs
.
GetQueryResultsOutput
,
error
)
{
func
(
e
*
cloudWatchExecutor
)
alertQuery
(
ctx
context
.
Context
,
logsClient
cloudwatchlogsiface
.
CloudWatchLogsAPI
,
queryContext
*
tsdb
.
TsdbQuery
)
(
*
cloudwatchlogs
.
GetQueryResultsOutput
,
error
)
{
const
maxAttempts
=
8
const
pollPeriod
=
1000
*
time
.
Millisecond
...
...
pkg/tsdb/cloudwatch/credentials.go
View file @
415638cd
...
...
@@ -142,7 +142,7 @@ func getCredentials(dsInfo *datasourceInfo) (*credentials.Credentials, error) {
return
creds
,
nil
}
func
webIdentityProvider
(
sess
*
session
.
Session
)
credentials
.
Provider
{
func
webIdentityProvider
(
sess
client
.
ConfigProvider
)
credentials
.
Provider
{
svc
:=
newSTSService
(
sess
)
roleARN
:=
os
.
Getenv
(
"AWS_ROLE_ARN"
)
...
...
@@ -171,7 +171,7 @@ func ecsCredProvider(sess *session.Session, uri string) credentials.Provider {
func
(
p
*
endpointcreds
.
Provider
)
{
p
.
ExpiryWindow
=
5
*
time
.
Minute
})
}
func
ec2RoleProvider
(
sess
*
session
.
Session
)
credentials
.
Provider
{
func
ec2RoleProvider
(
sess
client
.
ConfigProvider
)
credentials
.
Provider
{
return
&
ec2rolecreds
.
EC2RoleProvider
{
Client
:
newEC2Metadata
(
sess
),
ExpiryWindow
:
5
*
time
.
Minute
}
}
...
...
scripts/go/configs/.golangci.toml
View file @
415638cd
...
...
@@ -26,7 +26,6 @@ enable = [
"gosimple"
,
"govet"
,
"ineffassign"
,
# "interfacer",
"misspell"
,
"nakedret"
,
"rowserrcheck"
,
...
...
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