Remote provisioning: consolidate resource operations (#102972)
* Move to new repository * Rename it to dual writer * Rename the function * Rename the methods * Rename to exportResource * Clean up logic in migrate and add TODOs * Add TODOs * Use generic client for unprovisioned * ForEachResource * More consolidation * Refactor more around client * Consolidate constants * ForEachFolder * More use of constants * Add FIXME notes * Use more constant * Remove Dashboard * Pass tree to folder manager * Replicate tree * Reduce export complexity * More refactoring * Use the ForEach for loading users * Limit in-memory folders * Isolate the object * Improve the export function * Move resources to resources package * Move delete operation * Move more logic * More consolidation * More renaming * Fix more issues * Ensure path exists when created a resource * Simply append error * Fix receiver lint issue * Fix cyclomatic complexity * Fix linting * Remove folder path creation
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/resources"
|
||||
)
|
||||
|
||||
// FIXME: do this tests make sense in their current form?
|
||||
func TestIntegrationProvisioning_Client(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
@@ -22,32 +23,25 @@ func TestIntegrationProvisioning_Client(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("dashboard client support", func(t *testing.T) {
|
||||
dash, err := clients.Dashboard()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, dash)
|
||||
|
||||
client, _, err := clients.ForResource(schema.GroupVersionResource{
|
||||
_, _, err := clients.ForResource(schema.GroupVersionResource{
|
||||
Group: "dashboard.grafana.app",
|
||||
Resource: "dashboards",
|
||||
Version: "v1alpha1",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, dash, client, "expecting the default dashboard to be version1")
|
||||
|
||||
// With empty version, we should get the preferred version (v1alpha1)
|
||||
client, _, err = clients.ForResource(schema.GroupVersionResource{
|
||||
_, _, err = clients.ForResource(schema.GroupVersionResource{
|
||||
Group: "dashboard.grafana.app",
|
||||
Resource: "dashboards",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, dash, client, "expecting the default dashboard to be version0")
|
||||
|
||||
client, _, err = clients.ForKind(schema.GroupVersionKind{
|
||||
_, _, err = clients.ForKind(schema.GroupVersionKind{
|
||||
Group: "dashboard.grafana.app",
|
||||
Version: "v1alpha1",
|
||||
Kind: "Dashboard",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, dash, client, "same client when requested by kind")
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user