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
a3925e8a
Commit
a3925e8a
authored
Feb 15, 2015
by
Jason Wilder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CLI: Use console logger for dashbard:import command
More consistent w/ other commands and separates stdout/stderr
parent
7c8fa067
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
pkg/cmd/dashboard.go
+7
-11
No files found.
pkg/cmd/dashboard.go
View file @
a3925e8a
...
...
@@ -30,19 +30,16 @@ var ImportJson = cli.Command{
func
runImport
(
c
*
cli
.
Context
)
{
dir
:=
c
.
String
(
"dir"
)
if
len
(
dir
)
==
0
{
log
.
Error
(
3
,
"Missing command flag --dir"
)
return
log
.
ConsoleFatalf
(
"Missing command flag --dir"
)
}
file
,
err
:=
os
.
Stat
(
dir
)
if
os
.
IsNotExist
(
err
)
{
log
.
Error
(
3
,
"Directory does not exist: %v"
,
dir
)
return
log
.
ConsoleFatalf
(
"Directory does not exist: %v"
,
dir
)
}
if
!
file
.
IsDir
()
{
log
.
Error
(
3
,
"%v is not a directory"
,
dir
)
return
log
.
ConsoleFatalf
(
"%v is not a directory"
,
dir
)
}
if
!
c
.
Args
()
.
Present
()
{
...
...
@@ -57,8 +54,7 @@ func runImport(c *cli.Context) {
accountQuery
:=
m
.
GetAccountByNameQuery
{
Name
:
accountName
}
if
err
:=
bus
.
Dispatch
(
&
accountQuery
);
err
!=
nil
{
log
.
Error
(
3
,
"Failed to find account"
,
err
)
return
log
.
ConsoleFatalf
(
"Failed to find account"
,
err
)
}
accountId
:=
accountQuery
.
Result
.
Id
...
...
@@ -72,19 +68,19 @@ func runImport(c *cli.Context) {
}
if
strings
.
HasSuffix
(
f
.
Name
(),
".json"
)
{
if
err
:=
importDashboard
(
path
,
accountId
);
err
!=
nil
{
log
.
Error
(
3
,
"Failed to import dashboard file: %v, err: %v"
,
path
,
err
)
log
.
ConsoleFatalf
(
"Failed to import dashboard file: %v, err: %v"
,
path
,
err
)
}
}
return
nil
}
if
err
:=
filepath
.
Walk
(
dir
,
visitor
);
err
!=
nil
{
log
.
Error
(
3
,
"f
ailed to scan dir for json files: %v"
,
err
)
log
.
ConsoleFatalf
(
"F
ailed to scan dir for json files: %v"
,
err
)
}
}
func
importDashboard
(
path
string
,
accountId
int64
)
error
{
log
.
Info
(
"Importing %v"
,
path
)
log
.
ConsoleInfof
(
"Importing %v"
,
path
)
reader
,
err
:=
os
.
Open
(
path
)
if
err
!=
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