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
5f5cdad9
Commit
5f5cdad9
authored
Dec 08, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve error handling for datasources as cfg
parent
c7668023
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
6 deletions
+79
-6
conf/provisioning/datasources/sample.yaml
+2
-2
pkg/services/provisioning/dashboards/config_reader_test.go
+13
-0
pkg/services/provisioning/dashboards/test-configs/broken-configs/commented.yaml
+6
-0
pkg/services/provisioning/datasources/datasources.go
+10
-4
pkg/services/provisioning/datasources/test-configs/broken-yaml/commented.yaml
+48
-0
No files found.
conf/provisioning/datasources/
custom
.yaml
→
conf/provisioning/datasources/
sample
.yaml
View file @
5f5cdad9
# # list of datasources that should be deleted from the database
# # list of datasources that should be deleted from the database
delete_datasources
:
#
delete_datasources:
# - name: Graphite
# - name: Graphite
# org_id: 1
# org_id: 1
# # list of datasources to insert/update depending
# # list of datasources to insert/update depending
# # whats available in the datbase
# # whats available in the datbase
datasources
:
#
datasources:
# # <string, required> name of the datasource. Required
# # <string, required> name of the datasource. Required
# - name: Graphite
# - name: Graphite
# # <string, required> datasource type. Required
# # <string, required> datasource type. Required
...
...
pkg/services/provisioning/dashboards/
dashboard
_test.go
→
pkg/services/provisioning/dashboards/
config_reader
_test.go
View file @
5f5cdad9
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
var
(
var
(
simpleDashboardConfig
string
=
"./test-configs/dashboards-from-disk"
simpleDashboardConfig
string
=
"./test-configs/dashboards-from-disk"
brokenConfigs
string
=
"./test-configs/borken-configs"
)
)
func
TestDashboardsAsConfig
(
t
*
testing
.
T
)
{
func
TestDashboardsAsConfig
(
t
*
testing
.
T
)
{
...
@@ -45,5 +46,17 @@ func TestDashboardsAsConfig(t *testing.T) {
...
@@ -45,5 +46,17 @@ func TestDashboardsAsConfig(t *testing.T) {
So
(
len
(
ds2
.
Options
),
ShouldEqual
,
1
)
So
(
len
(
ds2
.
Options
),
ShouldEqual
,
1
)
So
(
ds2
.
Options
[
"folder"
],
ShouldEqual
,
"/var/lib/grafana/dashboards"
)
So
(
ds2
.
Options
[
"folder"
],
ShouldEqual
,
"/var/lib/grafana/dashboards"
)
})
})
Convey
(
"Should skip broken config files"
,
func
()
{
cfgProvifer
:=
configReader
{
path
:
brokenConfigs
}
cfg
,
err
:=
cfgProvifer
.
readConfig
()
if
err
!=
nil
{
t
.
Fatalf
(
"readConfig return an error %v"
,
err
)
}
So
(
len
(
cfg
),
ShouldEqual
,
0
)
})
})
})
}
}
pkg/services/provisioning/dashboards/test-configs/broken-configs/commented.yaml
0 → 100644
View file @
5f5cdad9
# - name: 'default'
# org_id: 1
# folder: ''
# type: file
# options:
# folder: /var/lib/grafana/dashboards
pkg/services/provisioning/datasources/datasources.go
View file @
5f5cdad9
...
@@ -118,13 +118,19 @@ func (configReader) readConfig(path string) ([]*DatasourcesAsConfig, error) {
...
@@ -118,13 +118,19 @@ func (configReader) readConfig(path string) ([]*DatasourcesAsConfig, error) {
return
nil
,
err
return
nil
,
err
}
}
datasources
=
append
(
datasources
,
datasource
)
if
datasource
!=
nil
{
datasources
=
append
(
datasources
,
datasource
)
}
}
}
}
}
defaultCount
:=
0
defaultCount
:=
0
for
_
,
cfg
:=
range
datasources
{
for
i
:=
range
datasources
{
for
_
,
ds
:=
range
cfg
.
Datasources
{
if
datasources
[
i
]
.
Datasources
==
nil
{
continue
}
for
_
,
ds
:=
range
datasources
[
i
]
.
Datasources
{
if
ds
.
OrgId
==
0
{
if
ds
.
OrgId
==
0
{
ds
.
OrgId
=
1
ds
.
OrgId
=
1
}
}
...
@@ -137,7 +143,7 @@ func (configReader) readConfig(path string) ([]*DatasourcesAsConfig, error) {
...
@@ -137,7 +143,7 @@ func (configReader) readConfig(path string) ([]*DatasourcesAsConfig, error) {
}
}
}
}
for
_
,
ds
:=
range
cfg
.
DeleteDatasources
{
for
_
,
ds
:=
range
datasources
[
i
]
.
DeleteDatasources
{
if
ds
.
OrgId
==
0
{
if
ds
.
OrgId
==
0
{
ds
.
OrgId
=
1
ds
.
OrgId
=
1
}
}
...
...
pkg/services/provisioning/datasources/test-configs/broken-yaml/commented.yaml
0 → 100644
View file @
5f5cdad9
# # list of datasources that should be deleted from the database
#delete_datasources:
# - name: Graphite
# org_id: 1
# # list of datasources to insert/update depending
# # whats available in the datbase
#datasources:
# # <string, required> name of the datasource. Required
# - name: Graphite
# # <string, required> datasource type. Required
# type: graphite
# # <string, required> access mode. direct or proxy. Required
# access: proxy
# # <int> org id. will default to org_id 1 if not specified
# org_id: 1
# # <string> url
# url: http://localhost:8080
# # <string> database password, if used
# password:
# # <string> database user, if used
# user:
# # <string> database name, if used
# database:
# # <bool> enable/disable basic auth
# basic_auth:
# # <string> basic auth username
# basic_auth_user:
# # <string> basic auth password
# basic_auth_password:
# # <bool> enable/disable with credentials headers
# with_credentials:
# # <bool> mark as default datasource. Max one per org
# is_default:
# # <map> fields that will be converted to json and stored in json_data
# json_data:
# graphiteVersion: "1.1"
# tlsAuth: true
# tlsAuthWithCACert: true
# # <string> json object of data that will be encrypted.
# secure_json_data:
# tlsCACert: "..."
# tlsClientCert: "..."
# tlsClientKey: "..."
# version: 1
# # <bool> allow users to edit datasources from the UI.
# editable: false
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