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
887387cd
Unverified
Commit
887387cd
authored
Aug 20, 2018
by
Marcus Efraimsson
Committed by
GitHub
Aug 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12974 from grafana/ds-proxy-json-data
dsproxy: interpolate route url
parents
0223a75d
c75e0712
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
pkg/api/pluginproxy/ds_proxy.go
+8
-2
pkg/api/pluginproxy/ds_proxy_test.go
+19
-0
No files found.
pkg/api/pluginproxy/ds_proxy.go
View file @
887387cd
...
...
@@ -320,9 +320,15 @@ func (proxy *DataSourceProxy) applyRoute(req *http.Request) {
SecureJsonData
:
proxy
.
ds
.
SecureJsonData
.
Decrypt
(),
}
routeURL
,
err
:=
url
.
Parse
(
proxy
.
route
.
Url
)
interpolatedURL
,
err
:=
interpolateString
(
proxy
.
route
.
Url
,
data
)
if
err
!=
nil
{
logger
.
Error
(
"Error parsing plugin route url"
)
logger
.
Error
(
"Error interpolating proxy url"
,
"error"
,
err
)
return
}
routeURL
,
err
:=
url
.
Parse
(
interpolatedURL
)
if
err
!=
nil
{
logger
.
Error
(
"Error parsing plugin route url"
,
"error"
,
err
)
return
}
...
...
pkg/api/pluginproxy/ds_proxy_test.go
View file @
887387cd
...
...
@@ -49,6 +49,13 @@ func TestDSRouteRule(t *testing.T) {
{
Name
:
"x-header"
,
Content
:
"my secret {{.SecureJsonData.key}}"
},
},
},
{
Path
:
"api/common"
,
Url
:
"{{.JsonData.dynamicUrl}}"
,
Headers
:
[]
plugins
.
AppPluginRouteHeader
{
{
Name
:
"x-header"
,
Content
:
"my secret {{.SecureJsonData.key}}"
},
},
},
},
}
...
...
@@ -58,6 +65,7 @@ func TestDSRouteRule(t *testing.T) {
ds
:=
&
m
.
DataSource
{
JsonData
:
simplejson
.
NewFromAny
(
map
[
string
]
interface
{}{
"clientId"
:
"asd"
,
"dynamicUrl"
:
"https://dynamic.grafana.com"
,
}),
SecureJsonData
:
map
[
string
][]
byte
{
"key"
:
key
,
...
...
@@ -83,6 +91,17 @@ func TestDSRouteRule(t *testing.T) {
})
})
Convey
(
"When matching route path and has dynamic url"
,
func
()
{
proxy
:=
NewDataSourceProxy
(
ds
,
plugin
,
ctx
,
"api/common/some/method"
)
proxy
.
route
=
plugin
.
Routes
[
3
]
proxy
.
applyRoute
(
req
)
Convey
(
"should add headers and interpolate the url"
,
func
()
{
So
(
req
.
URL
.
String
(),
ShouldEqual
,
"https://dynamic.grafana.com/some/method"
)
So
(
req
.
Header
.
Get
(
"x-header"
),
ShouldEqual
,
"my secret 123"
)
})
})
Convey
(
"Validating request"
,
func
()
{
Convey
(
"plugin route with valid role"
,
func
()
{
proxy
:=
NewDataSourceProxy
(
ds
,
plugin
,
ctx
,
"api/v4/some/method"
)
...
...
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