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
fee0745e
Commit
fee0745e
authored
Mar 10, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(cli): support for asking grafana net about plugins
parent
43073da7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
15 deletions
+18
-15
pkg/cmd/grafana-cli/commands/install_command.go
+10
-8
pkg/cmd/grafana-cli/commands/ls_command.go
+2
-2
pkg/cmd/grafana-cli/commands/ls_command_test.go
+3
-3
pkg/cmd/grafana-cli/main.go
+1
-1
pkg/cmd/grafana-cli/services/services.go
+2
-1
No files found.
pkg/cmd/grafana-cli/commands/install_command.go
View file @
fee0745e
...
...
@@ -4,6 +4,7 @@ import (
"archive/zip"
"bytes"
"errors"
"fmt"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
m
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
s
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
...
...
@@ -64,30 +65,31 @@ func InstallPlugin(pluginName, version string, c CommandLine) error {
return
err
}
url
:=
v
.
Url
commit
:=
v
.
Commit
if
version
==
""
{
version
=
v
.
Version
}
downloadURL
:=
url
+
"/archive/"
+
commit
+
".zip"
downloadURL
:=
fmt
.
Sprintf
(
"%s/%s/versions/%s/download"
,
c
.
GlobalString
(
"repo"
),
pluginName
,
version
)
log
.
Infof
(
"installing %v @ %v
\n
"
,
plugin
.
Id
,
version
)
log
.
Infof
(
"from url: %v
\n
"
,
downloadURL
)
log
.
Infof
(
"on commit: %v
\n
"
,
commit
)
log
.
Infof
(
"into: %v
\n
"
,
pluginFolder
)
err
=
downloadFile
(
plugin
.
Id
,
pluginFolder
,
downloadURL
)
if
err
=
=
nil
{
log
.
Infof
(
"Installed %v successfully ✔
\n
"
,
plugin
.
Id
)
if
err
!
=
nil
{
return
err
}
log
.
Infof
(
"Installed %v successfully ✔
\n
"
,
plugin
.
Id
)
res
,
_
:=
s
.
ReadPlugin
(
pluginFolder
,
pluginName
)
for
_
,
v
:=
range
res
.
Dependency
.
Plugins
{
InstallPlugin
(
v
.
Id
,
version
,
c
)
log
.
Infof
(
"Installed
D
ependency: %v ✔
\n
"
,
v
.
Id
)
log
.
Infof
(
"Installed
d
ependency: %v ✔
\n
"
,
v
.
Id
)
}
return
err
...
...
pkg/cmd/grafana-cli/commands/ls_command.go
View file @
fee0745e
...
...
@@ -10,7 +10,7 @@ import (
var
ls_getPlugins
func
(
path
string
)
[]
m
.
InstalledPlugin
=
s
.
GetLocalPlugins
var
validateLsComm
m
and
=
func
(
pluginDir
string
)
error
{
var
validateLsCommand
=
func
(
pluginDir
string
)
error
{
if
pluginDir
==
""
{
return
errors
.
New
(
"missing path flag"
)
}
...
...
@@ -31,7 +31,7 @@ var validateLsCommmand = func(pluginDir string) error {
func
lsCommand
(
c
CommandLine
)
error
{
pluginDir
:=
c
.
GlobalString
(
"path"
)
if
err
:=
validateLsComm
m
and
(
pluginDir
);
err
!=
nil
{
if
err
:=
validateLsCommand
(
pluginDir
);
err
!=
nil
{
return
err
}
...
...
pkg/cmd/grafana-cli/commands/ls_command_test.go
View file @
fee0745e
...
...
@@ -9,10 +9,10 @@ import (
)
func
TestMissingPath
(
t
*
testing
.
T
)
{
var
org
=
validateLsComm
m
and
var
org
=
validateLsCommand
Convey
(
"ls command"
,
t
,
func
()
{
validateLsComm
m
and
=
org
validateLsCommand
=
org
Convey
(
"Missing path"
,
func
()
{
commandLine
:=
&
commandstest
.
FakeCommandLine
{
...
...
@@ -61,7 +61,7 @@ func TestMissingPath(t *testing.T) {
},
}
validateLsComm
m
and
=
func
(
pluginDir
string
)
error
{
validateLsCommand
=
func
(
pluginDir
string
)
error
{
return
errors
.
New
(
"dummie error"
)
}
...
...
pkg/cmd/grafana-cli/main.go
View file @
fee0745e
...
...
@@ -41,7 +41,7 @@ func main() {
cli
.
StringFlag
{
Name
:
"repo"
,
Usage
:
"url to the plugin repository"
,
Value
:
"
https://raw.githubusercontent.com/grafana/grafana-plugin-repository/master/repo.json
"
,
Value
:
""
,
},
cli
.
BoolFlag
{
Name
:
"debug, d"
,
...
...
pkg/cmd/grafana-cli/services/services.go
View file @
fee0745e
...
...
@@ -12,7 +12,8 @@ import (
var
IoHelper
m
.
IoUtil
=
IoUtilImp
{}
func
ListAllPlugins
(
repoUrl
string
)
(
m
.
PluginRepo
,
error
)
{
res
,
_
:=
goreq
.
Request
{
Uri
:
repoUrl
,
MaxRedirects
:
3
}
.
Do
()
res
,
_
:=
goreq
.
Request
{
Uri
:
repoUrl
+
"/repo"
,
MaxRedirects
:
3
}
.
Do
()
var
resp
m
.
PluginRepo
err
:=
res
.
Body
.
FromJsonTo
(
&
resp
)
...
...
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