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
1e44ee9e
Commit
1e44ee9e
authored
Mar 28, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(grafana-cli): minor changes
parent
b3bda2aa
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
33 deletions
+36
-33
pkg/cmd/grafana-cli/commands/install_command.go
+13
-13
pkg/cmd/grafana-cli/commands/ls_command.go
+2
-1
pkg/cmd/grafana-cli/commands/remove_command.go
+2
-1
pkg/cmd/grafana-cli/commands/upgrade_all_command.go
+3
-3
pkg/cmd/grafana-cli/commands/upgrade_command.go
+3
-3
pkg/cmd/grafana-cli/main.go
+9
-7
pkg/cmd/grafana-cli/services/services.go
+3
-4
public/app/core/components/navbar/navbar.html
+1
-1
No files found.
pkg/cmd/grafana-cli/commands/install_command.go
View file @
1e44ee9e
...
...
@@ -5,10 +5,6 @@ import (
"bytes"
"errors"
"fmt"
"github.com/fatih/color"
"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"
"io"
"io/ioutil"
"net/http"
...
...
@@ -16,6 +12,11 @@ import (
"path"
"regexp"
"strings"
"github.com/fatih/color"
"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"
)
func
validateInput
(
c
CommandLine
,
pluginFolder
string
)
error
{
...
...
@@ -24,17 +25,16 @@ func validateInput(c CommandLine, pluginFolder string) error {
return
errors
.
New
(
"please specify plugin to install"
)
}
plugin
Dir
:=
c
.
GlobalString
(
"path
"
)
if
pluginDir
==
""
{
return
errors
.
New
(
"missing p
ath
flag"
)
plugin
sDir
:=
c
.
GlobalString
(
"pluginsDir
"
)
if
plugin
s
Dir
==
""
{
return
errors
.
New
(
"missing p
luginsDir
flag"
)
}
fileInfo
,
err
:=
os
.
Stat
(
pluginDir
)
fileInfo
,
err
:=
os
.
Stat
(
plugin
s
Dir
)
if
err
!=
nil
{
if
err
=
os
.
MkdirAll
(
pluginDir
,
os
.
ModePerm
);
err
!=
nil
{
return
errors
.
New
(
"path is not a directory"
)
if
err
=
os
.
MkdirAll
(
plugin
s
Dir
,
os
.
ModePerm
);
err
!=
nil
{
return
errors
.
New
(
fmt
.
Sprintf
(
"pluginsDir (%s) is not a directory"
,
pluginsDir
)
)
}
return
nil
}
...
...
@@ -46,7 +46,7 @@ func validateInput(c CommandLine, pluginFolder string) error {
}
func
installCommand
(
c
CommandLine
)
error
{
pluginFolder
:=
c
.
GlobalString
(
"p
ath
"
)
pluginFolder
:=
c
.
GlobalString
(
"p
luginsDir
"
)
if
err
:=
validateInput
(
c
,
pluginFolder
);
err
!=
nil
{
return
err
}
...
...
@@ -59,7 +59,7 @@ func installCommand(c CommandLine) error {
func
InstallPlugin
(
pluginName
,
version
string
,
c
CommandLine
)
error
{
plugin
,
err
:=
s
.
GetPlugin
(
pluginName
,
c
.
GlobalString
(
"repo"
))
pluginFolder
:=
c
.
GlobalString
(
"p
ath
"
)
pluginFolder
:=
c
.
GlobalString
(
"p
luginsDir
"
)
if
err
!=
nil
{
return
err
}
...
...
pkg/cmd/grafana-cli/commands/ls_command.go
View file @
1e44ee9e
...
...
@@ -3,6 +3,7 @@ package commands
import
(
"errors"
"fmt"
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
m
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
...
...
@@ -31,7 +32,7 @@ var validateLsCommand = func(pluginDir string) error {
}
func
lsCommand
(
c
CommandLine
)
error
{
pluginDir
:=
c
.
GlobalString
(
"p
ath
"
)
pluginDir
:=
c
.
GlobalString
(
"p
luginsDir
"
)
if
err
:=
validateLsCommand
(
pluginDir
);
err
!=
nil
{
return
err
}
...
...
pkg/cmd/grafana-cli/commands/remove_command.go
View file @
1e44ee9e
...
...
@@ -2,6 +2,7 @@ package commands
import
(
"errors"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
m
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
services
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
...
...
@@ -11,7 +12,7 @@ var getPluginss func(path string) []m.InstalledPlugin = services.GetLocalPlugins
var
removePlugin
func
(
pluginPath
,
id
string
)
error
=
services
.
RemoveInstalledPlugin
func
removeCommand
(
c
CommandLine
)
error
{
pluginPath
:=
c
.
GlobalString
(
"p
ath
"
)
pluginPath
:=
c
.
GlobalString
(
"p
luginsDir
"
)
localPlugins
:=
getPluginss
(
pluginPath
)
log
.
Info
(
"remove!
\n
"
)
...
...
pkg/cmd/grafana-cli/commands/upgrade_all_command.go
View file @
1e44ee9e
...
...
@@ -28,9 +28,9 @@ func ShouldUpgrade(installed string, remote m.Plugin) bool {
}
func
upgradeAllCommand
(
c
CommandLine
)
error
{
plugin
Dir
:=
c
.
GlobalString
(
"path
"
)
plugin
sDir
:=
c
.
GlobalString
(
"pluginsDir
"
)
localPlugins
:=
s
.
GetLocalPlugins
(
pluginDir
)
localPlugins
:=
s
.
GetLocalPlugins
(
plugin
s
Dir
)
remotePlugins
,
err
:=
s
.
ListAllPlugins
(
c
.
GlobalString
(
"repo"
))
...
...
@@ -53,7 +53,7 @@ func upgradeAllCommand(c CommandLine) error {
for
_
,
p
:=
range
pluginsToUpgrade
{
log
.
Infof
(
"Upgrading %v
\n
"
,
p
.
Id
)
s
.
RemoveInstalledPlugin
(
pluginDir
,
p
.
Id
)
s
.
RemoveInstalledPlugin
(
plugin
s
Dir
,
p
.
Id
)
InstallPlugin
(
p
.
Id
,
""
,
c
)
}
...
...
pkg/cmd/grafana-cli/commands/upgrade_command.go
View file @
1e44ee9e
...
...
@@ -5,10 +5,10 @@ import (
)
func
upgradeCommand
(
c
CommandLine
)
error
{
plugin
Dir
:=
c
.
GlobalString
(
"path
"
)
plugin
sDir
:=
c
.
GlobalString
(
"pluginsDir
"
)
pluginName
:=
c
.
Args
()
.
First
()
localPlugin
,
err
:=
s
.
ReadPlugin
(
pluginDir
,
pluginName
)
localPlugin
,
err
:=
s
.
ReadPlugin
(
plugin
s
Dir
,
pluginName
)
if
err
!=
nil
{
return
err
...
...
@@ -23,7 +23,7 @@ func upgradeCommand(c CommandLine) error {
for
_
,
v
:=
range
remotePlugins
.
Plugins
{
if
localPlugin
.
Id
==
v
.
Id
{
if
ShouldUpgrade
(
localPlugin
.
Info
.
Version
,
v
)
{
s
.
RemoveInstalledPlugin
(
pluginDir
,
pluginName
)
s
.
RemoveInstalledPlugin
(
plugin
s
Dir
,
pluginName
)
return
InstallPlugin
(
localPlugin
.
Id
,
""
,
c
)
}
}
...
...
pkg/cmd/grafana-cli/main.go
View file @
1e44ee9e
...
...
@@ -2,16 +2,17 @@ package main
import
(
"fmt"
"os"
"runtime"
"github.com/codegangsta/cli"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"os"
"runtime"
)
var
version
=
"master"
func
getGrafanaPlugin
Path
()
string
{
func
getGrafanaPlugin
Dir
()
string
{
os
:=
runtime
.
GOOS
if
os
==
"windows"
{
return
"C:
\\
opt
\\
grafana
\\
plugins"
...
...
@@ -25,14 +26,15 @@ func main() {
app
:=
cli
.
NewApp
()
app
.
Name
=
"Grafana cli"
app
.
Author
=
"raintank"
app
.
Usage
=
""
app
.
Author
=
"Grafana Project"
app
.
Email
=
"https://github.com/grafana/grafana"
app
.
Version
=
version
app
.
Flags
=
[]
cli
.
Flag
{
cli
.
StringFlag
{
Name
:
"p
ath
"
,
Usage
:
"path to the grafana
installation
"
,
Value
:
getGrafanaPlugin
Path
(),
Name
:
"p
luginsDir
"
,
Usage
:
"path to the grafana
plugin directory
"
,
Value
:
getGrafanaPlugin
Dir
(),
EnvVar
:
"GF_PLUGIN_DIR"
,
},
cli
.
StringFlag
{
...
...
pkg/cmd/grafana-cli/services/services.go
View file @
1e44ee9e
...
...
@@ -4,10 +4,11 @@ import (
"encoding/json"
"errors"
"fmt"
"path"
"github.com/franela/goreq"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
m
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
"path"
)
var
IoHelper
m
.
IoUtil
=
IoUtilImp
{}
...
...
@@ -66,9 +67,7 @@ func RemoveInstalledPlugin(pluginPath, id string) error {
}
func
GetPlugin
(
pluginId
,
repoUrl
string
)
(
m
.
Plugin
,
error
)
{
resp
,
err
:=
ListAllPlugins
(
repoUrl
)
if
err
!=
nil
{
}
resp
,
_
:=
ListAllPlugins
(
repoUrl
)
for
_
,
i
:=
range
resp
.
Plugins
{
if
i
.
Id
==
pluginId
{
...
...
public/app/core/components/navbar/navbar.html
View file @
1e44ee9e
...
...
@@ -10,7 +10,7 @@
<a
href=
"{{ctrl.titleUrl}}"
class=
"navbar-page-btn"
ng-show=
"ctrl.title"
>
<i
class=
"{{ctrl.icon}}"
ng-show=
"ctrl.icon"
></i>
<img
src=
"{{ctrl.iconUrl}}"
ng-show=
"ctrl.iconUrl"
></i>
<img
ng-
src=
"{{ctrl.iconUrl}}"
ng-show=
"ctrl.iconUrl"
></i>
{{ctrl.title}}
</a>
...
...
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