K8s/Folders: Use v1beta1 and app-sdk based spec (#103975)
This commit is contained in:
@@ -18,7 +18,7 @@ func TestFolderConversions(t *testing.T) {
|
||||
input := &unstructured.Unstructured{}
|
||||
err := input.UnmarshalJSON([]byte(`{
|
||||
"kind": "Folder",
|
||||
"apiVersion": "folder.grafana.app/v1",
|
||||
"apiVersion": "folder.grafana.app/v1beta1",
|
||||
"metadata": {
|
||||
"name": "be79sztagf20wd",
|
||||
"namespace": "default",
|
||||
@@ -86,10 +86,10 @@ func TestFolderConversions(t *testing.T) {
|
||||
func TestFolderListConversions(t *testing.T) {
|
||||
input := &unstructured.UnstructuredList{}
|
||||
err := input.UnmarshalJSON([]byte(`{
|
||||
"apiVersion": "folder.grafana.app/v1",
|
||||
"apiVersion": "folder.grafana.app/v1beta1",
|
||||
"items": [
|
||||
{
|
||||
"apiVersion": "folder.grafana.app/v1",
|
||||
"apiVersion": "folder.grafana.app/v1beta1",
|
||||
"kind": "Folder",
|
||||
"metadata": {
|
||||
"annotations": {
|
||||
@@ -113,7 +113,7 @@ func TestFolderListConversions(t *testing.T) {
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "folder.grafana.app/v1",
|
||||
"apiVersion": "folder.grafana.app/v1beta1",
|
||||
"kind": "Folder",
|
||||
"metadata": {
|
||||
"annotations": {
|
||||
@@ -135,7 +135,7 @@ func TestFolderListConversions(t *testing.T) {
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "folder.grafana.app/v1",
|
||||
"apiVersion": "folder.grafana.app/v1beta1",
|
||||
"kind": "Folder",
|
||||
"metadata": {
|
||||
"annotations": {
|
||||
@@ -158,7 +158,7 @@ func TestFolderListConversions(t *testing.T) {
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "folder.grafana.app/v1",
|
||||
"apiVersion": "folder.grafana.app/v1beta1",
|
||||
"kind": "Folder",
|
||||
"metadata": {
|
||||
"annotations": {
|
||||
@@ -180,7 +180,7 @@ func TestFolderListConversions(t *testing.T) {
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "folder.grafana.app/v1",
|
||||
"apiVersion": "folder.grafana.app/v1beta1",
|
||||
"kind": "Folder",
|
||||
"metadata": {
|
||||
"annotations": {
|
||||
@@ -203,7 +203,7 @@ func TestFolderListConversions(t *testing.T) {
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "folder.grafana.app/v1",
|
||||
"apiVersion": "folder.grafana.app/v1beta1",
|
||||
"kind": "Folder",
|
||||
"metadata": {
|
||||
"annotations": {},
|
||||
|
||||
@@ -19,8 +19,8 @@ import (
|
||||
"github.com/grafana/dskit/concurrency"
|
||||
|
||||
dashboardv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1alpha1"
|
||||
folderv1 "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
folderv1 "github.com/grafana/grafana/pkg/apis/folder/v1"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/events"
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
folderv1 "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
folderv1 "github.com/grafana/grafana/pkg/apis/folder/v1"
|
||||
"github.com/grafana/grafana/pkg/events"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/infra/slugify"
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
"k8s.io/apimachinery/pkg/selection"
|
||||
clientrest "k8s.io/client-go/rest"
|
||||
|
||||
foldersv1 "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
foldersv1 "github.com/grafana/grafana/pkg/apis/folder/v1"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/log/logtest"
|
||||
@@ -82,11 +82,11 @@ func TestIntegrationFolderServiceViaUnifiedStorage(t *testing.T) {
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.HandleFunc("DELETE /apis/folder.grafana.app/v1/namespaces/default/folders/deletefolder", func(w http.ResponseWriter, req *http.Request) {
|
||||
mux.HandleFunc("DELETE /apis/folder.grafana.app/v1beta1/namespaces/default/folders/deletefolder", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
})
|
||||
|
||||
mux.HandleFunc("GET /apis/folder.grafana.app/v1/namespaces/default/folders", func(w http.ResponseWriter, req *http.Request) {
|
||||
mux.HandleFunc("GET /apis/folder.grafana.app/v1beta1/namespaces/default/folders", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
l := &foldersv1.FolderList{}
|
||||
l.Kind = "Folder"
|
||||
@@ -94,7 +94,7 @@ func TestIntegrationFolderServiceViaUnifiedStorage(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
mux.HandleFunc("GET /apis/folder.grafana.app/v1/namespaces/default/folders/foo", func(w http.ResponseWriter, req *http.Request) {
|
||||
mux.HandleFunc("GET /apis/folder.grafana.app/v1beta1/namespaces/default/folders/foo", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
namespacer := func(_ int64) string { return "1" }
|
||||
result, err := internalfolders.LegacyFolderToUnstructured(fooFolder, namespacer)
|
||||
@@ -104,7 +104,7 @@ func TestIntegrationFolderServiceViaUnifiedStorage(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
mux.HandleFunc("GET /apis/folder.grafana.app/v1/namespaces/default/folders/updatefolder", func(w http.ResponseWriter, req *http.Request) {
|
||||
mux.HandleFunc("GET /apis/folder.grafana.app/v1beta1/namespaces/default/folders/updatefolder", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
namespacer := func(_ int64) string { return "1" }
|
||||
result, err := internalfolders.LegacyFolderToUnstructured(updateFolder, namespacer)
|
||||
@@ -114,7 +114,7 @@ func TestIntegrationFolderServiceViaUnifiedStorage(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
mux.HandleFunc("PUT /apis/folder.grafana.app/v1/namespaces/default/folders/updatefolder", func(w http.ResponseWriter, req *http.Request) {
|
||||
mux.HandleFunc("PUT /apis/folder.grafana.app/v1beta1/namespaces/default/folders/updatefolder", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
buf, err := io.ReadAll(req.Body)
|
||||
require.NoError(t, err)
|
||||
@@ -133,17 +133,17 @@ func TestIntegrationFolderServiceViaUnifiedStorage(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
mux.HandleFunc("GET /apis/folder.grafana.app/v1/namespaces/default/folders/ady4yobv315a8e", func(w http.ResponseWriter, req *http.Request) {
|
||||
mux.HandleFunc("GET /apis/folder.grafana.app/v1beta1/namespaces/default/folders/ady4yobv315a8e", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
err := json.NewEncoder(w).Encode(unifiedStorageFolder)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
mux.HandleFunc("PUT /apis/folder.grafana.app/v1/namespaces/default/folders/ady4yobv315a8e", func(w http.ResponseWriter, req *http.Request) {
|
||||
mux.HandleFunc("PUT /apis/folder.grafana.app/v1beta1/namespaces/default/folders/ady4yobv315a8e", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
err := json.NewEncoder(w).Encode(unifiedStorageFolder)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
mux.HandleFunc("POST /apis/folder.grafana.app/v1/namespaces/default/folders", func(w http.ResponseWriter, req *http.Request) {
|
||||
mux.HandleFunc("POST /apis/folder.grafana.app/v1beta1/namespaces/default/folders", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
buf, err := io.ReadAll(req.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/resource"
|
||||
|
||||
folderv1 "github.com/grafana/grafana/pkg/apis/folder/v1"
|
||||
folderv1 "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
internalfolders "github.com/grafana/grafana/pkg/registry/apis/folders"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
|
||||
Reference in New Issue
Block a user