From b80901cce020e785107420859225638c059189a5 Mon Sep 17 00:00:00 2001 From: Yuri Tseretyan Date: Thu, 24 Apr 2025 17:23:42 -0400 Subject: [PATCH] move to v0alpha1 --- .../apps/alerting/notifications/receiver/authorize.go | 3 ++- .../notifications/receiver/{ => v0alpha1}/conversions.go | 2 +- .../receiver/{ => v0alpha1}/legacy_storage.go | 8 ++++---- .../notifications/receiver/{ => v0alpha1}/storage.go | 2 +- .../notifications/receiver/{ => v0alpha1}/type.go | 2 +- pkg/registry/apps/alerting/notifications/register.go | 7 ++++--- 6 files changed, 13 insertions(+), 11 deletions(-) rename pkg/registry/apps/alerting/notifications/receiver/{ => v0alpha1}/conversions.go (99%) rename pkg/registry/apps/alerting/notifications/receiver/{ => v0alpha1}/legacy_storage.go (98%) rename pkg/registry/apps/alerting/notifications/receiver/{ => v0alpha1}/storage.go (96%) rename pkg/registry/apps/alerting/notifications/receiver/{ => v0alpha1}/type.go (98%) diff --git a/pkg/registry/apps/alerting/notifications/receiver/authorize.go b/pkg/registry/apps/alerting/notifications/receiver/authorize.go index c1ddc7b070f..60ac9c01cc4 100644 --- a/pkg/registry/apps/alerting/notifications/receiver/authorize.go +++ b/pkg/registry/apps/alerting/notifications/receiver/authorize.go @@ -9,6 +9,7 @@ import ( "github.com/grafana/grafana/pkg/apimachinery/errutil" "github.com/grafana/grafana/pkg/apimachinery/identity" + "github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/receiver/v0alpha1" "github.com/grafana/grafana/pkg/services/ngalert/accesscontrol" ) @@ -22,7 +23,7 @@ type AccessControlService interface { } func Authorize(ctx context.Context, ac AccessControlService, attr authorizer.Attributes) (authorized authorizer.Decision, reason string, err error) { - if attr.GetResource() != ResourceInfo.GroupResource().Resource { + if attr.GetResource() != v0alpha1.ResourceInfo.GroupResource().Resource { return authorizer.DecisionNoOpinion, "", nil } user, err := identity.GetRequester(ctx) diff --git a/pkg/registry/apps/alerting/notifications/receiver/conversions.go b/pkg/registry/apps/alerting/notifications/receiver/v0alpha1/conversions.go similarity index 99% rename from pkg/registry/apps/alerting/notifications/receiver/conversions.go rename to pkg/registry/apps/alerting/notifications/receiver/v0alpha1/conversions.go index 9b7de3c4c29..f32be9242d2 100644 --- a/pkg/registry/apps/alerting/notifications/receiver/conversions.go +++ b/pkg/registry/apps/alerting/notifications/receiver/v0alpha1/conversions.go @@ -1,4 +1,4 @@ -package receiver +package v0alpha1 import ( "fmt" diff --git a/pkg/registry/apps/alerting/notifications/receiver/legacy_storage.go b/pkg/registry/apps/alerting/notifications/receiver/v0alpha1/legacy_storage.go similarity index 98% rename from pkg/registry/apps/alerting/notifications/receiver/legacy_storage.go rename to pkg/registry/apps/alerting/notifications/receiver/v0alpha1/legacy_storage.go index 4301ff250e1..f9410c0221d 100644 --- a/pkg/registry/apps/alerting/notifications/receiver/legacy_storage.go +++ b/pkg/registry/apps/alerting/notifications/receiver/v0alpha1/legacy_storage.go @@ -1,4 +1,4 @@ -package receiver +package v0alpha1 import ( "context" @@ -76,9 +76,9 @@ func (s *legacyStorage) List(ctx context.Context, opts *internalversion.ListOpti q := ngmodels.GetReceiversQuery{ OrgID: orgId, Decrypt: false, - //Names: ctx.QueryStrings("names"), // TODO: Query params. - //Limit: ctx.QueryInt("limit"), - //Offset: ctx.QueryInt("offset"), + // Names: ctx.QueryStrings("names"), // TODO: Query params. + // Limit: ctx.QueryInt("limit"), + // Offset: ctx.QueryInt("offset"), } user, err := identity.GetRequester(ctx) diff --git a/pkg/registry/apps/alerting/notifications/receiver/storage.go b/pkg/registry/apps/alerting/notifications/receiver/v0alpha1/storage.go similarity index 96% rename from pkg/registry/apps/alerting/notifications/receiver/storage.go rename to pkg/registry/apps/alerting/notifications/receiver/v0alpha1/storage.go index 0c779eca0c8..bd97113a13e 100644 --- a/pkg/registry/apps/alerting/notifications/receiver/storage.go +++ b/pkg/registry/apps/alerting/notifications/receiver/v0alpha1/storage.go @@ -1,4 +1,4 @@ -package receiver +package v0alpha1 import ( grafanarest "github.com/grafana/grafana/pkg/apiserver/rest" diff --git a/pkg/registry/apps/alerting/notifications/receiver/type.go b/pkg/registry/apps/alerting/notifications/receiver/v0alpha1/type.go similarity index 98% rename from pkg/registry/apps/alerting/notifications/receiver/type.go rename to pkg/registry/apps/alerting/notifications/receiver/v0alpha1/type.go index d42a4cff451..d7189713b37 100644 --- a/pkg/registry/apps/alerting/notifications/receiver/type.go +++ b/pkg/registry/apps/alerting/notifications/receiver/v0alpha1/type.go @@ -1,4 +1,4 @@ -package receiver +package v0alpha1 import ( "fmt" diff --git a/pkg/registry/apps/alerting/notifications/register.go b/pkg/registry/apps/alerting/notifications/register.go index 6f62d7a56ea..33d5242b462 100644 --- a/pkg/registry/apps/alerting/notifications/register.go +++ b/pkg/registry/apps/alerting/notifications/register.go @@ -12,6 +12,7 @@ import ( notificationsApp "github.com/grafana/grafana/apps/alerting/notifications/pkg/app" grafanarest "github.com/grafana/grafana/pkg/apiserver/rest" "github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/receiver" + receiverv1 "github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/receiver/v0alpha1" "github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/routingtree" "github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/templategroup" "github.com/grafana/grafana/pkg/registry/apps/alerting/notifications/timeinterval" @@ -55,7 +56,7 @@ func getAuthorizer(authz accesscontrol.AccessControl) authorizer.Authorizer { return templategroup.Authorize(ctx, authz, a) case timeinterval.ResourceInfo.GroupResource().Resource: return timeinterval.Authorize(ctx, authz, a) - case receiver.ResourceInfo.GroupResource().Resource: + case receiverv1.ResourceInfo.GroupResource().Resource: return receiver.Authorize(ctx, ac.NewReceiverAccess[*ngmodels.Receiver](authz, false), a) case routingtree.ResourceInfo.GroupResource().Resource: return routingtree.Authorize(ctx, authz, a) @@ -66,8 +67,8 @@ func getAuthorizer(authz accesscontrol.AccessControl) authorizer.Authorizer { func getLegacyStorage(namespacer request.NamespaceMapper, ng *ngalert.AlertNG) runner.LegacyStorageGetter { return func(gvr schema.GroupVersionResource) grafanarest.Storage { - if gvr == receiver.ResourceInfo.GroupVersionResource() { - return receiver.NewStorage(ng.Api.ReceiverService, namespacer, ng.Api.ReceiverService) + if gvr == receiverv1.ResourceInfo.GroupVersionResource() { + return receiverv1.NewStorage(ng.Api.ReceiverService, namespacer, ng.Api.ReceiverService) } else if gvr == timeinterval.ResourceInfo.GroupVersionResource() { return timeinterval.NewStorage(ng.Api.MuteTimings, namespacer) } else if gvr == templategroup.ResourceInfo.GroupVersionResource() {