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
87983021
Commit
87983021
authored
Nov 16, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
datasources as cfg: convert yaml map into json for jsonData
parent
6267ef13
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
27 deletions
+50
-27
conf/datasources/datasources.yaml
+7
-4
pkg/services/provisioning/datasources/datasources_test.go
+10
-0
pkg/services/provisioning/datasources/test-configs/all-properties/all-properties.yaml
+8
-2
pkg/services/provisioning/datasources/types.go
+25
-21
No files found.
conf/datasources/datasources.yaml
View file @
87983021
...
...
@@ -32,10 +32,13 @@ datasources:
# with_credentials:
# # <bool> mark as default datasource. Max one per org
# is_default:
# # <string> json data
# json_data: '{"graphiteVersion":"0.9"}'
# # <string> json object of data that will be encrypted in UI.
# secure_json_fields: ''
# # <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: ''
# # <int> including this value guarantees that instance with old configs cannot
# # overwrite your last change.
# version: 1
...
...
pkg/services/provisioning/datasources/datasources_test.go
View file @
87983021
...
...
@@ -146,6 +146,16 @@ func TestDatasourceAsConfig(t *testing.T) {
So
(
ds
.
IsDefault
,
ShouldBeTrue
)
So
(
ds
.
Editable
,
ShouldBeTrue
)
So
(
len
(
ds
.
JsonData
),
ShouldBeGreaterThan
,
2
)
So
(
ds
.
JsonData
[
"graphiteVersion"
],
ShouldEqual
,
"1.1"
)
So
(
ds
.
JsonData
[
"tlsAuth"
],
ShouldEqual
,
true
)
So
(
ds
.
JsonData
[
"tlsAuthWithCACert"
],
ShouldEqual
,
true
)
So
(
len
(
ds
.
SecureJsonData
),
ShouldBeGreaterThan
,
2
)
So
(
ds
.
SecureJsonData
[
"tlsCACert"
],
ShouldEqual
,
"MjNOcW9RdkbUDHZmpco2HCYzVq9dE+i6Yi+gmUJotq5CDA=="
)
So
(
ds
.
SecureJsonData
[
"tlsClientCert"
],
ShouldEqual
,
"ckN0dGlyMXN503YNfjTcf9CV+GGQneN+xmAclQ=="
)
So
(
ds
.
SecureJsonData
[
"tlsClientKey"
],
ShouldEqual
,
"ZkN4aG1aNkja/gKAB1wlnKFIsy2SRDq4slrM0A=="
)
dstwo
:=
cfg
[
1
]
.
Datasources
[
0
]
So
(
dstwo
.
Name
,
ShouldEqual
,
"name2"
)
})
...
...
pkg/services/provisioning/datasources/test-configs/all-properties/all-properties.yaml
View file @
87983021
...
...
@@ -12,6 +12,12 @@ datasources:
basic_auth_password
:
basic_auth_password
with_credentials
:
true
is_default
:
true
json_data
:
'
{"graphiteVersion":"0.9"}'
secure_json_fields
:
'
'
json_data
:
graphiteVersion
:
"
1.1"
tlsAuth
:
true
tlsAuthWithCACert
:
true
secure_json_data
:
tlsCACert
:
"
MjNOcW9RdkbUDHZmpco2HCYzVq9dE+i6Yi+gmUJotq5CDA=="
tlsClientCert
:
"
ckN0dGlyMXN503YNfjTcf9CV+GGQneN+xmAclQ=="
tlsClientKey
:
"
ZkN4aG1aNkja/gKAB1wlnKFIsy2SRDq4slrM0A=="
editable
:
true
pkg/services/provisioning/datasources/types.go
View file @
87983021
...
...
@@ -17,27 +17,29 @@ type DataSourceFromConfig struct {
OrgId
int64
`json:"org_id" yaml:"org_id"`
Version
int
`json:"version" yaml:"version"`
Name
string
`json:"name" yaml:"name"`
Type
string
`json:"type" yaml:"type"`
Access
string
`json:"access" yaml:"access"`
Url
string
`json:"url" yaml:"url"`
Password
string
`json:"password" yaml:"password"`
User
string
`json:"user" yaml:"user"`
Database
string
`json:"database" yaml:"database"`
BasicAuth
bool
`json:"basic_auth" yaml:"basic_auth"`
BasicAuthUser
string
`json:"basic_auth_user" yaml:"basic_auth_user"`
BasicAuthPassword
string
`json:"basic_auth_password" yaml:"basic_auth_password"`
WithCredentials
bool
`json:"with_credentials" yaml:"with_credentials"`
IsDefault
bool
`json:"is_default" yaml:"is_default"`
JsonData
string
`json:"json_data" yaml:"json_data"`
SecureJsonData
map
[
string
]
string
`json:"secure_json_data" yaml:"secure_json_data"`
Editable
bool
`json:"editable" yaml:"editable"`
Name
string
`json:"name" yaml:"name"`
Type
string
`json:"type" yaml:"type"`
Access
string
`json:"access" yaml:"access"`
Url
string
`json:"url" yaml:"url"`
Password
string
`json:"password" yaml:"password"`
User
string
`json:"user" yaml:"user"`
Database
string
`json:"database" yaml:"database"`
BasicAuth
bool
`json:"basic_auth" yaml:"basic_auth"`
BasicAuthUser
string
`json:"basic_auth_user" yaml:"basic_auth_user"`
BasicAuthPassword
string
`json:"basic_auth_password" yaml:"basic_auth_password"`
WithCredentials
bool
`json:"with_credentials" yaml:"with_credentials"`
IsDefault
bool
`json:"is_default" yaml:"is_default"`
JsonData
map
[
string
]
interface
{}
`json:"json_data" yaml:"json_data"`
SecureJsonData
map
[
string
]
string
`json:"secure_json_data" yaml:"secure_json_data"`
Editable
bool
`json:"editable" yaml:"editable"`
}
func
createInsertCommand
(
ds
*
DataSourceFromConfig
)
*
models
.
AddDataSourceCommand
{
jsonData
,
err
:=
simplejson
.
NewJson
([]
byte
(
ds
.
JsonData
))
if
err
!=
nil
{
jsonData
=
simplejson
.
New
()
jsonData
:=
simplejson
.
New
()
if
len
(
ds
.
JsonData
)
>
0
{
for
k
,
v
:=
range
ds
.
JsonData
{
jsonData
.
Set
(
k
,
v
)
}
}
return
&
models
.
AddDataSourceCommand
{
...
...
@@ -61,9 +63,11 @@ func createInsertCommand(ds *DataSourceFromConfig) *models.AddDataSourceCommand
}
func
createUpdateCommand
(
ds
*
DataSourceFromConfig
,
id
int64
)
*
models
.
UpdateDataSourceCommand
{
jsonData
,
err
:=
simplejson
.
NewJson
([]
byte
(
ds
.
JsonData
))
if
err
!=
nil
{
jsonData
=
simplejson
.
New
()
jsonData
:=
simplejson
.
New
()
if
len
(
ds
.
JsonData
)
>
0
{
for
k
,
v
:=
range
ds
.
JsonData
{
jsonData
.
Set
(
k
,
v
)
}
}
return
&
models
.
UpdateDataSourceCommand
{
...
...
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