Implement k8s count handler (#97955)

* Implement k8s count handler

* Fix endpoint

* Fix type converstions

* Add tests for foldercounts

* Add more tests

* Only use sql-fallback if no values in unistore

* Update gomod

* Fix test

* Update pkg/api/folder_test.go

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>

* Go.mod

---------

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>
This commit is contained in:
Leonor Oliveira
2024-12-16 14:08:29 +01:00
committed by GitHub
co-authored by Bruno Abrantes
parent 1180ea07b7
commit 62c1735a61
5 changed files with 174 additions and 6 deletions
+8
View File
@@ -2,6 +2,8 @@ package v0alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -76,3 +78,9 @@ type ResourceStats struct {
Resource string `json:"resource"`
Count int64 `json:"count"`
}
func UnstructuredToDescendantCounts(obj *unstructured.Unstructured) (*DescendantCounts, error) {
var res DescendantCounts
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &res)
return &res, err
}