feat: pass resources directly
This commit is contained in:
2 files changed
+14
-30
No files matched your search
@@ -77,33 +77,22 @@ func (c *exportConnector) Connect(
|
||||
// TODO: We need some way to filter what we export.
|
||||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
client, lookup, err := c.client.New(ns)
|
||||
client, _, err := c.client.New(ns)
|
||||
if err != nil {
|
||||
responder.Error(apierrors.NewInternalError(fmt.Errorf("failed to create a dynamic client: %w", err)))
|
||||
return
|
||||
}
|
||||
|
||||
dashboardGVR, ok := lookup.Resource(schema.GroupVersionKind{
|
||||
Group: "dashboard.grafana.app",
|
||||
Version: "v2alpha1",
|
||||
Kind: "Dashboard",
|
||||
dashboardIface := client.Resource(schema.GroupVersionResource{
|
||||
Group: "dashboard.grafana.app",
|
||||
Version: "v2alpha1",
|
||||
Resource: "dashboards",
|
||||
})
|
||||
if !ok {
|
||||
responder.Error(apierrors.NewInternalError(fmt.Errorf("no GVR was found for dashboards")))
|
||||
return
|
||||
}
|
||||
dashboardIface := client.Resource(dashboardGVR)
|
||||
|
||||
folderGVR, ok := lookup.Resource(schema.GroupVersionKind{
|
||||
Group: "folder.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
Kind: "Folder",
|
||||
folderIface := client.Resource(schema.GroupVersionResource{
|
||||
Group: "folder.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
Resource: "folders",
|
||||
})
|
||||
if !ok {
|
||||
responder.Error(apierrors.NewInternalError(fmt.Errorf("no GVR was found for folders")))
|
||||
return
|
||||
}
|
||||
folderIface := client.Resource(folderGVR)
|
||||
|
||||
// TODO: handle pagination
|
||||
folders, err := c.fetchFolderInfo(ctx, folderIface)
|
||||
|
||||
@@ -288,20 +288,15 @@ func (b *ProvisioningAPIBuilder) ensureRepositoryFolderExists(ctx context.Contex
|
||||
return nil
|
||||
}
|
||||
|
||||
client, lookup, err := b.client.New(cfg.GetNamespace())
|
||||
client, _, err := b.client.New(cfg.GetNamespace())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
folderResource, ok := lookup.Resource(schema.GroupVersionKind{
|
||||
Group: "folder.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
Kind: "Folder",
|
||||
folderIface := client.Resource(schema.GroupVersionResource{
|
||||
Group: "folder.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
Resource: "folders",
|
||||
})
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to get resource client of the Folder kind")
|
||||
}
|
||||
folderIface := client.Resource(folderResource)
|
||||
|
||||
_, err = folderIface.Get(ctx, cfg.Spec.Folder, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
|
||||
Reference in new issue
Block a user