92 Commits

Author SHA1 Message Date
04fb9f534e Dashboards: Only expose LibraryPanels and search on v0 (not v1+v2) (#103335) 2025-04-03 20:24:12 +03:00
b97b1cc730 K8s: Revert change around full path (#103334) 2025-04-03 04:57:26 -05:00
0087d7bd58 Unistore: Skip label for getting full path (#102928) 2025-03-26 15:50:53 -05:00
0ce28c8dd8 K8s: Reduce folder get calls in modes 0-2 (#102831) 2025-03-26 05:44:10 +02:00
2e2b5942c8 K8s/Unified: Consolidate generation logic in apistore client (#102260) 2025-03-21 10:45:25 +02:00
c79c768421 Folders: Add pagination to list (#102334) 2025-03-18 04:56:06 -06:00
4755da0ff5 Folders: Fix user setting in api (#102329) 2025-03-17 18:33:09 -05:00
927f7befd6 Unistore: Create default permissions through Folder APIServer (#101420)
* Unistore: Declare a new storage to set default folder permissions

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Remove the setting of default permissions from folder legacy storage

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Disable setting of folder permissions when Api Server is enabled

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Reverts grafana/grafana#100019

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Add unit test

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* check error on unit test

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Add unit test

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Remove unused fields

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Add unit tests for folder_storage

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Remove duplicated import

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Fix unit test

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2025-03-11 11:33:08 +00:00
6389b801b9 Authz: Pass correct property (#101674) 2025-03-06 10:02:04 +01:00
67221fb328 K8s: Folders: Fix not found errors (#101585) 2025-03-05 00:31:41 +02:00
7c35d741ba Folders: Add validation that folder is not a parent of itself (#101569) 2025-03-04 13:56:21 -06:00
d6b6a9da7b FolderAPI: Use different authorizer for multi-tenant api (#101372)
Use different authorizers depening on if we are running multi-tenant or single-tenant
2025-02-28 10:10:32 +01:00
5e61ec1258 Prevent wrong type conversion (#101349) 2025-02-27 15:17:50 +01:00
bfabe2ce82 Ks8/Folders: Fix status codes returned on GET (#101237)
return the correct status code for folder fetching failures
2025-02-25 11:07:27 +00:00
3e6f40c873 K8s: Move to one feature toggle for folders and dashboards (#100911) 2025-02-19 01:11:26 +02:00
9d5af95565 K8s/OpenAPI: Remove /watch/ from the openapi spec (#99793) 2025-01-30 12:51:55 +03:00
94a844977e Folders/K8s: Fix createdBy and updatedBy fields in response (#99569) 2025-01-28 10:46:07 -06:00
a5c14db051 Folders: Convert between unstructured and legacy (#99504) 2025-01-27 17:37:28 +01:00
7720f0b64e folder: allow standalone folder apiserver (#99508)
* add standalone folders

* add validate

* fix auth
2025-01-27 15:50:06 +01:00
a037c6f344 K8s/Folders: Remove kubernetesFolders flag and full path metadata (#99256)
* remove full path

* remove more

* remove KubernetesFolders tests

* remove feature toggles

* remove feature toggles

* skip permissions test

* skip permissions test

---------

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
2025-01-23 17:25:03 +03:00
d8b6ded101 K8s: use deprecatedInternalID label rather than SQL annotation (#99263) 2025-01-21 12:38:14 +03:00
680e6bc1f8 Authlib: Use types package rather than claims (#99243) 2025-01-21 12:06:55 +03:00
b4ec11e150 Unistore: Ensure deprecated Folder ID gets stored on all modes (#99043)
* Unistore: Ensure deprecated Folder ID gets stored on all modes

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2025-01-16 15:01:00 -03:00
cbb688e910 Zanzana: Remove usage from legacy access control (#98883)
* Zanzana: Remove usage from legacy access control

* remove unused

* remove zanzana client from services where it's not used

* remove unused metrics

* fix linter
2025-01-14 10:26:15 +01:00
766d645d82 Filewalkwithme/unistore refactor folder service to hit folder apiserver (#98409)
Refactor folder service to use Unified Storage

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
2025-01-13 18:15:35 -03:00
937e8dea2d Folder/parent subresource (#98392)
* Expose get folder parents endpoint

* Add tests
2025-01-03 10:43:56 +01:00
d2639f6080 Ensure all internal Services are using FolderService and not FolderStore (#98370)
* Ensure all internal Services are using FolderService and not FolderStore

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-12-30 13:48:35 -03:00
fec5c0ec19 Make sure annotations are kept when updating a folder (#98321)
* Make sure annotations are kept when updating a folder

* Remove pointer

* Mock get on update tests
2024-12-27 13:51:10 +01:00
58c44f6c66 Trim folder title (#98275) 2024-12-19 17:56:14 +01:00
f5d44ff51d Folders move (#98100) 2024-12-19 09:59:14 +01:00
2e08092a34 UniStore: Get Folder Handler return Root Folder (general) (#98127)
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-12-18 22:31:55 -03:00
eb38a63559 K8s/Folder: Show parent folder information (#97938) 2024-12-17 16:19:40 +02:00
62c1735a61 Implement k8s count handler (#97955)
* Implement k8s count handler

* Fix endpoint

* Fix type converstions

* Add tests for foldercounts

* Add more tests

* Only use sql-fallback if no values in unistore

* Update gomod

* Fix test

* Update pkg/api/folder_test.go

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>

* Go.mod

---------

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>
2024-12-16 14:08:29 +01:00
f710573b37 Use searcher GetStats to count for folders and dashboards under a folder to be deleted (#97708)
* get stats from index

* fix logging

* fix logging

* actually counting

* Use searcher to check for resources referencing a folder

* Add tests when deleting a folder

* Lint

* merge/fix test

* will delegate to SQL

* get stats from index

* fix logging

* actually counting

* merge/fix test

* will delegate to SQL

* Uncomment test

* Add tests for checking stats before deleting a folder

* Change base branch to main

* Lint

* [REVIEW] remove logs

* Check for type assertion success

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2024-12-12 11:53:01 +01:00
ea17b79c09 Search: Return counts for values within an folder/repository (#97534) 2024-12-10 20:37:37 +02:00
5f39d2eeb0 K8s: Make GetAPIRoutes an optional interface (#97531) 2024-12-07 03:08:18 +03:00
7fd8877439 Unistore: Update Folders Endpoint (#97317)
* Add route for update folders via apiserver

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-12-03 15:33:01 -03:00
20a27da636 FeatureFlags: Add helper to check against a set of flags (#97240) 2024-12-02 21:41:41 +02:00
2a74778776 Support delete endpoint for folders (#96573)
* Support delete endpoint for folders

* Include authorizer

* Add test for delete verb

* Add delete command to delete options

* Pass query string to context to admission

* Dont support nested folder deletion for now

* Skip test if feature flag is present

* Add test case

* Remove comment

* Only rely on the storage type config to run alerting tests

* Dont change legacy subpath

* Remove unised function

* Add test case when an editor can delete alert rules

* Lint
2024-11-22 16:51:53 +01:00
bbae396db4 Unistore: Add GetFolders endpoint backed by UnifiedStorage (#96399)
* Unistore: Add GetFolders endpoint backed by UnifiedStorage

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
Co-authored-by: Arati R. <33031346+suntala@users.noreply.github.com>
2024-11-22 10:38:00 -03:00
cc6d057a18 Provisioning: Rename k8s origin metadata to repo (#96524) 2024-11-15 17:26:14 +03:00
2e62f75166 K8s/Folders: Allow recursive creation of DTO (#96439)
* Fix toDTO
* Remove conversion function for folder dto
* Convert toDTO to a standalone function

---------

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
2024-11-15 15:21:57 +01:00
4c0dde6f2f Plugin Extensions: Streamline log messages (#95943)
* streamline log messages

* cleanup

* fix tests

* only log errors to the console

* more cleanup again

* cleanup

* Update public/app/features/plugins/extensions/errors.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* pr feedback

* remove white space

* Update public/app/features/plugins/extensions/registry/ExposedComponentsRegistry.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* revert touched file

* revert touched file

* fix tests

---------

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
2024-11-12 08:55:04 +01:00
b5e636b126 UniStore: Legacy List Folders must return all folders (#96062)
* UniStore: Legacy List Folders must return all folders

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-11-08 12:38:34 -03:00
b1157dbd7a Validate if we are creating a folder more than 5 levels deep (#95579)
* Add getter to FolderAPIBuilder so that we can access it in admission

* Remove deprecated return

* Fix test

* Update pkg/registry/apis/folders/register_test.go

Co-authored-by: maicon <maiconscosta@gmail.com>

* Fix maxNested folder test

* Remove log

---------

Co-authored-by: maicon <maiconscosta@gmail.com>
2024-10-31 12:19:53 +01:00
55afbdc6be [Folder] Add general UID validation (#95549)
* Add general UID validation

* [REVIEW] group all folder validation rules into struct

* Fix test
2024-10-29 16:09:28 +01:00
5533b30135 K8s: Add validation support to builder (#95502) 2024-10-28 11:40:25 -04:00
5cf86c981f Test Folder's GetAuthorizer (#95266)
* WIP: setup to test folders GetAuthorizer

* Setup test

* Extract authorizer fn for tests

* Setup internal test fn

* Better define test inputs

* Add FolderAPI builder to the test

* First test passing

* Test getAuthorize for the create method

* Change authorizerFunc's signature

* [REVIEW] code readability

* Name error

* [REVIEW] add one more test case. Lint

* Remove empty line
2024-10-28 12:00:19 +02:00
a03652494c Dual Writer simplification (#93852)
* All objects should have an UID

* Now with a different error message

* Simplify create on DW 2: use the same object to write to both storages

* Run only one test

* Add check for status code

* Add name if it's not present in mode2

* Populate UID in legacy

* Remove logs and commented code

* Change dualwriter1

* Remove commented code

* Fix list test

* remove get on update from dualwriter 2

* Get object before updating. Better var renaming

* Finish rebasing

* Comment test

* Uncomment tests

* Update legacy first. Add preconditions

* Remove preconditions

* Fix update test

* copy RV from unified to legacy objects

* revert changes to playlist xorm store

* Improve logging. Add go routines for mode3

* Add tests for async funcs in mode3

* Lint

* Lint

* Lint. Start to fix tests

* Fix watcher tests

* Fix store tests

* Fiinish fixing watcher tests

* Fix server tests

* add name check

* Update pkg/apiserver/rest/dualwriter_mode1.go

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>

* All objects should have an UID

* Now with a different error message

* Simplify create on DW 2: use the same object to write to both storages

* Run only one test

* Add check for status code

* Add name if it's not present in mode2

* Populate UID in legacy

* Remove logs and commented code

* Change dualwriter1

* Remove commented code

* Fix list test

* remove get on update from dualwriter 2

* Get object before updating. Better var renaming

* Finish rebasing

* Comment test

* Uncomment tests

* Fix update test

* revert changes to playlist xorm store

* Improve logging. Add go routines for mode3

* Lint

* Fix watcher tests

* Fiinish fixing watcher tests

* Add mode 5 with etcd test case. Add early check to fail on populated RV in payload

* we can't set RV to the found object when updating

* Lint

* Don't fail on update playlists

* Name should not be different when updating and it should be not empty on creating

* Fix tests

* Update pkg/apiserver/rest/dualwriter_mode2.go

Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>

* Lint

* Fix mode 5 tests

* Lint

* Add generateName condition on every mode. Fix tests

* Lint

* Add condition on where name or generate name have to be set

* Fix test

* Lint

* Fix folders test

* We dont need to send name for mode1

* Fail if UID is not present

* Remove change from not running test

* Remove unused line

* Lint

* Update pkg/storage/unified/apistore/store.go

Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>

* Improve error message

* Fix broken watcher test

* Fail on name mismatch on update

* Remove log

* Make sure UIDs match on create in both stores

* Lint

* Write first to unified storage

* Remove uid setting

* Remove RV only in mode2

* Fix test. Remove log line

* test

* No need to asser on RV in mode3

* Remove RV check due to race condition

* Update dualwriter.go

Co-authored-by: Georges Chaudy <chaudyg@gmail.com>

* Update pkg/storage/unified/client.go

* remove unused parameter

* log an error for object is missing UID instead of returning an error

* remove obj.SetResourceVersion("")

* log an error for object is missing UID instead of returning an error

* FInalise merge

* Move RV check to where it was

* Remove name check

* Remove server check for backwards compatibility

* Remove unused fn

* Move test checks for another PR

* Dont commit go work sum changes

* Only log error if RV is present for now.

---------

Co-authored-by: Todd Treece <todd.treece@grafana.com>
Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>
Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
Co-authored-by: Georges Chaudy <chaudyg@gmail.com>
2024-10-23 10:29:41 +02:00
f3a93a0303 K8s/Folders: Enhance k8s folder update (#95033)
* Put folder update behind feature toggle
* Set more fields when doing k8s update
* Check update in folder tests
* Uncomment remaining k8s handler methods
2024-10-21 19:08:03 +02:00