K8s/Folders: Remove folder service from client (#94450)

* Support getting full path of UIDs
* Use full path to set parents field
* Update get folder test
* Add folder store test for getting with full path UIDs
* Add test for parsing parent titles
* Test nested folder create payload
This commit is contained in:
Arati R.
2024-10-10 13:22:57 +02:00
committed by GitHub
parent bf9e5ae056
commit 011978e81b
10 changed files with 262 additions and 84 deletions
+26
View File
@@ -34,6 +34,11 @@ const AnnoKeyOriginPath = "grafana.app/originPath"
const AnnoKeyOriginHash = "grafana.app/originHash"
const AnnoKeyOriginTimestamp = "grafana.app/originTimestamp"
// #TODO revisit keeping these folder-specific annotations once we have complete support for mode 1
const AnnoKeyFullPath = "grafana.app/fullPath"
const AnnoKeyFullPathUIDs = "grafana.app/fullPathUIDs"
// ResourceOriginInfo is saved in annotations. This is used to identify where the resource came from
// This object can model the same data as our existing provisioning table or a more general git sync
type ResourceOriginInfo struct {
@@ -101,6 +106,11 @@ type GrafanaMetaAccessor interface {
// NOTE the type must match the existing value, or an error will be thrown
SetStatus(any) error
GetFullPath() string
SetFullPath(path string)
GetFullPathUIDs() string
SetFullPathUIDs(path string)
// Find a title in the object
// This will reflect the object and try to get:
// * spec.title
@@ -598,6 +608,22 @@ func (m *grafanaMetaAccessor) SetStatus(s any) (err error) {
return
}
func (m *grafanaMetaAccessor) GetFullPath() string {
return m.get(AnnoKeyFullPath)
}
func (m *grafanaMetaAccessor) SetFullPath(path string) {
m.SetAnnotation(AnnoKeyFullPath, path)
}
func (m *grafanaMetaAccessor) GetFullPathUIDs() string {
return m.get(AnnoKeyFullPathUIDs)
}
func (m *grafanaMetaAccessor) SetFullPathUIDs(path string) {
m.SetAnnotation(AnnoKeyFullPathUIDs, path)
}
func (m *grafanaMetaAccessor) FindTitle(defaultTitle string) string {
// look for Spec.Title or Spec.Name
spec := m.r.FieldByName("Spec")