Commit Graph

58 Commits

Author SHA1 Message Date
bergquist
47d3884377 provisioning: follow symlinked folders
fixes #11958
2018-05-31 09:38:09 +02:00
bergquist
d5aeae3a90 test: fixes broken test on windows 2018-05-31 08:27:29 +02:00
bergquist
c7acbcdaf5 provisioning: enable relative path's
this commit enable relatives path for provisioning dashboards.
this enables easier dev setups
2018-05-30 08:46:44 +02:00
bergquist
c40b0ea1df test: moves test files to testdata folder 2018-05-18 23:23:13 +02:00
Torkel Ödegaard
053c2039bb refactor: provisioning service refactoring 2018-05-02 19:56:15 +02:00
Karsten Weiss
b7adf28501 Remove redundancy in variable declarations (golint)
This commit fixes the following golint warnings:
pkg/api/avatar/avatar.go:229:12: should omit type *http.Client from declaration of var client; it will be inferred from the right-hand side
pkg/login/brute_force_login_protection.go:13:26: should omit type time.Duration from declaration of var loginAttemptsWindow; it will be inferred from the right-hand side
pkg/metrics/graphitebridge/graphite.go:58:26: should omit type []string from declaration of var metricCategoryPrefix; it will be inferred from the right-hand side
pkg/metrics/graphitebridge/graphite.go:69:22: should omit type []string from declaration of var trimMetricPrefix; it will be inferred from the right-hand side
pkg/models/alert.go:37:36: should omit type error from declaration of var ErrCannotChangeStateOnPausedAlert; it will be inferred from the right-hand side
pkg/models/alert.go:38:36: should omit type error from declaration of var ErrRequiresNewState; it will be inferred from the right-hand side
pkg/models/datasource.go:61:28: should omit type map[string]bool from declaration of var knownDatasourcePlugins; it will be inferred from the right-hand side
pkg/plugins/update_checker.go:16:13: should omit type http.Client from declaration of var httpClient; it will be inferred from the right-hand side
pkg/services/alerting/engine.go:103:24: should omit type time.Duration from declaration of var unfinishedWorkTimeout; it will be inferred from the right-hand side
pkg/services/alerting/engine.go:105:19: should omit type time.Duration from declaration of var alertTimeout; it will be inferred from the right-hand side
pkg/services/alerting/engine.go:106:19: should omit type int from declaration of var alertMaxAttempts; it will be inferred from the right-hand side
pkg/services/alerting/notifier.go:143:23: should omit type map[string]*NotifierPlugin from declaration of var notifierFactories; it will be inferred from the right-hand side
pkg/services/alerting/rule.go:136:24: should omit type map[string]ConditionFactory from declaration of var conditionFactories; it will be inferred from the right-hand side
pkg/services/alerting/conditions/evaluator.go:12:15: should omit type []string from declaration of var defaultTypes; it will be inferred from the right-hand side
pkg/services/alerting/conditions/evaluator.go:13:15: should omit type []string from declaration of var rangedTypes; it will be inferred from the right-hand side
pkg/services/alerting/notifiers/opsgenie.go:44:19: should omit type string from declaration of var opsgenieAlertURL; it will be inferred from the right-hand side
pkg/services/alerting/notifiers/pagerduty.go:43:23: should omit type string from declaration of var pagerdutyEventApiUrl; it will be inferred from the right-hand side
pkg/services/alerting/notifiers/telegram.go:21:17: should omit type string from declaration of var telegramApiUrl; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/config_reader_test.go:11:24: should omit type string from declaration of var simpleDashboardConfig; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/config_reader_test.go:12:24: should omit type string from declaration of var oldVersion; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/config_reader_test.go:13:24: should omit type string from declaration of var brokenConfigs; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/file_reader.go:22:30: should omit type time.Duration from declaration of var checkDiskForChangesInterval; it will be inferred from the right-hand side
pkg/services/provisioning/dashboards/file_reader.go:24:23: should omit type error from declaration of var ErrFolderNameMissing; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:15:34: should omit type string from declaration of var twoDatasourcesConfig; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:16:34: should omit type string from declaration of var twoDatasourcesConfigPurgeOthers; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:17:34: should omit type string from declaration of var doubleDatasourcesConfig; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:18:34: should omit type string from declaration of var allProperties; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:19:34: should omit type string from declaration of var versionZero; it will be inferred from the right-hand side
pkg/services/provisioning/datasources/config_reader_test.go:20:34: should omit type string from declaration of var brokenYaml; it will be inferred from the right-hand side
pkg/services/sqlstore/stats.go:16:25: should omit type time.Duration from declaration of var activeUserTimeLimit; it will be inferred from the right-hand side
pkg/services/sqlstore/migrator/mysql_dialect.go:69:14: should omit type bool from declaration of var hasLen1; it will be inferred from the right-hand side
pkg/services/sqlstore/migrator/mysql_dialect.go:70:14: should omit type bool from declaration of var hasLen2; it will be inferred from the right-hand side
pkg/services/sqlstore/migrator/postgres_dialect.go:95:14: should omit type bool from declaration of var hasLen1; it will be inferred from the right-hand side
pkg/services/sqlstore/migrator/postgres_dialect.go:96:14: should omit type bool from declaration of var hasLen2; it will be inferred from the right-hand side
pkg/setting/setting.go:42:15: should omit type string from declaration of var Env; it will be inferred from the right-hand side
pkg/setting/setting.go:161:18: should omit type bool from declaration of var LdapAllowSignup; it will be inferred from the right-hand side
pkg/setting/setting.go:473:30: should omit type bool from declaration of var skipStaticRootValidation; it will be inferred from the right-hand side
pkg/tsdb/interval.go:14:21: should omit type time.Duration from declaration of var defaultMinInterval; it will be inferred from the right-hand side
pkg/tsdb/interval.go:15:21: should omit type time.Duration from declaration of var year; it will be inferred from the right-hand side
pkg/tsdb/interval.go:16:21: should omit type time.Duration from declaration of var day; it will be inferred from the right-hand side
pkg/tsdb/cloudwatch/credentials.go:26:24: should omit type map[string]cache from declaration of var awsCredentialCache; it will be inferred from the right-hand side
pkg/tsdb/influxdb/query.go:15:27: should omit type *regexp.Regexp from declaration of var regexpOperatorPattern; it will be inferred from the right-hand side
pkg/tsdb/influxdb/query.go:16:27: should omit type *regexp.Regexp from declaration of var regexpMeasurementPattern; it will be inferred from the right-hand side
pkg/tsdb/mssql/mssql_test.go:25:14: should omit type string from declaration of var serverIP; it will be inferred from the right-hand side
2018-04-27 22:14:36 +02:00
Mario Trangoni
6eb00000fe pkg/services: fix ineffassign issues 2018-04-23 19:28:54 +02:00
Marcus Efraimsson
8a5cb088d3
Merge branch 'master' into readonly_dashboards 2018-04-17 10:50:04 +02:00
Mario Trangoni
91fb2e07ce pkg: fix codespell issues 2018-04-13 20:31:29 +02:00
Marcus Efraimsson
6bbeb723ca Merge branch 'master' into readonly_dashboards 2018-04-05 20:30:27 +02:00
bergquist
d6faa3d06f provisioning: improve UX when saving provisioned dashboards 2018-03-26 15:08:46 +02:00
bergquist
b61bc72e2a provisioning: removes id from dashboard.json
if dashboard json files contains `id` we
will just remove it form the dashboard model
before importing it into the database.

closes #11138
2018-03-26 13:17:39 +02:00
Torkel Ödegaard
2f6e77af1e Merge branch 'master' into docs_v5.0 2018-02-21 10:47:14 +01:00
bergquist
4dc6074e79 provisioning: dont ignore sample yaml files
closes #10963
2018-02-20 08:40:37 +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
Carl Bergquist
243b987758
Merge pull request #10910 from bergquist/provisioning_disable_deleting_dashboards
provisioning: adds setting to disable dashboard deletes
2018-02-15 08:28:10 +01:00
bergquist
ad42883fc7 provisioning: adds setting to disable dashboard deletes 2018-02-14 17:30:08 +01:00
Leonard Gram
fa1b92a12b
provisioning: uses unix epoch timestamps. (#10907)
* provisioning: uses unix epoch timestamps.
2018-02-14 15:28:30 +01:00
bergquist
dba087463a provisioing: always skip sample.yaml files 2018-02-14 11:33:58 +01:00
bergquist
84de76ff0a provisioning: code formating 2018-02-14 10:30:08 +01:00
bergquist
44baaeed8f provisioning: adds logs about deprecated config format 2018-02-14 10:30:08 +01:00
bergquist
b010e4df93 provisioning: support camelcase for dashboards configs 2018-02-14 10:30:08 +01:00
Leonard Gram
ba0285a3ec
provisioning: Warns the user when uid or title is re-used. (#10892)
* provisioning: Warns the user when uid or title is re-used.

Closes #10880
2018-02-13 15:47:02 +01:00
bergquist
f01890c3ff provisioning: better variable naming 2018-02-12 08:22:34 +01:00
bergquist
84fea7c148 provisioning: dont return error unless you want to cancel all operations 2018-02-09 15:43:58 +01:00
bergquist
5a76624003 provisioning: createWalkFn doesnt have to be attached to the filereader anymore 2018-02-09 15:33:54 +01:00
bergquist
59cd2d5102 provisioning: avoid caching and use updated field from db 2018-02-09 15:23:38 +01:00
bergquist
31f3fdcba3 provisioning: delete dashboards before insert/update 2018-02-09 12:17:58 +01:00
Leonard Gram
b549d29319 Merge branch 'master' into provisioning 2018-02-08 11:01:09 +01:00
bergquist
76dc7932a4 docs: describe uid for dashboard provisioning 2018-02-07 11:04:48 +01:00
bergquist
d62d5c7418 provisioning: delete dashboards from db when file is missing 2018-01-25 15:25:07 +01:00
Leonard Gram
1c034b7a73 fixes minor typo 2018-01-25 09:30:37 +01:00
bergquist
c3a768b3ed provsioning: dont stop grafana due to missing 2018-01-25 09:30:37 +01:00
bergquist
57e7048b8f provisioning: enables title changes for dashboards 2018-01-24 19:16:57 +01:00
bergquist
77a4ccb822 dashboards: save provisioning meta data 2018-01-23 21:54:30 +01:00
bergquist
67a9e6a71d provisioing: add lookup table provisioned dashboards 2018-01-23 21:52:55 +01:00
bergquist
7858965117 codestyle: extract code into methods 2018-01-18 12:04:12 +01:00
Carl Bergquist
d6667c4fa0
Merge pull request #10548 from StevenTobin/follow_symlinks
Make file_reader follow symlinks
2018-01-18 11:29:34 +01:00
stobin
f1813ae3a3 Make file_reader follow symlinks 2018-01-17 14:51:17 +00:00
bergquist
34d7f8a44f dashboards as cfg: property path replaces folder 2018-01-17 15:48:24 +01:00
Leonard Gram
183507964c Clearer naming for dashboard provisioning config.
Renames folder (in options) to path to make it
different from the grafana folder wherein the
dashboard will be created.
2018-01-16 17:40:14 +01:00
bergquist
1a6c2ea8d8 dashboards as cfg: logs error when trying to import dashboard with id
dashboard json cannot contain fixed id when importing from
disk. We used to override this but it didnt caught all problems
so now we block dashboards from beeing imported instead.

closes #10504
2018-01-15 12:26:43 +01:00
bergquist
f5e00e133b dashboards as cfg: moves dashcash into its own file 2017-12-28 13:37:02 +01:00
bergquist
237d469ed4 dashboards as cfg: create dashboard folders if missing
closes #10259
2017-12-28 13:33:11 +01:00
bergquist
f4078e1935 tests: for skipping with hidden folders 2017-12-27 15:04:49 +01:00
Torkel Ödegaard
c395237710 Merge branch Grafana v5 'develop' branch 2017-12-15 12:06:09 +01:00
Simon Aquino
5dbbf1826c Avoid ID validation before provisioning dashboards
Attempting to provision grafana using a previously exported
JSON dashboard with the ID field already set, might result in an error.
In fact, Grafana might believe that a dashboard with that
given ID already exists in the database, throwing an error if it doesn't.
(see pkg/services/sqlstore/dashboard.go#L32)

The dashboard provisioner should set the dashboard id to zero in order to
avoid this behaviour inducing the dashboard to be written to the DB
without ID validation.
2017-12-14 02:07:50 +01:00
bergquist
dd3dd407ad removes unused property 2017-12-13 13:12:50 +01:00
Torkel Ödegaard
2465fcbd6b fix: FolderId and IsFolder when saving dashboard 2017-12-13 10:00:54 +01:00
bergquist
0c5ef1453d fixes broken test 2017-12-08 11:33:15 +01:00