Chore: Use Kind().GroupVersionResource() (#113133)
This commit is contained in:
@@ -5,12 +5,11 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana-app-sdk/app"
|
||||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apiserver/pkg/admission"
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
|
||||
"github.com/grafana/grafana-app-sdk/app"
|
||||
examplev1 "github.com/grafana/grafana/pkg/services/apiserver/builder/runner/testdata/app/pkg/apis/example/v1"
|
||||
)
|
||||
|
||||
@@ -20,12 +19,8 @@ func TestBuilderAdmission_Validate(t *testing.T) {
|
||||
A: "test",
|
||||
},
|
||||
}
|
||||
gvk := schema.GroupVersionKind{
|
||||
Group: examplev1.ExampleKind().Group(),
|
||||
Version: examplev1.ExampleKind().Version(),
|
||||
Kind: examplev1.ExampleKind().Kind(),
|
||||
}
|
||||
gvr := gvk.GroupVersion().WithResource(examplev1.ExampleKind().Plural())
|
||||
gvk := examplev1.ExampleKind().GroupVersionKind()
|
||||
gvr := examplev1.ExampleKind().GroupVersionResource()
|
||||
defaultAttributes := admission.NewAttributesRecord(exampleObj, nil, gvk, "default", "foo", gvr, "", admission.Create, nil, false, &user.DefaultInfo{})
|
||||
|
||||
tests := []struct {
|
||||
@@ -73,12 +68,8 @@ func TestBuilderAdmission_Validate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuilderAdmission_Mutate(t *testing.T) {
|
||||
gvk := schema.GroupVersionKind{
|
||||
Group: examplev1.ExampleKind().Group(),
|
||||
Version: examplev1.ExampleKind().Version(),
|
||||
Kind: examplev1.ExampleKind().Kind(),
|
||||
}
|
||||
gvr := gvk.GroupVersion().WithResource(examplev1.ExampleKind().Plural())
|
||||
gvk := examplev1.ExampleKind().GroupVersionKind()
|
||||
gvr := examplev1.ExampleKind().GroupVersionResource()
|
||||
getAttributes := func() admission.Attributes {
|
||||
exampleObj := &examplev1.Example{
|
||||
Spec: examplev1.ExampleSpec{
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/client-go/dynamic"
|
||||
|
||||
"github.com/grafana/grafana/apps/shorturl/pkg/apis/shorturl/v1alpha1"
|
||||
@@ -326,11 +325,7 @@ func (srv *CleanUpService) deleteStaleKubernetesShortURLs(ctx context.Context) {
|
||||
}
|
||||
|
||||
// Set up the GroupVersionResource for shortURLs
|
||||
gvr := schema.GroupVersionResource{
|
||||
Group: v1alpha1.ShortURLKind().Group(),
|
||||
Version: v1alpha1.ShortURLKind().Version(),
|
||||
Resource: v1alpha1.ShortURLKind().Plural(),
|
||||
}
|
||||
gvr := v1alpha1.ShortURLKind().GroupVersionResource()
|
||||
|
||||
// Calculate the expiration time
|
||||
expirationTime := time.Now().Add(-time.Duration(srv.Cfg.ShortLinkExpiration*24) * time.Hour)
|
||||
|
||||
Reference in New Issue
Block a user