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
1fd40a48
Commit
1fd40a48
authored
Jan 10, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
supports windows compatible plugin binaries
parent
ebd86776
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
10 deletions
+40
-10
pkg/plugins/datasource_plugin.go
+11
-4
pkg/plugins/datasource_plugin_test.go
+29
-6
No files found.
pkg/plugins/datasource_plugin.go
View file @
1fd40a48
...
...
@@ -65,8 +65,14 @@ var handshakeConfig = plugin.HandshakeConfig{
MagicCookieValue
:
"datasource"
,
}
func
buildExecutablePath
(
pluginDir
,
executable
,
os
,
arch
string
)
string
{
return
path
.
Join
(
pluginDir
,
fmt
.
Sprintf
(
"%s_%s_%s"
,
executable
,
strings
.
ToLower
(
os
),
strings
.
ToLower
(
arch
)))
func
composeBinaryName
(
executable
,
os
,
arch
string
)
string
{
var
extension
string
os
=
strings
.
ToLower
(
os
)
if
os
==
"windows"
{
extension
=
".exe"
}
return
fmt
.
Sprintf
(
"%s_%s_%s%s"
,
executable
,
os
,
strings
.
ToLower
(
arch
),
extension
)
}
func
(
p
*
DataSourcePlugin
)
initBackendPlugin
(
ctx
context
.
Context
,
log
log
.
Logger
)
error
{
...
...
@@ -81,12 +87,13 @@ func (p *DataSourcePlugin) initBackendPlugin(ctx context.Context, log log.Logger
}
func
(
p
*
DataSourcePlugin
)
spawnSubProcess
()
error
{
cmd
:=
buildExecutablePath
(
p
.
PluginDir
,
p
.
Executable
,
runtime
.
GOOS
,
runtime
.
GOARCH
)
cmd
:=
composeBinaryName
(
p
.
Executable
,
runtime
.
GOOS
,
runtime
.
GOARCH
)
fullpath
:=
path
.
Join
(
p
.
PluginDir
,
cmd
)
p
.
client
=
plugin
.
NewClient
(
&
plugin
.
ClientConfig
{
HandshakeConfig
:
handshakeConfig
,
Plugins
:
map
[
string
]
plugin
.
Plugin
{
p
.
Id
:
&
shared
.
TsdbPluginImpl
{}},
Cmd
:
exec
.
Command
(
cmd
),
Cmd
:
exec
.
Command
(
fullpath
),
AllowedProtocols
:
[]
plugin
.
Protocol
{
plugin
.
ProtocolGRPC
},
Logger
:
LogWrapper
{
Logger
:
p
.
log
},
})
...
...
pkg/plugins/datasource_plugin_test.go
View file @
1fd40a48
package
plugins
import
"testing"
import
(
"testing"
)
func
TestExecutablePathBuilder
(
t
*
testing
.
T
)
{
func
TestComposeBinaryName
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
os
string
arch
string
have
:=
buildExecutablePath
(
"/var/grafana/plugins/grafana-simple-json-datasource"
,
"simple-json"
,
"linux"
,
"amd64"
)
want
:=
`/var/grafana/plugins/grafana-simple-json-datasource/simple-json_linux_amd64`
if
have
!=
want
{
t
.
Errorf
(
"expected %s got %s"
,
want
,
have
)
expectedPath
string
}{
{
name
:
"simple-json"
,
os
:
"linux"
,
arch
:
"amd64"
,
expectedPath
:
`simple-json_linux_amd64`
,
},
{
name
:
"simple-json"
,
os
:
"windows"
,
arch
:
"amd64"
,
expectedPath
:
`simple-json_windows_amd64.exe`
,
},
}
for
_
,
v
:=
range
tests
{
have
:=
composeBinaryName
(
v
.
name
,
v
.
os
,
v
.
arch
)
if
have
!=
v
.
expectedPath
{
t
.
Errorf
(
"expected %s got %s"
,
v
.
expectedPath
,
have
)
}
}
}
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