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
dc0fb8be
Commit
dc0fb8be
authored
Nov 28, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboards as cfg: code cleanup
parent
d69b63cb
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
13 additions
and
32 deletions
+13
-32
pkg/services/provisioning/dashboard/dashboard.go
+4
-8
pkg/services/provisioning/dashboard/file_reader.go
+2
-2
pkg/services/provisioning/datasource/datasources.go
+1
-1
pkg/services/provisioning/datasource/datasources_test.go
+1
-1
pkg/services/provisioning/datasource/test-configs/all-properties/all-properties.yaml
+0
-0
pkg/services/provisioning/datasource/test-configs/all-properties/not.yaml.txt
+0
-0
pkg/services/provisioning/datasource/test-configs/all-properties/second.yaml
+0
-0
pkg/services/provisioning/datasource/test-configs/broken-yaml/broken.yaml
+0
-0
pkg/services/provisioning/datasource/test-configs/double-default/default-1.yaml
+0
-0
pkg/services/provisioning/datasource/test-configs/double-default/default-2.yaml
+0
-0
pkg/services/provisioning/datasource/test-configs/insert-two-delete-two/one-datasources.yaml
+0
-0
pkg/services/provisioning/datasource/test-configs/insert-two-delete-two/two-datasources.yml
+0
-0
pkg/services/provisioning/datasource/test-configs/two-datasources/two-datasources.yaml
+0
-0
pkg/services/provisioning/datasource/test-configs/zero-datasources/placeholder-for-git
+0
-0
pkg/services/provisioning/datasource/types.go
+1
-1
pkg/services/provisioning/provisioning.go
+4
-19
No files found.
pkg/services/provisioning/dashboard/dashboard.go
View file @
dc0fb8be
...
...
@@ -30,19 +30,15 @@ func (provider *DashboardProvisioner) Init(ctx context.Context) error {
}
for
_
,
cfg
:=
range
cfgs
{
if
cfg
.
Type
==
"file"
{
switch
cfg
.
Type
{
case
"file"
:
fileReader
,
err
:=
NewDashboardFilereader
(
cfg
,
provider
.
log
.
New
(
"type"
,
cfg
.
Type
,
"name"
,
cfg
.
Name
))
if
err
!=
nil
{
return
err
}
// err = fileReader.Init()
// if err != nil {
// provider.log.Error("Failed to load dashboards", "error", err)
// }
go
fileReader
.
Listen
(
ctx
)
}
else
{
go
fileReader
.
ReadAndListen
(
ctx
)
default
:
return
fmt
.
Errorf
(
"type %s is not supported"
,
cfg
.
Type
)
}
}
...
...
pkg/services/provisioning/dashboard/file_reader.go
View file @
dc0fb8be
...
...
@@ -67,8 +67,8 @@ func NewDashboardFilereader(cfg *DashboardsAsConfig, log log.Logger) (*fileReade
},
nil
}
func
(
fr
*
fileReader
)
Listen
(
ctx
context
.
Context
)
error
{
ticker
:=
time
.
NewTicker
(
time
.
Second
*
1
)
func
(
fr
*
fileReader
)
ReadAnd
Listen
(
ctx
context
.
Context
)
error
{
ticker
:=
time
.
NewTicker
(
time
.
Second
*
1
0
)
if
err
:=
fr
.
walkFolder
();
err
!=
nil
{
fr
.
log
.
Error
(
"failed to search for dashboards"
,
"error"
,
err
)
...
...
pkg/services/provisioning/datasource
s
/datasources.go
→
pkg/services/provisioning/datasource/datasources.go
View file @
dc0fb8be
package
datasource
s
package
datasource
import
(
"errors"
...
...
pkg/services/provisioning/datasource
s
/datasources_test.go
→
pkg/services/provisioning/datasource/datasources_test.go
View file @
dc0fb8be
package
datasource
s
package
datasource
import
(
"testing"
...
...
pkg/services/provisioning/datasource
s
/test-configs/all-properties/all-properties.yaml
→
pkg/services/provisioning/datasource/test-configs/all-properties/all-properties.yaml
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/all-properties/not.yaml.txt
→
pkg/services/provisioning/datasource/test-configs/all-properties/not.yaml.txt
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/all-properties/second.yaml
→
pkg/services/provisioning/datasource/test-configs/all-properties/second.yaml
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/broken-yaml/broken.yaml
→
pkg/services/provisioning/datasource/test-configs/broken-yaml/broken.yaml
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/double-default/default-1.yaml
→
pkg/services/provisioning/datasource/test-configs/double-default/default-1.yaml
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/double-default/default-2.yaml
→
pkg/services/provisioning/datasource/test-configs/double-default/default-2.yaml
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/insert-two-delete-two/one-datasources.yaml
→
pkg/services/provisioning/datasource/test-configs/insert-two-delete-two/one-datasources.yaml
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/insert-two-delete-two/two-datasources.yml
→
pkg/services/provisioning/datasource/test-configs/insert-two-delete-two/two-datasources.yml
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/two-datasources/two-datasources.yaml
→
pkg/services/provisioning/datasource/test-configs/two-datasources/two-datasources.yaml
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/test-configs/zero-datasources/placeholder-for-git
→
pkg/services/provisioning/datasource/test-configs/zero-datasources/placeholder-for-git
View file @
dc0fb8be
File moved
pkg/services/provisioning/datasource
s
/types.go
→
pkg/services/provisioning/datasource/types.go
View file @
dc0fb8be
package
datasource
s
package
datasource
import
"github.com/grafana/grafana/pkg/models"
import
"github.com/grafana/grafana/pkg/components/simplejson"
...
...
pkg/services/provisioning/provisioning.go
View file @
dc0fb8be
...
...
@@ -4,30 +4,19 @@ import (
"context"
"path/filepath"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/services/provisioning/dashboard"
"github.com/grafana/grafana/pkg/services/provisioning/datasource
s
"
"github.com/grafana/grafana/pkg/services/provisioning/datasource"
ini
"gopkg.in/ini.v1"
)
var
(
logger
log
.
Logger
=
log
.
New
(
"services.provisioning"
)
)
type
Provisioner
struct
{
datasourcePath
string
dashboardPath
string
bgContext
context
.
Context
}
func
Init
(
backgroundContext
context
.
Context
,
homePath
string
,
cfg
*
ini
.
File
)
error
{
func
Init
(
ctx
context
.
Context
,
homePath
string
,
cfg
*
ini
.
File
)
error
{
datasourcePath
:=
makeAbsolute
(
cfg
.
Section
(
"paths"
)
.
Key
(
"datasources"
)
.
String
(),
homePath
)
if
err
:=
datasource
s
.
Provision
(
datasourcePath
);
err
!=
nil
{
if
err
:=
datasource
.
Provision
(
datasourcePath
);
err
!=
nil
{
return
err
}
dashboardPath
:=
makeAbsolute
(
cfg
.
Section
(
"paths"
)
.
Key
(
"dashboards"
)
.
String
(),
homePath
)
_
,
err
:=
dashboard
.
Provision
(
backgroundContext
,
dashboardPath
)
_
,
err
:=
dashboard
.
Provision
(
ctx
,
dashboardPath
)
if
err
!=
nil
{
return
err
}
...
...
@@ -35,10 +24,6 @@ func Init(backgroundContext context.Context, homePath string, cfg *ini.File) err
return
nil
}
func
(
p
*
Provisioner
)
Listen
()
error
{
return
nil
}
func
makeAbsolute
(
path
string
,
root
string
)
string
{
if
filepath
.
IsAbs
(
path
)
{
return
path
...
...
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