Chore: Use Kind().GroupVersionResource() (#113133)
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
|
||||
playlist "github.com/grafana/grafana/apps/playlist/pkg/apis/playlist/v0alpha1"
|
||||
@@ -87,10 +86,7 @@ func (s *legacyStorage) Get(ctx context.Context, name string, options *metav1.Ge
|
||||
})
|
||||
if err != nil || dto == nil {
|
||||
if errors.Is(err, playlistsvc.ErrPlaylistNotFound) || err == nil {
|
||||
err = k8serrors.NewNotFound(schema.GroupResource{
|
||||
Group: playlist.PlaylistKind().Group(),
|
||||
Resource: playlist.PlaylistKind().Plural(),
|
||||
}, name)
|
||||
err = k8serrors.NewNotFound(playlist.PlaylistKind().GroupVersionResource().GroupResource(), name)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -65,11 +65,7 @@ func RegisterAppInstaller(
|
||||
|
||||
// GetLegacyStorage returns the legacy storage for the playlist app.
|
||||
func (p *PlaylistAppInstaller) GetLegacyStorage(requested schema.GroupVersionResource) grafanarest.Storage {
|
||||
gvr := schema.GroupVersionResource{
|
||||
Group: playlistv0alpha1.PlaylistKind().Group(),
|
||||
Version: playlistv0alpha1.PlaylistKind().Version(),
|
||||
Resource: playlistv0alpha1.PlaylistKind().Plural(),
|
||||
}
|
||||
gvr := playlistv0alpha1.PlaylistKind().GroupVersionResource()
|
||||
if requested.String() != gvr.String() {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -55,11 +55,7 @@ func (p *PluginsAppInstaller) InstallAPIs(
|
||||
server appsdkapiserver.GenericAPIServer,
|
||||
restOptsGetter generic.RESTOptionsGetter,
|
||||
) error {
|
||||
pluginMetaGVR := schema.GroupVersionResource{
|
||||
Group: pluginsv0alpha1.GroupVersion.Group,
|
||||
Version: pluginsv0alpha1.GroupVersion.Version,
|
||||
Resource: pluginsv0alpha1.PluginMetaKind().Plural(),
|
||||
}
|
||||
pluginMetaGVR := pluginsv0alpha1.PluginMetaKind().GroupVersionResource()
|
||||
replacedStorage := map[schema.GroupVersionResource]rest.Storage{
|
||||
pluginMetaGVR: pluginsapp.NewPluginMetaStorage(request.GetNamespaceMapper(p.cfg)),
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
|
||||
shorturl "github.com/grafana/grafana/apps/shorturl/pkg/apis/shorturl/v1alpha1"
|
||||
@@ -97,10 +96,7 @@ func (s *legacyStorage) Get(ctx context.Context, name string, options *metav1.Ge
|
||||
dto, err := s.service.GetShortURLByUID(ctx, signedInUser, name)
|
||||
if err != nil || dto == nil {
|
||||
if errors.Is(err, shorturls.ErrShortURLNotFound) || err == nil {
|
||||
err = k8serrors.NewNotFound(schema.GroupResource{
|
||||
Group: shorturl.ShortURLKind().Group(),
|
||||
Resource: shorturl.ShortURLKind().Plural(),
|
||||
}, name)
|
||||
err = k8serrors.NewNotFound(shorturl.ShortURLKind().GroupVersionResource().GroupResource(), name)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -167,10 +163,7 @@ func (s *legacyStorage) Update(ctx context.Context,
|
||||
shortURL, err := s.service.GetShortURLByUID(ctx, signedInUser, name)
|
||||
if err != nil || shortURL == nil {
|
||||
if errors.Is(err, shorturls.ErrShortURLNotFound) || err == nil {
|
||||
err = k8serrors.NewNotFound(schema.GroupResource{
|
||||
Group: shorturl.ShortURLKind().Group(),
|
||||
Resource: shorturl.ShortURLKind().Plural(),
|
||||
}, name)
|
||||
err = k8serrors.NewNotFound(shorturl.ShortURLKind().GroupVersionResource().GroupResource(), name)
|
||||
}
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
@@ -55,11 +55,7 @@ func RegisterAppInstaller(
|
||||
}
|
||||
|
||||
func (s *ShortURLAppInstaller) GetLegacyStorage(requested schema.GroupVersionResource) grafanarest.Storage {
|
||||
gvr := schema.GroupVersionResource{
|
||||
Group: shorturl.ShortURLKind().Group(),
|
||||
Version: shorturl.ShortURLKind().Version(),
|
||||
Resource: shorturl.ShortURLKind().Plural(),
|
||||
}
|
||||
gvr := shorturl.ShortURLKind().GroupVersionResource()
|
||||
if requested.String() != gvr.String() {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user