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
af216ecf
Commit
af216ecf
authored
Jun 25, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tech(cli): remove loop and head straight for plugindir
parent
07be2c89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
pkg/cmd/grafana-cli/commands/remove_command.go
+9
-7
pkg/cmd/grafana-cli/services/services.go
+10
-3
No files found.
pkg/cmd/grafana-cli/commands/remove_command.go
View file @
af216ecf
...
@@ -2,10 +2,10 @@ package commands
...
@@ -2,10 +2,10 @@ package commands
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
m
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
m
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
services
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
services
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
"strings"
)
)
var
getPluginss
func
(
path
string
)
[]
m
.
InstalledPlugin
=
services
.
GetLocalPlugins
var
getPluginss
func
(
path
string
)
[]
m
.
InstalledPlugin
=
services
.
GetLocalPlugins
...
@@ -13,19 +13,21 @@ var removePlugin func(pluginPath, id string) error = services.RemoveInstalledPlu
...
@@ -13,19 +13,21 @@ var removePlugin func(pluginPath, id string) error = services.RemoveInstalledPlu
func
removeCommand
(
c
CommandLine
)
error
{
func
removeCommand
(
c
CommandLine
)
error
{
pluginPath
:=
c
.
PluginDirectory
()
pluginPath
:=
c
.
PluginDirectory
()
localPlugins
:=
getPluginss
(
pluginPath
)
plugin
:=
c
.
Args
()
.
First
()
plugin
:=
c
.
Args
()
.
First
()
if
plugin
==
""
{
if
plugin
==
""
{
return
errors
.
New
(
"Missing plugin parameter"
)
return
errors
.
New
(
"Missing plugin parameter"
)
}
}
for
_
,
p
:=
range
localPlugins
{
err
:=
removePlugin
(
pluginPath
,
plugin
)
if
p
.
Id
==
c
.
Args
()
.
First
()
{
removePlugin
(
pluginPath
,
p
.
Id
)
if
err
!=
nil
{
return
nil
if
strings
.
Contains
(
err
.
Error
(),
"no such file or directory"
)
{
return
fmt
.
Errorf
(
"Plugin does not exist"
)
}
}
return
err
}
}
return
fmt
.
Errorf
(
"Could not find plugin named %s"
,
c
.
Args
()
.
First
())
return
nil
}
}
pkg/cmd/grafana-cli/services/services.go
View file @
af216ecf
...
@@ -75,9 +75,16 @@ func GetLocalPlugins(pluginDir string) []m.InstalledPlugin {
...
@@ -75,9 +75,16 @@ func GetLocalPlugins(pluginDir string) []m.InstalledPlugin {
return
result
return
result
}
}
func
RemoveInstalledPlugin
(
pluginPath
,
id
string
)
error
{
func
RemoveInstalledPlugin
(
pluginPath
,
pluginName
string
)
error
{
logger
.
Infof
(
"Removing plugin: %v
\n
"
,
id
)
logger
.
Infof
(
"Removing plugin: %v
\n
"
,
pluginName
)
return
IoHelper
.
RemoveAll
(
path
.
Join
(
pluginPath
,
id
))
pluginDir
:=
path
.
Join
(
pluginPath
,
pluginName
)
_
,
err
:=
IoHelper
.
Stat
(
pluginDir
)
if
err
!=
nil
{
return
err
}
return
IoHelper
.
RemoveAll
(
pluginDir
)
}
}
func
GetPlugin
(
pluginId
,
repoUrl
string
)
(
m
.
Plugin
,
error
)
{
func
GetPlugin
(
pluginId
,
repoUrl
string
)
(
m
.
Plugin
,
error
)
{
...
...
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