mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Provisioning: Use proxy as default access mode in provisioning (#24669)
fixes #24591 fixes #19501
This commit is contained in:
parent
2f22781cd8
commit
7610d5717a
@ -94,6 +94,10 @@ func validateDefaultUniqueness(datasources []*configs) error {
|
||||
ds.OrgID = 1
|
||||
}
|
||||
|
||||
if ds.Access == "" {
|
||||
ds.Access = "proxy"
|
||||
}
|
||||
|
||||
if ds.IsDefault {
|
||||
defaultCount[ds.OrgID] = defaultCount[ds.OrgID] + 1
|
||||
if defaultCount[ds.OrgID] > 1 {
|
||||
|
@ -21,6 +21,7 @@ var (
|
||||
versionZero = "testdata/version-0"
|
||||
brokenYaml = "testdata/broken-yaml"
|
||||
multipleOrgsWithDefault = "testdata/multiple-org-default"
|
||||
withoutDefaults = "testdata/appliedDefaults"
|
||||
|
||||
fakeRepo *fakeRepository
|
||||
)
|
||||
@ -35,6 +36,18 @@ func TestDatasourceAsConfig(t *testing.T) {
|
||||
bus.AddHandler("test", mockGet)
|
||||
bus.AddHandler("test", mockGetAll)
|
||||
|
||||
Convey("apply default values when missing", func() {
|
||||
dc := newDatasourceProvisioner(logger)
|
||||
err := dc.applyChanges(withoutDefaults)
|
||||
if err != nil {
|
||||
t.Fatalf("applyChanges return an error %v", err)
|
||||
}
|
||||
|
||||
So(len(fakeRepo.inserted), ShouldEqual, 1)
|
||||
So(fakeRepo.inserted[0].OrgId, ShouldEqual, 1)
|
||||
So(fakeRepo.inserted[0].Access, ShouldEqual, "proxy")
|
||||
})
|
||||
|
||||
Convey("One configured datasource", func() {
|
||||
Convey("no datasource in database", func() {
|
||||
dc := newDatasourceProvisioner(logger)
|
||||
|
5
pkg/services/provisioning/datasources/testdata/appliedDefaults/without-defaults.yaml
vendored
Normal file
5
pkg/services/provisioning/datasources/testdata/appliedDefaults/without-defaults.yaml
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: $TEST_VAR
|
||||
type: type
|
Loading…
Reference in New Issue
Block a user