K8s: Move ResourceInfo from common to utils (#92924)

This commit is contained in:
Ryan McKinley
2024-09-04 14:53:14 +03:00
committed by GitHub
parent 668d87b19f
commit cb484f9883
22 changed files with 75 additions and 99 deletions

View File

@ -5,7 +5,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
) )
@ -15,7 +14,7 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var DataPlaneServiceResourceInfo = common.NewResourceInfo(GROUP, VERSION, var DataPlaneServiceResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"dataplaneservices", "dataplaneservice", "DataPlaneService", "dataplaneservices", "dataplaneservice", "DataPlaneService",
func() runtime.Object { return &DataPlaneService{} }, func() runtime.Object { return &DataPlaneService{} },
func() runtime.Object { return &DataPlaneServiceList{} }, func() runtime.Object { return &DataPlaneServiceList{} },

View File

@ -1,7 +1,6 @@
package v0alpha1 package utils
import ( import (
"github.com/grafana/grafana/pkg/apimachinery/utils"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -9,7 +8,6 @@ import (
) )
// ResourceInfo helps define a k8s resource // ResourceInfo helps define a k8s resource
// +k8s:openapi-gen=false
type ResourceInfo struct { type ResourceInfo struct {
group string group string
version string version string
@ -19,11 +17,11 @@ type ResourceInfo struct {
kind string kind string
newObj func() runtime.Object newObj func() runtime.Object
newList func() runtime.Object newList func() runtime.Object
columns utils.TableColumns columns TableColumns
} }
func NewResourceInfo(group, version, resourceName, singularName, kind string, func NewResourceInfo(group, version, resourceName, singularName, kind string,
newObj func() runtime.Object, newList func() runtime.Object, columns utils.TableColumns) ResourceInfo { newObj func() runtime.Object, newList func() runtime.Object, columns TableColumns) ResourceInfo {
shortName := "" // an optional alias helpful in kubectl eg ("sa" for serviceaccounts) shortName := "" // an optional alias helpful in kubectl eg ("sa" for serviceaccounts)
return ResourceInfo{group, version, resourceName, singularName, shortName, kind, newObj, newList, columns} return ResourceInfo{group, version, resourceName, singularName, shortName, kind, newObj, newList, columns}
} }
@ -116,8 +114,8 @@ func (info *ResourceInfo) NewListFunc() runtime.Object {
return info.newList() return info.newList()
} }
func (info *ResourceInfo) TableConverter() utils.TableConvertor { func (info *ResourceInfo) TableConverter() TableConvertor {
return utils.NewTableConverter(info.GroupResource(), info.columns) return NewTableConverter(info.GroupResource(), info.columns)
} }
func (info *ResourceInfo) NewNotFound(name string) *errors.StatusError { func (info *ResourceInfo) NewNotFound(name string) *errors.StatusError {

View File

@ -9,7 +9,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
scope "github.com/grafana/grafana/pkg/apis/scope/v0alpha1" scope "github.com/grafana/grafana/pkg/apis/scope/v0alpha1"
) )
@ -25,7 +24,7 @@ const (
) )
var ( var (
TimeIntervalResourceInfo = common.NewResourceInfo(GROUP, VERSION, TimeIntervalResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"timeintervals", "timeinterval", "TimeInterval", "timeintervals", "timeinterval", "TimeInterval",
func() runtime.Object { return &TimeInterval{} }, func() runtime.Object { return &TimeInterval{} },
func() runtime.Object { return &TimeIntervalList{} }, func() runtime.Object { return &TimeIntervalList{} },
@ -46,7 +45,7 @@ var (
}, },
}, },
) )
ReceiverResourceInfo = common.NewResourceInfo(GROUP, VERSION, ReceiverResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"receivers", "receiver", "Receiver", "receivers", "receiver", "Receiver",
func() runtime.Object { return &Receiver{} }, func() runtime.Object { return &Receiver{} },
func() runtime.Object { return &ReceiverList{} }, func() runtime.Object { return &ReceiverList{} },

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"time" "time"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -17,7 +16,7 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var DashboardResourceInfo = common.NewResourceInfo(GROUP, VERSION, var DashboardResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"dashboards", "dashboard", "Dashboard", "dashboards", "dashboard", "Dashboard",
func() runtime.Object { return &Dashboard{} }, func() runtime.Object { return &Dashboard{} },
func() runtime.Object { return &DashboardList{} }, func() runtime.Object { return &DashboardList{} },
@ -43,7 +42,7 @@ var DashboardResourceInfo = common.NewResourceInfo(GROUP, VERSION,
}, },
) )
var LibraryPanelResourceInfo = common.NewResourceInfo(GROUP, VERSION, var LibraryPanelResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"librarypanels", "librarypanel", "LibraryPanel", "librarypanels", "librarypanel", "LibraryPanel",
func() runtime.Object { return &LibraryPanel{} }, func() runtime.Object { return &LibraryPanel{} },
func() runtime.Object { return &LibraryPanelList{} }, func() runtime.Object { return &LibraryPanelList{} },

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"time" "time"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -17,7 +16,7 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var DashboardSnapshotResourceInfo = common.NewResourceInfo(GROUP, VERSION, var DashboardSnapshotResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"dashboardsnapshots", "dashboardsnapshot", "DashboardSnapshot", "dashboardsnapshots", "dashboardsnapshot", "DashboardSnapshot",
func() runtime.Object { return &DashboardSnapshot{} }, func() runtime.Object { return &DashboardSnapshot{} },
func() runtime.Object { return &DashboardSnapshotList{} }, func() runtime.Object { return &DashboardSnapshotList{} },

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"time" "time"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -15,7 +14,7 @@ const (
VERSION = "v0alpha1" VERSION = "v0alpha1"
) )
var GenericConnectionResourceInfo = common.NewResourceInfo(GROUP, VERSION, var GenericConnectionResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"connections", "connection", "DataSourceConnection", "connections", "connection", "DataSourceConnection",
func() runtime.Object { return &DataSourceConnection{} }, func() runtime.Object { return &DataSourceConnection{} },
func() runtime.Object { return &DataSourceConnectionList{} }, func() runtime.Object { return &DataSourceConnectionList{} },

View File

@ -3,7 +3,6 @@ package v0alpha1
import ( import (
"fmt" "fmt"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
@ -17,7 +16,7 @@ const (
) )
// FeatureResourceInfo represents each feature that may have a toggle // FeatureResourceInfo represents each feature that may have a toggle
var FeatureResourceInfo = common.NewResourceInfo(GROUP, VERSION, var FeatureResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"features", "feature", "Feature", "features", "feature", "Feature",
func() runtime.Object { return &Feature{} }, func() runtime.Object { return &Feature{} },
func() runtime.Object { return &FeatureList{} }, func() runtime.Object { return &FeatureList{} },
@ -42,7 +41,7 @@ var FeatureResourceInfo = common.NewResourceInfo(GROUP, VERSION,
) )
// TogglesResourceInfo represents the actual configuration // TogglesResourceInfo represents the actual configuration
var TogglesResourceInfo = common.NewResourceInfo(GROUP, VERSION, var TogglesResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"featuretoggles", "featuretoggle", "FeatureToggles", "featuretoggles", "featuretoggle", "FeatureToggles",
func() runtime.Object { return &FeatureToggles{} }, func() runtime.Object { return &FeatureToggles{} },
func() runtime.Object { return &FeatureTogglesList{} }, func() runtime.Object { return &FeatureTogglesList{} },

View File

@ -3,7 +3,6 @@ package v0alpha1
import ( import (
"fmt" "fmt"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -17,7 +16,7 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var FolderResourceInfo = common.NewResourceInfo(GROUP, VERSION, var FolderResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
RESOURCE, "folder", "Folder", RESOURCE, "folder", "Folder",
func() runtime.Object { return &Folder{} }, func() runtime.Object { return &Folder{} },
func() runtime.Object { return &FolderList{} }, func() runtime.Object { return &FolderList{} },

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"time" "time"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -17,7 +16,7 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var UserResourceInfo = common.NewResourceInfo(GROUP, VERSION, var UserResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"users", "user", "User", "users", "user", "User",
func() runtime.Object { return &User{} }, func() runtime.Object { return &User{} },
func() runtime.Object { return &UserList{} }, func() runtime.Object { return &UserList{} },
@ -43,7 +42,7 @@ var UserResourceInfo = common.NewResourceInfo(GROUP, VERSION,
}, },
) )
var TeamResourceInfo = common.NewResourceInfo(GROUP, VERSION, var TeamResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"teams", "team", "Team", "teams", "team", "Team",
func() runtime.Object { return &Team{} }, func() runtime.Object { return &Team{} },
func() runtime.Object { return &TeamList{} }, func() runtime.Object { return &TeamList{} },
@ -69,7 +68,7 @@ var TeamResourceInfo = common.NewResourceInfo(GROUP, VERSION,
}, },
) )
var ServiceAccountResourceInfo = common.NewResourceInfo(GROUP, VERSION, var ServiceAccountResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"serviceaccounts", "serviceaccount", "ServiceAccount", "serviceaccounts", "serviceaccount", "ServiceAccount",
func() runtime.Object { return &ServiceAccount{} }, func() runtime.Object { return &ServiceAccount{} },
func() runtime.Object { return &ServiceAccountList{} }, func() runtime.Object { return &ServiceAccountList{} },
@ -95,7 +94,7 @@ var ServiceAccountResourceInfo = common.NewResourceInfo(GROUP, VERSION,
}, },
) )
var SSOSettingResourceInfo = common.NewResourceInfo( var SSOSettingResourceInfo = utils.NewResourceInfo(
GROUP, VERSION, "ssosettings", "ssosetting", "SSOSetting", GROUP, VERSION, "ssosettings", "ssosetting", "SSOSetting",
func() runtime.Object { return &SSOSetting{} }, func() runtime.Object { return &SSOSetting{} },
func() runtime.Object { return &SSOSettingList{} }, func() runtime.Object { return &SSOSettingList{} },
@ -121,7 +120,7 @@ var SSOSettingResourceInfo = common.NewResourceInfo(
}, },
) )
var TeamBindingResourceInfo = common.NewResourceInfo( var TeamBindingResourceInfo = utils.NewResourceInfo(
GROUP, VERSION, "teambindings", "teambinding", "TeamBinding", GROUP, VERSION, "teambindings", "teambinding", "TeamBinding",
func() runtime.Object { return &TeamBinding{} }, func() runtime.Object { return &TeamBinding{} },
func() runtime.Object { return &TeamBindingList{} }, func() runtime.Object { return &TeamBindingList{} },

View File

@ -5,7 +5,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
) )
@ -15,7 +14,7 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var QueryTemplateResourceInfo = common.NewResourceInfo(GROUP, VERSION, var QueryTemplateResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"querytemplates", "querytemplate", "QueryTemplate", "querytemplates", "querytemplate", "QueryTemplate",
func() runtime.Object { return &QueryTemplate{} }, func() runtime.Object { return &QueryTemplate{} },
func() runtime.Object { return &QueryTemplateList{} }, func() runtime.Object { return &QueryTemplateList{} },

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"time" "time"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -19,7 +18,7 @@ const (
GROUPRESOURCE = GROUP + "/" + RESOURCE GROUPRESOURCE = GROUP + "/" + RESOURCE
) )
var PlaylistResourceInfo = common.NewResourceInfo(GROUP, VERSION, var PlaylistResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
RESOURCE, "playlist", "Playlist", RESOURCE, "playlist", "Playlist",
func() runtime.Object { return &Playlist{} }, func() runtime.Object { return &Playlist{} },
func() runtime.Object { return &PlaylistList{} }, func() runtime.Object { return &PlaylistList{} },

View File

@ -4,7 +4,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
) )
@ -14,14 +13,14 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var DataSourceApiServerResourceInfo = common.NewResourceInfo(GROUP, VERSION, var DataSourceApiServerResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"datasourceapiservers", "datasourceapiserver", "DataSourceApiServer", "datasourceapiservers", "datasourceapiserver", "DataSourceApiServer",
func() runtime.Object { return &DataSourceApiServer{} }, func() runtime.Object { return &DataSourceApiServer{} },
func() runtime.Object { return &DataSourceApiServerList{} }, func() runtime.Object { return &DataSourceApiServerList{} },
utils.TableColumns{}, // default table converter utils.TableColumns{}, // default table converter
) )
var QueryTypeDefinitionResourceInfo = common.NewResourceInfo(GROUP, VERSION, var QueryTypeDefinitionResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"querytypes", "querytype", "QueryTypeDefinition", "querytypes", "querytype", "QueryTypeDefinition",
func() runtime.Object { return &QueryTypeDefinition{} }, func() runtime.Object { return &QueryTypeDefinition{} },
func() runtime.Object { return &QueryTypeDefinitionList{} }, func() runtime.Object { return &QueryTypeDefinitionList{} },

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"time" "time"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -17,7 +16,7 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var ScopeResourceInfo = common.NewResourceInfo(GROUP, VERSION, var ScopeResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"scopes", "scope", "Scope", "scopes", "scope", "Scope",
func() runtime.Object { return &Scope{} }, func() runtime.Object { return &Scope{} },
func() runtime.Object { return &ScopeList{} }, func() runtime.Object { return &ScopeList{} },
@ -43,7 +42,7 @@ var ScopeResourceInfo = common.NewResourceInfo(GROUP, VERSION,
}, // default table converter }, // default table converter
) )
var ScopeDashboardBindingResourceInfo = common.NewResourceInfo(GROUP, VERSION, var ScopeDashboardBindingResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"scopedashboardbindings", "scopedashboardbinding", "ScopeDashboardBinding", "scopedashboardbindings", "scopedashboardbinding", "ScopeDashboardBinding",
func() runtime.Object { return &ScopeDashboardBinding{} }, func() runtime.Object { return &ScopeDashboardBinding{} },
func() runtime.Object { return &ScopeDashboardBindingList{} }, func() runtime.Object { return &ScopeDashboardBindingList{} },
@ -69,7 +68,7 @@ var ScopeDashboardBindingResourceInfo = common.NewResourceInfo(GROUP, VERSION,
}, },
) )
var ScopeNodeResourceInfo = common.NewResourceInfo(GROUP, VERSION, var ScopeNodeResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"scopenodes", "scopenode", "ScopeNode", "scopenodes", "scopenode", "ScopeNode",
func() runtime.Object { return &ScopeNode{} }, func() runtime.Object { return &ScopeNode{} },
func() runtime.Object { return &ScopeNodeList{} }, func() runtime.Object { return &ScopeNodeList{} },

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"time" "time"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/apimachinery/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -17,7 +16,7 @@ const (
APIVERSION = GROUP + "/" + VERSION APIVERSION = GROUP + "/" + VERSION
) )
var ExternalNameResourceInfo = common.NewResourceInfo(GROUP, VERSION, var ExternalNameResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
"externalnames", "externalname", "ExternalName", "externalnames", "externalname", "ExternalName",
func() runtime.Object { return &ExternalName{} }, func() runtime.Object { return &ExternalName{} },
func() runtime.Object { return &ExternalNameList{} }, func() runtime.Object { return &ExternalNameList{} },

View File

@ -1,21 +1,20 @@
package dashboard package dashboard
import ( import (
"k8s.io/apimachinery/pkg/runtime" "github.com/grafana/grafana/pkg/apimachinery/utils"
"k8s.io/apiserver/pkg/registry/generic"
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
grafanaregistry "github.com/grafana/grafana/pkg/apiserver/registry/generic" grafanaregistry "github.com/grafana/grafana/pkg/apiserver/registry/generic"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest" grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/registry/apis/dashboard/legacy" "github.com/grafana/grafana/pkg/registry/apis/dashboard/legacy"
"github.com/grafana/grafana/pkg/storage/unified/apistore" "github.com/grafana/grafana/pkg/storage/unified/apistore"
"github.com/grafana/grafana/pkg/storage/unified/resource" "github.com/grafana/grafana/pkg/storage/unified/resource"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/generic"
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
) )
type dashboardStorage struct { type dashboardStorage struct {
resource common.ResourceInfo resource utils.ResourceInfo
access legacy.DashboardAccess access legacy.DashboardAccess
tableConverter rest.TableConvertor tableConverter rest.TableConvertor

View File

@ -3,12 +3,11 @@ package datasource
import ( import (
"context" "context"
"github.com/grafana/grafana/pkg/apimachinery/utils"
"k8s.io/apimachinery/pkg/apis/meta/internalversion" "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
) )
var ( var (
@ -20,7 +19,7 @@ var (
) )
type connectionAccess struct { type connectionAccess struct {
resourceInfo common.ResourceInfo resourceInfo utils.ResourceInfo
tableConverter rest.TableConvertor tableConverter rest.TableConvertor
datasources PluginDatasourceProvider datasources PluginDatasourceProvider
} }

View File

@ -4,20 +4,19 @@ import (
"context" "context"
"github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/identity" "github.com/grafana/grafana/pkg/apimachinery/identity"
"github.com/grafana/grafana/pkg/apimachinery/utils"
"github.com/grafana/grafana/pkg/apis/datasource/v0alpha1" "github.com/grafana/grafana/pkg/apis/datasource/v0alpha1"
"github.com/grafana/grafana/pkg/plugins" "github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request" "github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
"github.com/grafana/grafana/pkg/services/datasources" "github.com/grafana/grafana/pkg/services/datasources"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
type QuerierFactoryFunc func(ctx context.Context, ri common.ResourceInfo, pj plugins.JSONData) (Querier, error) type QuerierFactoryFunc func(ctx context.Context, ri utils.ResourceInfo, pj plugins.JSONData) (Querier, error)
type QuerierProvider interface { type QuerierProvider interface {
Querier(ctx context.Context, ri common.ResourceInfo, pj plugins.JSONData) (Querier, error) Querier(ctx context.Context, ri utils.ResourceInfo, pj plugins.JSONData) (Querier, error)
} }
type DefaultQuerierProvider struct { type DefaultQuerierProvider struct {
@ -26,7 +25,7 @@ type DefaultQuerierProvider struct {
func ProvideDefaultQuerierProvider(pluginClient plugins.Client, dsService datasources.DataSourceService, func ProvideDefaultQuerierProvider(pluginClient plugins.Client, dsService datasources.DataSourceService,
dsCache datasources.CacheService) *DefaultQuerierProvider { dsCache datasources.CacheService) *DefaultQuerierProvider {
return NewQuerierProvider(func(ctx context.Context, ri common.ResourceInfo, pj plugins.JSONData) (Querier, error) { return NewQuerierProvider(func(ctx context.Context, ri utils.ResourceInfo, pj plugins.JSONData) (Querier, error) {
return NewDefaultQuerier(ri, pj, pluginClient, dsService, dsCache), nil return NewDefaultQuerier(ri, pj, pluginClient, dsService, dsCache), nil
}) })
} }
@ -37,7 +36,7 @@ func NewQuerierProvider(factory QuerierFactoryFunc) *DefaultQuerierProvider {
} }
} }
func (p *DefaultQuerierProvider) Querier(ctx context.Context, ri common.ResourceInfo, pj plugins.JSONData) (Querier, error) { func (p *DefaultQuerierProvider) Querier(ctx context.Context, ri utils.ResourceInfo, pj plugins.JSONData) (Querier, error) {
return p.factory(ctx, ri, pj) return p.factory(ctx, ri, pj)
} }
@ -56,7 +55,7 @@ type Querier interface {
} }
type DefaultQuerier struct { type DefaultQuerier struct {
connectionResourceInfo common.ResourceInfo connectionResourceInfo utils.ResourceInfo
pluginJSON plugins.JSONData pluginJSON plugins.JSONData
pluginClient plugins.Client pluginClient plugins.Client
dsService datasources.DataSourceService dsService datasources.DataSourceService
@ -64,7 +63,7 @@ type DefaultQuerier struct {
} }
func NewDefaultQuerier( func NewDefaultQuerier(
connectionResourceInfo common.ResourceInfo, connectionResourceInfo utils.ResourceInfo,
pluginJSON plugins.JSONData, pluginJSON plugins.JSONData,
pluginClient plugins.Client, pluginClient plugins.Client,
dsService datasources.DataSourceService, dsService datasources.DataSourceService,

View File

@ -6,7 +6,19 @@ import (
"fmt" "fmt"
"github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/apimachinery/utils"
datasource "github.com/grafana/grafana/pkg/apis/datasource/v0alpha1"
query "github.com/grafana/grafana/pkg/apis/query/v0alpha1"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/promlib/models"
"github.com/grafana/grafana/pkg/registry/apis/query/queryschema"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/apiserver/builder"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
"github.com/grafana/grafana/pkg/tsdb/grafana-testdata-datasource/kinds"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@ -19,26 +31,13 @@ import (
openapi "k8s.io/kube-openapi/pkg/common" openapi "k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/spec3" "k8s.io/kube-openapi/pkg/spec3"
"k8s.io/utils/strings/slices" "k8s.io/utils/strings/slices"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
datasource "github.com/grafana/grafana/pkg/apis/datasource/v0alpha1"
query "github.com/grafana/grafana/pkg/apis/query/v0alpha1"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/promlib/models"
"github.com/grafana/grafana/pkg/registry/apis/query/queryschema"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/apiserver/builder"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
"github.com/grafana/grafana/pkg/tsdb/grafana-testdata-datasource/kinds"
) )
var _ builder.APIGroupBuilder = (*DataSourceAPIBuilder)(nil) var _ builder.APIGroupBuilder = (*DataSourceAPIBuilder)(nil)
// DataSourceAPIBuilder is used just so wire has something unique to return // DataSourceAPIBuilder is used just so wire has something unique to return
type DataSourceAPIBuilder struct { type DataSourceAPIBuilder struct {
connectionResourceInfo common.ResourceInfo connectionResourceInfo utils.ResourceInfo
pluginJSON plugins.JSONData pluginJSON plugins.JSONData
client PluginClient // will only ever be called with the same pluginid! client PluginClient // will only ever be called with the same pluginid!
@ -192,10 +191,10 @@ func (b *DataSourceAPIBuilder) InstallSchema(scheme *runtime.Scheme) error {
return scheme.SetVersionPriority(gv) return scheme.SetVersionPriority(gv)
} }
func resourceFromPluginID(pluginID string) (common.ResourceInfo, error) { func resourceFromPluginID(pluginID string) (utils.ResourceInfo, error) {
group, err := plugins.GetDatasourceGroupNameFromPluginID(pluginID) group, err := plugins.GetDatasourceGroupNameFromPluginID(pluginID)
if err != nil { if err != nil {
return common.ResourceInfo{}, err return utils.ResourceInfo{}, err
} }
return datasource.GenericConnectionResourceInfo.WithGroupAndShortName(group, pluginID+"-connection"), nil return datasource.GenericConnectionResourceInfo.WithGroupAndShortName(group, pluginID+"-connection"), nil
} }

View File

@ -5,14 +5,13 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/grafana/grafana/pkg/apimachinery/utils"
"github.com/grafana/grafana/pkg/apis/featuretoggle/v0alpha1"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"k8s.io/apimachinery/pkg/apis/meta/internalversion" "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apis/featuretoggle/v0alpha1"
"github.com/grafana/grafana/pkg/services/featuremgmt"
) )
var ( var (
@ -24,7 +23,7 @@ var (
) )
type featuresStorage struct { type featuresStorage struct {
resource *common.ResourceInfo resource *utils.ResourceInfo
tableConverter rest.TableConvertor tableConverter rest.TableConvertor
features *v0alpha1.FeatureList features *v0alpha1.FeatureList
featuresOnce sync.Once featuresOnce sync.Once

View File

@ -4,15 +4,14 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/grafana/grafana/pkg/apimachinery/utils"
"github.com/grafana/grafana/pkg/apis/featuretoggle/v0alpha1"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"k8s.io/apimachinery/pkg/apis/meta/internalversion" "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apis/featuretoggle/v0alpha1"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
"github.com/grafana/grafana/pkg/services/featuremgmt"
) )
var ( var (
@ -24,7 +23,7 @@ var (
) )
type togglesStorage struct { type togglesStorage struct {
resource *common.ResourceInfo resource *utils.ResourceInfo
tableConverter rest.TableConvertor tableConverter rest.TableConvertor
// The startup toggles // The startup toggles

View File

@ -3,13 +3,12 @@ package query
import ( import (
"context" "context"
"github.com/grafana/grafana/pkg/apimachinery/utils"
query "github.com/grafana/grafana/pkg/apis/query/v0alpha1"
"k8s.io/apimachinery/pkg/apis/meta/internalversion" "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
query "github.com/grafana/grafana/pkg/apis/query/v0alpha1"
) )
var ( var (
@ -20,7 +19,7 @@ var (
) )
type pluginsStorage struct { type pluginsStorage struct {
resourceInfo *common.ResourceInfo resourceInfo *utils.ResourceInfo
tableConverter rest.TableConvertor tableConverter rest.TableConvertor
registry query.DataSourceApiServerRegistry registry query.DataSourceApiServerRegistry

View File

@ -4,15 +4,13 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1"
"github.com/grafana/grafana/pkg/apimachinery/utils"
query "github.com/grafana/grafana/pkg/apis/query/v0alpha1"
"k8s.io/apimachinery/pkg/apis/meta/internalversion" "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
query "github.com/grafana/grafana/pkg/apis/query/v0alpha1"
) )
var ( var (
@ -27,7 +25,7 @@ var (
) )
type queryTypeStorage struct { type queryTypeStorage struct {
resourceInfo *common.ResourceInfo resourceInfo *utils.ResourceInfo
tableConverter rest.TableConvertor tableConverter rest.TableConvertor
registry query.QueryTypeDefinitionList registry query.QueryTypeDefinitionList
} }