Storage: include SQL implementation (#58018)

This commit is contained in:
Ryan McKinley
2022-11-04 17:30:22 -04:00
committed by GitHub
parent 978f1119d7
commit eb1cc80941
9 changed files with 978 additions and 33 deletions
@@ -0,0 +1,27 @@
package sqlstash
import (
"crypto/md5"
"encoding/hex"
"strings"
"github.com/grafana/grafana/pkg/models"
)
func createContentsHash(contents []byte) string {
hash := md5.Sum(contents)
return hex.EncodeToString(hash[:])
}
func getParentFolderPath(kind string, key string) string {
idx := strings.LastIndex(key, "/")
if idx < 0 {
return "" // ?
}
// folder should have a parent up one directory
if kind == models.StandardKindFolder {
idx = strings.LastIndex(key[:idx], "/")
}
return key[:idx]
}