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
b387a875
Commit
b387a875
authored
Mar 07, 2017
by
Mitsuhiro Tanda
Committed by
Torkel Ödegaard
Mar 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use session.NewSession() (#7745)
parent
6ab90425
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
13 deletions
+63
-13
pkg/api/cloudwatch/cloudwatch.go
+49
-9
pkg/api/cloudwatch/metrics.go
+5
-2
pkg/components/imguploader/s3uploader.go
+9
-2
No files found.
pkg/api/cloudwatch/cloudwatch.go
View file @
b387a875
...
...
@@ -114,7 +114,10 @@ func getCredentials(dsInfo *datasourceInfo) (*credentials.Credentials, error) {
DurationSeconds
:
aws
.
Int64
(
900
),
}
stsSess
:=
session
.
New
()
stsSess
,
err
:=
session
.
NewSession
()
if
err
!=
nil
{
return
nil
,
err
}
stsCreds
:=
credentials
.
NewChainCredentials
(
[]
credentials
.
Provider
{
&
credentials
.
EnvProvider
{},
...
...
@@ -126,7 +129,11 @@ func getCredentials(dsInfo *datasourceInfo) (*credentials.Credentials, error) {
Credentials
:
stsCreds
,
}
svc
:=
sts
.
New
(
session
.
New
(
stsConfig
),
stsConfig
)
sess
,
err
:=
session
.
NewSession
(
stsConfig
)
if
err
!=
nil
{
return
nil
,
err
}
svc
:=
sts
.
New
(
sess
,
stsConfig
)
resp
,
err
:=
svc
.
AssumeRole
(
params
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -139,7 +146,10 @@ func getCredentials(dsInfo *datasourceInfo) (*credentials.Credentials, error) {
}
}
sess
:=
session
.
New
()
sess
,
err
:=
session
.
NewSession
()
if
err
!=
nil
{
return
nil
,
err
}
creds
:=
credentials
.
NewChainCredentials
(
[]
credentials
.
Provider
{
&
credentials
.
StaticProvider
{
Value
:
credentials
.
Value
{
...
...
@@ -185,7 +195,12 @@ func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
session
.
New
(
cfg
),
cfg
)
sess
,
err
:=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
sess
,
cfg
)
reqParam
:=
&
struct
{
Parameters
struct
{
...
...
@@ -232,7 +247,12 @@ func handleListMetrics(req *cwRequest, c *middleware.Context) {
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
session
.
New
(
cfg
),
cfg
)
sess
,
err
:=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
sess
,
cfg
)
reqParam
:=
&
struct
{
Parameters
struct
{
...
...
@@ -273,7 +293,12 @@ func handleDescribeAlarms(req *cwRequest, c *middleware.Context) {
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
session
.
New
(
cfg
),
cfg
)
sess
,
err
:=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
sess
,
cfg
)
reqParam
:=
&
struct
{
Parameters
struct
{
...
...
@@ -316,7 +341,12 @@ func handleDescribeAlarmsForMetric(req *cwRequest, c *middleware.Context) {
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
session
.
New
(
cfg
),
cfg
)
sess
,
err
:=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
sess
,
cfg
)
reqParam
:=
&
struct
{
Parameters
struct
{
...
...
@@ -360,7 +390,12 @@ func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) {
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
session
.
New
(
cfg
),
cfg
)
sess
,
err
:=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
cloudwatch
.
New
(
sess
,
cfg
)
reqParam
:=
&
struct
{
Parameters
struct
{
...
...
@@ -396,7 +431,12 @@ func handleDescribeInstances(req *cwRequest, c *middleware.Context) {
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
ec2
.
New
(
session
.
New
(
cfg
),
cfg
)
sess
,
err
:=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Unable to call AWS API"
,
err
)
return
}
svc
:=
ec2
.
New
(
sess
,
cfg
)
reqParam
:=
&
struct
{
Parameters
struct
{
...
...
pkg/api/cloudwatch/metrics.go
View file @
b387a875
...
...
@@ -258,8 +258,11 @@ func getAllMetrics(cwData *datasourceInfo) (cloudwatch.ListMetricsOutput, error)
Region
:
aws
.
String
(
cwData
.
Region
),
Credentials
:
creds
,
}
svc
:=
cloudwatch
.
New
(
session
.
New
(
cfg
),
cfg
)
sess
,
err
:=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
return
cloudwatch
.
ListMetricsOutput
{},
err
}
svc
:=
cloudwatch
.
New
(
sess
,
cfg
)
params
:=
&
cloudwatch
.
ListMetricsInput
{
Namespace
:
aws
.
String
(
cwData
.
Namespace
),
...
...
pkg/components/imguploader/s3uploader.go
View file @
b387a875
...
...
@@ -35,7 +35,10 @@ func NewS3Uploader(region, bucket, acl, accessKey, secretKey string) *S3Uploader
}
func
(
u
*
S3Uploader
)
Upload
(
imageDiskPath
string
)
(
string
,
error
)
{
sess
:=
session
.
New
()
sess
,
err
:=
session
.
NewSession
()
if
err
!=
nil
{
return
""
,
err
}
creds
:=
credentials
.
NewChainCredentials
(
[]
credentials
.
Provider
{
&
credentials
.
StaticProvider
{
Value
:
credentials
.
Value
{
...
...
@@ -58,7 +61,11 @@ func (u *S3Uploader) Upload(imageDiskPath string) (string, error) {
return
""
,
err
}
svc
:=
s3
.
New
(
session
.
New
(
cfg
),
cfg
)
sess
,
err
=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
return
""
,
err
}
svc
:=
s3
.
New
(
sess
,
cfg
)
params
:=
&
s3
.
PutObjectInput
{
Bucket
:
aws
.
String
(
u
.
bucket
),
Key
:
aws
.
String
(
key
),
...
...
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