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
6abbf5b3
Commit
6abbf5b3
authored
Oct 16, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: refactoring request builder
parent
1756e82d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
pkg/tsdb/stackdriver/stackdriver.go
+4
-6
No files found.
pkg/tsdb/stackdriver/stackdriver.go
View file @
6abbf5b3
...
@@ -283,7 +283,7 @@ func setAggParams(params *url.Values, query *tsdb.Query, durationSeconds int) {
...
@@ -283,7 +283,7 @@ func setAggParams(params *url.Values, query *tsdb.Query, durationSeconds int) {
func
(
e
*
StackdriverExecutor
)
executeQuery
(
ctx
context
.
Context
,
query
*
StackdriverQuery
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
(
*
tsdb
.
QueryResult
,
StackdriverResponse
,
error
)
{
func
(
e
*
StackdriverExecutor
)
executeQuery
(
ctx
context
.
Context
,
query
*
StackdriverQuery
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
(
*
tsdb
.
QueryResult
,
StackdriverResponse
,
error
)
{
queryResult
:=
&
tsdb
.
QueryResult
{
Meta
:
simplejson
.
New
(),
RefId
:
query
.
RefID
}
queryResult
:=
&
tsdb
.
QueryResult
{
Meta
:
simplejson
.
New
(),
RefId
:
query
.
RefID
}
req
,
err
:=
e
.
createRequest
(
ctx
,
e
.
dsInfo
,
"timeSeries"
)
req
,
err
:=
e
.
createRequest
(
ctx
,
e
.
dsInfo
)
if
err
!=
nil
{
if
err
!=
nil
{
queryResult
.
Error
=
err
queryResult
.
Error
=
err
return
queryResult
,
StackdriverResponse
{},
nil
return
queryResult
,
StackdriverResponse
{},
nil
...
@@ -550,7 +550,7 @@ func calcBucketBound(bucketOptions StackdriverBucketOptions, n int) string {
...
@@ -550,7 +550,7 @@ func calcBucketBound(bucketOptions StackdriverBucketOptions, n int) string {
return
bucketBound
return
bucketBound
}
}
func
(
e
*
StackdriverExecutor
)
createRequest
(
ctx
context
.
Context
,
dsInfo
*
models
.
DataSource
,
endpointName
string
)
(
*
http
.
Request
,
error
)
{
func
(
e
*
StackdriverExecutor
)
createRequest
(
ctx
context
.
Context
,
dsInfo
*
models
.
DataSource
)
(
*
http
.
Request
,
error
)
{
u
,
_
:=
url
.
Parse
(
dsInfo
.
Url
)
u
,
_
:=
url
.
Parse
(
dsInfo
.
Url
)
u
.
Path
=
path
.
Join
(
u
.
Path
,
"render"
)
u
.
Path
=
path
.
Join
(
u
.
Path
,
"render"
)
...
@@ -578,7 +578,7 @@ func (e *StackdriverExecutor) createRequest(ctx context.Context, dsInfo *models.
...
@@ -578,7 +578,7 @@ func (e *StackdriverExecutor) createRequest(ctx context.Context, dsInfo *models.
}
}
projectName
:=
dsInfo
.
JsonData
.
Get
(
"defaultProject"
)
.
MustString
()
projectName
:=
dsInfo
.
JsonData
.
Get
(
"defaultProject"
)
.
MustString
()
proxyPass
:=
fmt
.
Sprintf
(
"stackdriver%s"
,
"v3/projects/"
+
projectName
+
"/
"
+
endpointName
)
proxyPass
:=
fmt
.
Sprintf
(
"stackdriver%s"
,
"v3/projects/"
+
projectName
+
"/
timeSeries"
)
pluginproxy
.
ApplyRoute
(
ctx
,
req
,
proxyPass
,
stackdriverRoute
,
dsInfo
)
pluginproxy
.
ApplyRoute
(
ctx
,
req
,
proxyPass
,
stackdriverRoute
,
dsInfo
)
...
@@ -591,10 +591,8 @@ func (e *StackdriverExecutor) getDefaultProject(ctx context.Context) (string, er
...
@@ -591,10 +591,8 @@ func (e *StackdriverExecutor) getDefaultProject(ctx context.Context) (string, er
defaultCredentials
,
err
:=
google
.
FindDefaultCredentials
(
ctx
,
"https://www.googleapis.com/auth/monitoring.read"
)
defaultCredentials
,
err
:=
google
.
FindDefaultCredentials
(
ctx
,
"https://www.googleapis.com/auth/monitoring.read"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Failed to retrieve default project from GCE metadata server. error: %v"
,
err
)
return
""
,
fmt
.
Errorf
(
"Failed to retrieve default project from GCE metadata server. error: %v"
,
err
)
}
else
{
}
return
defaultCredentials
.
ProjectID
,
nil
return
defaultCredentials
.
ProjectID
,
nil
}
}
}
else
{
return
e
.
dsInfo
.
JsonData
.
Get
(
"defaultProject"
)
.
MustString
(),
nil
return
e
.
dsInfo
.
JsonData
.
Get
(
"defaultProject"
)
.
MustString
(),
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