K8s/Folders: Warn against using full path in metadata (#94829)

This commit is contained in:
Ryan McKinley 2024-10-17 14:32:39 +03:00 committed by GitHub
parent 4e93b0f467
commit 8b9bb2acf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 5 deletions

View File

@ -106,9 +106,16 @@ type GrafanaMetaAccessor interface {
// NOTE the type must match the existing value, or an error will be thrown
SetStatus(any) error
// Deprecated: this is a temporary hack for folders, it will be removed without notice soon
GetFullPath() string
// Deprecated: this is a temporary hack for folders, it will be removed without notice soon
SetFullPath(path string)
// Deprecated: this is a temporary hack for folders, it will be removed without notice soon
GetFullPathUIDs() string
// Deprecated: this is a temporary hack for folders, it will be removed without notice soon
SetFullPathUIDs(path string)
// Find a title in the object

View File

@ -86,11 +86,19 @@ func UnstructuredToLegacyFolder(item unstructured.Unstructured, orgID int64) *fo
// #TODO add created by field if necessary
// CreatedBy: meta.GetCreatedBy(),
// UpdatedBy: meta.GetCreatedBy(),
URL: getURL(meta, title),
Created: createdTime,
Updated: createdTime,
OrgID: orgID,
Fullpath: meta.GetFullPath(),
URL: getURL(meta, title),
Created: createdTime,
Updated: createdTime,
OrgID: orgID,
// This will need to be restructured so the full path is looked up when saving
// it can't be saved in the resource metadata because then everything must cascade
// nolint:staticcheck
Fullpath: meta.GetFullPath(),
// This will need to be restructured so the full path is looked up when saving
// it can't be saved in the resource metadata because then everything must cascade
// nolint:staticcheck
FullpathUIDs: meta.GetFullPathUIDs(),
}
return f
@ -187,9 +195,11 @@ func convertToK8sResource(v *folder.Folder, namespacer request.NamespaceMapper)
meta.SetFolder(v.ParentUID)
}
if v.Fullpath != "" {
// nolint:staticcheck
meta.SetFullPath(v.Fullpath)
}
if v.FullpathUIDs != "" {
// nolint:staticcheck
meta.SetFullPathUIDs(v.FullpathUIDs)
}
f.UID = gapiutil.CalculateClusterWideUID(f)