Provisioning: Use proxy as default access mode in provisioning (#24669)

fixes #24591
fixes #19501
This commit is contained in:
Carl Bergquist 2020-05-14 12:40:00 +02:00 committed by GitHub
parent 2f22781cd8
commit 7610d5717a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -0,0 +1,5 @@
apiVersion: 1
datasources:
- name: $TEST_VAR
type: type