Chore: Use Kind().GroupVersionResource() (#113133)

This commit is contained in:
Ryan McKinley
2025-10-28 14:54:10 -07:00
committed by GitHub
parent 329d6a11fa
commit d72e048bfe
11 changed files with 27 additions and 102 deletions
@@ -3,12 +3,11 @@ package common
import (
"testing"
"github.com/grafana/grafana/pkg/tests/apis"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alertingnotifications/v0alpha1"
"github.com/grafana/grafana/pkg/tests/apis"
)
func NewReceiverClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1.Receiver, v0alpha1.ReceiverList] {
@@ -19,11 +18,8 @@ func NewReceiverClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1.
return &apis.TypedClient[v0alpha1.Receiver, v0alpha1.ReceiverList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1.ReceiverKind().Group(),
Version: v0alpha1.ReceiverKind().Version(),
Resource: v0alpha1.ReceiverKind().Plural(),
}).Namespace("default"),
v0alpha1.ReceiverKind().GroupVersionResource()).
Namespace("default"),
}
}
@@ -35,11 +31,7 @@ func NewRoutingTreeClient(t *testing.T, user apis.User) *apis.TypedClient[v0alph
return &apis.TypedClient[v0alpha1.RoutingTree, v0alpha1.RoutingTreeList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1.RoutingTreeKind().Group(),
Version: v0alpha1.RoutingTreeKind().Version(),
Resource: v0alpha1.RoutingTreeKind().Plural(),
}).Namespace("default"),
v0alpha1.RoutingTreeKind().GroupVersionResource()).Namespace("default"),
}
}
@@ -51,11 +43,7 @@ func NewTemplateGroupClient(t *testing.T, user apis.User) *apis.TypedClient[v0al
return &apis.TypedClient[v0alpha1.TemplateGroup, v0alpha1.TemplateGroupList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1.TemplateGroupKind().Group(),
Version: v0alpha1.TemplateGroupKind().Version(),
Resource: v0alpha1.TemplateGroupKind().Plural(),
}).Namespace("default"),
v0alpha1.TemplateGroupKind().GroupVersionResource()).Namespace("default"),
}
}
@@ -67,10 +55,6 @@ func NewTimeIntervalClient(t *testing.T, user apis.User) *apis.TypedClient[v0alp
return &apis.TypedClient[v0alpha1.TimeInterval, v0alpha1.TimeIntervalList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1.TimeIntervalKind().Group(),
Version: v0alpha1.TimeIntervalKind().Version(),
Resource: v0alpha1.TimeIntervalKind().Plural(),
}).Namespace("default"),
v0alpha1.TimeIntervalKind().GroupVersionResource()).Namespace("default"),
}
}
@@ -4,14 +4,14 @@ import (
"context"
"testing"
"github.com/stretchr/testify/require"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/dynamic"
"github.com/grafana/grafana/apps/alerting/rules/pkg/apis/alerting/v0alpha1"
folders "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
"github.com/grafana/grafana/pkg/tests/apis"
"github.com/grafana/grafana/pkg/tests/testinfra"
"github.com/stretchr/testify/require"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
)
func NewAlertRuleClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1.AlertRule, v0alpha1.AlertRuleList] {
@@ -22,11 +22,7 @@ func NewAlertRuleClient(t *testing.T, user apis.User) *apis.TypedClient[v0alpha1
return &apis.TypedClient[v0alpha1.AlertRule, v0alpha1.AlertRuleList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1.AlertRuleKind().Group(),
Version: v0alpha1.AlertRuleKind().Version(),
Resource: v0alpha1.AlertRuleKind().Plural(),
}).Namespace("default"),
v0alpha1.AlertRuleKind().GroupVersionResource()).Namespace("default"),
}
}
@@ -38,11 +34,7 @@ func NewRecordingRuleClient(t *testing.T, user apis.User) *apis.TypedClient[v0al
return &apis.TypedClient[v0alpha1.RecordingRule, v0alpha1.RecordingRuleList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: v0alpha1.RecordingRuleKind().Group(),
Version: v0alpha1.RecordingRuleKind().Version(),
Resource: v0alpha1.RecordingRuleKind().Plural(),
}).Namespace("default"),
v0alpha1.RecordingRuleKind().GroupVersionResource()).Namespace("default"),
}
}
@@ -54,11 +46,7 @@ func NewFolderClient(t *testing.T, user apis.User) *apis.TypedClient[folders.Fol
return &apis.TypedClient[folders.Folder, folders.FolderList]{
Client: client.Resource(
schema.GroupVersionResource{
Group: folders.FolderKind().Group(),
Version: folders.FolderKind().Version(),
Resource: folders.FolderKind().Plural(),
}).Namespace("default"),
folders.FolderKind().GroupVersionResource()).Namespace("default"),
}
}