Commit Graph

284 Commits

Author SHA1 Message Date
Mario Trangoni
b7628f2060 pkg/util/{filepath.go,shortid_generator.go}: Fix golint issues
See,
$ gometalinter --vendor --deadline 10m --disable-all --enable=golint  ./...
filepath.go:12:5⚠️ error var WalkSkipDir should have name of the form ErrFoo (golint)
shortid_generator.go:11:5⚠️ var validUidPattern should be validUIDPattern (golint)
shortid_generator.go:19:6⚠️ func IsValidShortUid should be IsValidShortUID (golint)
shortid_generator.go:24:6⚠️ func GenerateShortUid should be GenerateShortUID (golint)
2019-01-28 22:37:44 +01:00
Mario Trangoni
bf90ff87cf pkg/services/dashboards/dashboard_service.go: simplify return
See,
$ gometalinter --vendor --deadline 10m --disable-all --enable=megacheck  ./...
pkg/services/dashboards/dashboard_service.go:167:2⚠️ 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
2019-01-26 14:23:10 +01:00
Torkel Ödegaard
3e873a2500
Merge pull request #14710 from grafana/fixed-gometalinter
Fixed new gotmetalinter warning
2019-01-03 07:23:45 +01:00
Torkel Ödegaard
80e441f48b Fixed new gotmetalinter warning 2019-01-02 19:17:35 +01:00
bergquist
9895b1e6d0 adds orgId to user dto for provisioned dashboards 2018-12-28 10:49:00 +01:00
Marcus Efraimsson
36aec52c08
return actual error if failing to update alert data 2018-11-22 11:19:08 +01:00
Marcus Efraimsson
9e0da02b6a
refactor dashboard alert extractor 2018-11-05 14:25:19 +01:00
Torkel Ödegaard
ec4698fb96 alerting: propagate alert validation issues to the user instead of just 'invalid alert data' message 2018-10-12 23:03:54 -07:00
Marcus Efraimsson
d7688241c6
Merge branch 'master' into readonly_dashboards 2018-04-17 16:27:51 +02:00
Marcus Efraimsson
ff4e38c1d8
provisioned dashboard validation should be made when importing a dashboard
Had to add the validate before save command before validating provisioned dashboard
so that the import would get a proper dashboard id
2018-04-13 17:54:41 +02:00
Marcus Efraimsson
79d8937ce5
provisioned dashboard validation should not be made from provisioning service
Provisioned dashboard validation should not be made when creating/updating a folder or
when provisioning service are trying to provision/create/update dashboard
2018-04-13 17:45:32 +02:00
Marcus Efraimsson
b4863002c9
permission: fix user with org viewer save/move permissions
User with org viewer role should not be able to save/move dashboards
in/to general folder.
2018-04-11 00:23:50 +02:00
bergquist
949484b949 provisioning: simplify db query
the GetProvisionedDashboardQuery wasent used for anything
else than check if a dashboard is provisioned or not. So
we simplified this query to make it more maintainable.
2018-04-10 12:30:37 +02:00
bergquist
77e7887e5e provisioning: check provisiong before saveCmd 2018-04-10 09:35:54 +02:00
bergquist
627df67992 dashboards: reject updates of provisioned dashboards 2018-03-27 15:12:47 +02:00
Julian Kornberger
0a415c50d0 Make golint happier 2018-03-22 22:38:44 +01:00
Marcus Efraimsson
87284d284e dashboard: fix import dashboard with alert rule
Importing a dashboard with alert rule(s) should be possible without receiving invalid
alert data error. This fix reverts the import logic to how it worked before Grafana v5.0,
that is import will allow dashboard with alert rule(s) but no alerts will be created.
After an import the user will need to update the dashboard for the alerts to be created.
Fixes #11227
2018-03-14 14:24:56 +01:00
Marcus Efraimsson
8a8f3bd5bb folders: fix typo 2018-02-21 11:28:11 +01:00
Marcus Efraimsson
3c6bc263dc Merge branch 'master' into 10630_folder_api 2018-02-21 11:25:56 +01:00
Marcus Efraimsson
78283b9c77 folders: extend folder service tests 2018-02-21 11:25:21 +01:00
Marcus Efraimsson
a167e19b37 folders: folder api tests 2018-02-21 11:24:54 +01:00
Marcus Efraimsson
02278f90a7 dashboards: make fake dashboard guardian available to other packages 2018-02-20 18:08:19 +01:00
Marcus Efraimsson
268fb4dc6c folders: new folder service for managing folders 2018-02-20 13:56:22 +01:00
Torkel Ödegaard
21d48df095 fix: plugin dashboard did not get plugin id after import 2018-02-20 11:30:18 +01:00
Marcus Efraimsson
53cd39fde5 Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900)
* dashboards: new command for validating dashboard before update

Removes validation logic from saveDashboard and later on use the new command for validating
dashboard before saving a dashboard. This due to the fact that we need to validate permissions
for overwriting other dashboards by uid and title.

* dashboards: use the new command for validating dashboard before saving

Had to refactor dashboard provisioning a bit to be able to sidetrack the permission validation
in a somewhat reasonable way.
Adds some initial tests of the dashboard repository, but needs to be extended later. At least
now you can mock the dashboard guardian

* dashboards: removes validation logic in the save dashboard api layer

Use the dashboard repository solely for create/update dashboards and let it do all
the validation. One exception regarding quota validation which still is in api layer
since that logic is in a macaron middleware.
Need to move out-commented api tests later.

* dashboards: fix database tests for validate and saving dashboards

* dashboards: rename dashboard repository to dashboard service

Split the old dashboard repository interface in two new interfaces, IDashboardService and
IDashboardProvisioningService. Makes it more explicit when using it from the provisioning package
and there's no possibility of calling an incorrect method for saving a dashboard.

* database: make the InitTestDB function available to use from other packages

* dashboards: rename ValidateDashboardForUpdateCommand and some refactoring

* dashboards: integration tests of dashboard service

* dashboard: fix sqlstore test due to folder exist validation

* dashboards: move dashboard service integration tests to sqlstore package

Had to move it to the sqlstore package due to concurrency problems when running
against mysql and postgres. Using InitTestDB from two packages added conflicts
when clearing and running migrations on the test database

* dashboards: refactor how to find id to be used for save permission check

* dashboards: remove duplicated dashboard tests

* dashboards: cleanup dashboard service integration tests

* dashboards: handle save dashboard errors and return correct http status

* fix: remove log statement

* dashboards: import dashboard should use dashboard service

Had to move alerting commands to models package due to problems with import cycles of packages.

* dashboards: cleanup dashboard api tests and add some tests for post dashboard

* dashboards: rename dashboard service interfaces

* dashboards: rename dashboard guardian interface
2018-02-19 11:12:56 +01:00
bergquist
8954559cbd dashboard: whitelist allowed chars for uid 2018-02-15 09:56:13 +01:00
Leonard Gram
e0abd862e0 provisioning: fixed bug in saving dashboards. 2018-02-08 16:36:53 +01:00
bergquist
67a9e6a71d provisioing: add lookup table provisioned dashboards 2018-01-23 21:52:55 +01:00
Torkel Ödegaard
2465fcbd6b fix: FolderId and IsFolder when saving dashboard 2017-12-13 10:00:54 +01:00
bergquist
099178466d dashboards as cfg: wire up dashboard repo 2017-12-07 15:27:01 +01:00
bergquist
288cc35529 dashboards as cfg: use gocache for caching 2017-12-07 15:27:01 +01:00
bergquist
f5eac2e91d dashboards as cfg: expose dashboard service as interface 2017-12-07 15:27:01 +01:00
bergquist
16f072b320 dashboards as cfg: move saving logic for dashboards into its own service 2017-12-07 15:27:01 +01:00
bergquist
74e12c260f dashboards as cfg: move dashboard saving into its own service 2017-12-07 15:27:01 +01:00