Commit 4dc6074e by bergquist

provisioning: dont ignore sample yaml files

closes #10963
parent c5461fe2
# This file is only an example.
# Grafana will never read sample.yaml files
# # config file version # # config file version
# apiVersion: 1 apiVersion: 1
#providers: #providers:
# - name: 'default' # - name: 'default'
......
# This file is only an example.
# Grafana will never read sample.yaml files
# # config file version # # config file version
# apiVersion: 1 apiVersion: 1
# # list of datasources that should be deleted from the database # # list of datasources that should be deleted from the database
#deleteDatasources: #deleteDatasources:
......
...@@ -63,7 +63,7 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) { ...@@ -63,7 +63,7 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) {
} }
for _, file := range files { for _, file := range files {
if (!strings.HasSuffix(file.Name(), ".yaml") && !strings.HasSuffix(file.Name(), ".yml")) || file.Name() == "sample.yaml" { if !strings.HasSuffix(file.Name(), ".yaml") && !strings.HasSuffix(file.Name(), ".yml") {
continue continue
} }
......
apiVersion: 1 apiVersion: 1
providers: #providers:
- name: 'gasdf' #- name: 'gasdf'
orgId: 2 # orgId: 2
folder: 'developers' # folder: 'developers'
editable: true # editable: true
type: file # type: file
options: # options:
path: /var/lib/grafana/dashboards # path: /var/lib/grafana/dashboards
...@@ -24,7 +24,7 @@ func (cr *configReader) readConfig(path string) ([]*DatasourcesAsConfig, error) ...@@ -24,7 +24,7 @@ func (cr *configReader) readConfig(path string) ([]*DatasourcesAsConfig, error)
} }
for _, file := range files { for _, file := range files {
if (strings.HasSuffix(file.Name(), ".yaml") || strings.HasSuffix(file.Name(), ".yml")) && file.Name() != "sample.yaml" { if strings.HasSuffix(file.Name(), ".yaml") || strings.HasSuffix(file.Name(), ".yml") {
datasource, err := cr.parseDatasourceConfig(path, file) datasource, err := cr.parseDatasourceConfig(path, file)
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -138,7 +138,7 @@ func TestDatasourceAsConfig(t *testing.T) { ...@@ -138,7 +138,7 @@ func TestDatasourceAsConfig(t *testing.T) {
t.Fatalf("readConfig return an error %v", err) t.Fatalf("readConfig return an error %v", err)
} }
So(len(cfg), ShouldEqual, 2) So(len(cfg), ShouldEqual, 3)
dsCfg := cfg[0] dsCfg := cfg[0]
...@@ -146,6 +146,17 @@ func TestDatasourceAsConfig(t *testing.T) { ...@@ -146,6 +146,17 @@ func TestDatasourceAsConfig(t *testing.T) {
validateDatasource(dsCfg) validateDatasource(dsCfg)
validateDeleteDatasources(dsCfg) validateDeleteDatasources(dsCfg)
dsCount := 0
delDsCount := 0
for _, c := range cfg {
dsCount += len(c.Datasources)
delDsCount += len(c.DeleteDatasources)
}
So(dsCount, ShouldEqual, 2)
So(delDsCount, ShouldEqual, 1)
}) })
Convey("can read all properties from version 0", func() { Convey("can read all properties from version 0", func() {
......
...@@ -3,30 +3,30 @@ ...@@ -3,30 +3,30 @@
apiVersion: 1 apiVersion: 1
datasources: #datasources:
- name: name # - name: name
type: type # type: type
access: proxy # access: proxy
orgId: 2 # orgId: 2
url: url # url: url
password: password # password: password
user: user # user: user
database: database # database: database
basicAuth: true # basicAuth: true
basicAuthUser: basic_auth_user # basicAuthUser: basic_auth_user
basicAuthPassword: basic_auth_password # basicAuthPassword: basic_auth_password
withCredentials: true # withCredentials: true
jsonData: # jsonData:
graphiteVersion: "1.1" # graphiteVersion: "1.1"
tlsAuth: true # tlsAuth: true
tlsAuthWithCACert: true # tlsAuthWithCACert: true
secureJsonData: # secureJsonData:
tlsCACert: "MjNOcW9RdkbUDHZmpco2HCYzVq9dE+i6Yi+gmUJotq5CDA==" # tlsCACert: "MjNOcW9RdkbUDHZmpco2HCYzVq9dE+i6Yi+gmUJotq5CDA=="
tlsClientCert: "ckN0dGlyMXN503YNfjTcf9CV+GGQneN+xmAclQ==" # tlsClientCert: "ckN0dGlyMXN503YNfjTcf9CV+GGQneN+xmAclQ=="
tlsClientKey: "ZkN4aG1aNkja/gKAB1wlnKFIsy2SRDq4slrM0A==" # tlsClientKey: "ZkN4aG1aNkja/gKAB1wlnKFIsy2SRDq4slrM0A=="
editable: true # editable: true
version: 10 # version: 10
#
deleteDatasources: #deleteDatasources:
- name: old-graphite3 # - name: old-graphite3
orgId: 2 # orgId: 2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment