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
9f9f4e7f
Commit
9f9f4e7f
authored
May 12, 2016
by
Dan Cech
Committed by
Torkel Ödegaard
May 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use new plugin-specific repo route when installing or updating a single plugin (#4992)
parent
2f6b00b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
15 deletions
+22
-15
pkg/cmd/grafana-cli/commands/upgrade_command.go
+7
-8
pkg/cmd/grafana-cli/services/services.go
+15
-7
No files found.
pkg/cmd/grafana-cli/commands/upgrade_command.go
View file @
9f9f4e7f
package
commands
package
commands
import
(
import
(
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
s
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
s
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
)
)
...
@@ -14,20 +16,17 @@ func upgradeCommand(c CommandLine) error {
...
@@ -14,20 +16,17 @@ func upgradeCommand(c CommandLine) error {
return
err
return
err
}
}
remotePlugins
,
err2
:=
s
.
ListAllPlugins
(
c
.
GlobalString
(
"repo"
))
v
,
err2
:=
s
.
GetPlugin
(
localPlugin
.
Id
,
c
.
GlobalString
(
"repo"
))
if
err2
!=
nil
{
if
err2
!=
nil
{
return
err2
return
err2
}
}
for
_
,
v
:=
range
remotePlugins
.
Plugins
{
if
ShouldUpgrade
(
localPlugin
.
Info
.
Version
,
v
)
{
if
localPlugin
.
Id
==
v
.
Id
{
s
.
RemoveInstalledPlugin
(
pluginsDir
,
pluginName
)
if
ShouldUpgrade
(
localPlugin
.
Info
.
Version
,
v
)
{
return
InstallPlugin
(
localPlugin
.
Id
,
""
,
c
)
s
.
RemoveInstalledPlugin
(
pluginsDir
,
pluginName
)
return
InstallPlugin
(
localPlugin
.
Id
,
""
,
c
)
}
}
}
}
log
.
Infof
(
"%s %s is up to date
\n
"
,
color
.
GreenString
(
"✔"
),
localPlugin
.
Id
)
return
nil
return
nil
}
}
pkg/cmd/grafana-cli/services/services.go
View file @
9f9f4e7f
...
@@ -44,7 +44,7 @@ func ReadPlugin(pluginDir, pluginName string) (m.InstalledPlugin, error) {
...
@@ -44,7 +44,7 @@ func ReadPlugin(pluginDir, pluginName string) (m.InstalledPlugin, error) {
}
}
if
res
.
Id
==
""
{
if
res
.
Id
==
""
{
return
m
.
InstalledPlugin
{},
errors
.
New
(
"could not
read find plugin "
+
pluginName
)
return
m
.
InstalledPlugin
{},
errors
.
New
(
"could not
find plugin "
+
pluginName
+
" in "
+
pluginDir
)
}
}
return
res
,
nil
return
res
,
nil
...
@@ -69,13 +69,21 @@ func RemoveInstalledPlugin(pluginPath, id string) error {
...
@@ -69,13 +69,21 @@ func RemoveInstalledPlugin(pluginPath, id string) error {
}
}
func
GetPlugin
(
pluginId
,
repoUrl
string
)
(
m
.
Plugin
,
error
)
{
func
GetPlugin
(
pluginId
,
repoUrl
string
)
(
m
.
Plugin
,
error
)
{
resp
,
_
:=
ListAllPlugins
(
repoUrl
)
fullUrl
:=
repoUrl
+
"/repo/"
+
pluginId
for
_
,
i
:=
range
resp
.
Plugins
{
res
,
err
:=
goreq
.
Request
{
Uri
:
fullUrl
,
MaxRedirects
:
3
}
.
Do
()
if
i
.
Id
==
pluginId
{
if
err
!=
nil
{
return
i
,
nil
return
m
.
Plugin
{},
err
}
}
if
res
.
StatusCode
!=
200
{
return
m
.
Plugin
{},
fmt
.
Errorf
(
"Could not access %s statuscode %v"
,
fullUrl
,
res
.
StatusCode
)
}
}
return
m
.
Plugin
{},
errors
.
New
(
"could not find plugin named
\"
"
+
pluginId
+
"
\"
"
)
var
resp
m
.
Plugin
err
=
res
.
Body
.
FromJsonTo
(
&
resp
)
if
err
!=
nil
{
return
m
.
Plugin
{},
errors
.
New
(
"Could not load plugin data"
)
}
return
resp
,
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