move to v0alpha1
This commit is contained in:
@@ -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)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package receiver
|
||||
package v0alpha1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+4
-4
@@ -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)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package receiver
|
||||
package v0alpha1
|
||||
|
||||
import (
|
||||
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package receiver
|
||||
package v0alpha1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user