Authz: add support to use folder api to fetch folder tree (#100038)
* Add FolderStore interface * Authz: add implementation to use folders api and use it inproc with loopback config * Add tracing and add rest.Config for talking with folder api using access tokens * Restructure test to get rid of circular dependencies in tests * use correct group version kind --------- Co-authored-by: gamab <gabriel.mabille@grafana.com>
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -19,7 +18,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
|
||||
grafanaregistry "github.com/grafana/grafana/pkg/apiserver/registry/generic"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/resource"
|
||||
)
|
||||
|
||||
@@ -128,41 +126,3 @@ func isUnchanged(codec runtime.Codec, obj runtime.Object, newObj runtime.Object)
|
||||
|
||||
return bytes.Equal(buf.Bytes(), newBuf.Bytes()), nil
|
||||
}
|
||||
|
||||
func testKeyParser(val string) (*resource.ResourceKey, error) {
|
||||
k, err := grafanaregistry.ParseKey(val)
|
||||
if err != nil {
|
||||
if strings.HasPrefix(val, "pods/") {
|
||||
parts := strings.Split(val, "/")
|
||||
if len(parts) == 2 {
|
||||
err = nil
|
||||
k = &grafanaregistry.Key{
|
||||
Resource: parts[0], // pods
|
||||
Name: parts[1],
|
||||
}
|
||||
} else if len(parts) == 3 {
|
||||
err = nil
|
||||
k = &grafanaregistry.Key{
|
||||
Resource: parts[0], // pods
|
||||
Namespace: parts[1],
|
||||
Name: parts[2],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if k.Group == "" {
|
||||
k.Group = "example.apiserver.k8s.io"
|
||||
}
|
||||
if k.Resource == "" {
|
||||
return nil, apierrors.NewInternalError(fmt.Errorf("missing resource in request"))
|
||||
}
|
||||
return &resource.ResourceKey{
|
||||
Namespace: k.Namespace,
|
||||
Group: k.Group,
|
||||
Resource: k.Resource,
|
||||
Name: k.Name,
|
||||
}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user