Provisioning: Ensure path to file exists in Files endpoints (#103343)
* Create ensure folder path exists * Fix issue with folder names generated in 2 different ways
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
provisioning "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/repository"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/safepath"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -169,11 +170,15 @@ func (r *Parser) Parse(ctx context.Context, info *repository.FileInfo, validate
|
||||
|
||||
// Calculate name+folder from the file path
|
||||
if info.Path != "" {
|
||||
objName, folderName := NamesFromHashedRepoPath(r.repo.Name, info.Path)
|
||||
parsed.Meta.SetFolder(folderName)
|
||||
objName := FileNameFromHashedRepoPath(r.repo.Name, info.Path)
|
||||
if obj.GetName() == "" {
|
||||
obj.SetName(objName) // use the name saved in config
|
||||
}
|
||||
|
||||
dirPath := safepath.Dir(info.Path)
|
||||
if dirPath != "" {
|
||||
parsed.Meta.SetFolder(ParseFolder(dirPath, r.repo.Name).ID)
|
||||
}
|
||||
}
|
||||
obj.SetUID("") // clear identifiers
|
||||
obj.SetResourceVersion("") // clear identifiers
|
||||
|
||||
Reference in New Issue
Block a user