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