Skip to content

Commit

Permalink
chore: clean up repeated package import (#2579)
Browse files Browse the repository at this point in the history
Co-authored-by: Sertaç Özercan <852750+sozercan@users.noreply.github.com>
  • Loading branch information
Fish-pro and sozercan committed Feb 14, 2023
1 parent d8f501a commit 0761889
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
11 changes: 5 additions & 6 deletions pkg/mutation/mutators/assignmeta/assignmeta_mutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"github.com/open-policy-agent/gatekeeper/apis/mutations/unversioned"
mutationsunversioned "github.com/open-policy-agent/gatekeeper/apis/mutations/unversioned"
"github.com/open-policy-agent/gatekeeper/pkg/externaldata"
"github.com/open-policy-agent/gatekeeper/pkg/mutation/types"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -26,8 +25,8 @@ func newFoo(spec map[string]interface{}) *unstructured.Unstructured {
return &unstructured.Unstructured{Object: data}
}

func newAssignMetadataMutator(t *testing.T, path string, value mutationsunversioned.AssignField) *Mutator {
m := &mutationsunversioned.AssignMetadata{
func newAssignMetadataMutator(t *testing.T, path string, value unversioned.AssignField) *Mutator {
m := &unversioned.AssignMetadata{
ObjectMeta: metav1.ObjectMeta{
Name: "Foo",
},
Expand All @@ -47,13 +46,13 @@ func TestAssignMetadata(t *testing.T) {
name string
obj *unstructured.Unstructured
path string
value mutationsunversioned.AssignField
value unversioned.AssignField
expected interface{}
}{
{
name: "metadata value",
path: "metadata.labels.foo",
value: mutationsunversioned.AssignField{FromMetadata: &mutationsunversioned.FromMetadata{Field: mutationsunversioned.ObjName}},
value: unversioned.AssignField{FromMetadata: &unversioned.FromMetadata{Field: unversioned.ObjName}},
obj: newFoo(map[string]interface{}{}),
expected: map[string]interface{}{
"name": "my-foo",
Expand All @@ -65,7 +64,7 @@ func TestAssignMetadata(t *testing.T) {
{
name: "external data placeholder",
path: "metadata.labels.foo",
value: mutationsunversioned.AssignField{
value: unversioned.AssignField{
ExternalData: &unversioned.ExternalData{
Provider: "some-provider",
DataSource: types.DataSourceUsername,
Expand Down
3 changes: 1 addition & 2 deletions pkg/webhook/policy_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/uuid"
"sigs.k8s.io/controller-runtime/pkg/client"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
atypes "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
"sigs.k8s.io/yaml"
)
Expand Down Expand Up @@ -78,7 +77,7 @@ func getFiles(dir string) ([]string, error) {
return filePaths, nil
}

func (f *fakeNsGetter) SubResource(subResource string) ctrlclient.SubResourceClient {
func (f *fakeNsGetter) SubResource(subResource string) client.SubResourceClient {
return nil
}

Expand Down
15 changes: 7 additions & 8 deletions pkg/webhook/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
k8schema "k8s.io/apimachinery/pkg/runtime/schema"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
atypes "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

const (
Expand Down Expand Up @@ -245,7 +244,7 @@ func TestTemplateValidation(t *testing.T) {
t.Fatalf("Error parsing yaml: %s", err)
}

review := &atypes.Request{
review := &admission.Request{
AdmissionRequest: admissionv1.AdmissionRequest{
Kind: metav1.GroupVersionKind{
Group: "templates.gatekeeper.sh",
Expand Down Expand Up @@ -359,7 +358,7 @@ func TestReviewRequest(t *testing.T) {
if maxThreads > 0 {
handler.semaphore = make(chan struct{}, maxThreads)
}
review := &atypes.Request{
review := &admission.Request{
AdmissionRequest: admissionv1.AdmissionRequest{
Kind: metav1.GroupVersionKind{
Group: "",
Expand Down Expand Up @@ -523,7 +522,7 @@ func TestConstraintValidation(t *testing.T) {
if err != nil {
t.Fatalf("Error parsing yaml: %s", err)
}
review := &atypes.Request{
review := &admission.Request{
AdmissionRequest: admissionv1.AdmissionRequest{
Kind: metav1.GroupVersionKind{
Group: "constraints.gatekeeper.sh",
Expand Down Expand Up @@ -650,7 +649,7 @@ func TestTracing(t *testing.T) {
handler.semaphore = make(chan struct{}, maxThreads)
}

review := &atypes.Request{
review := &admission.Request{
AdmissionRequest: admissionv1.AdmissionRequest{
Kind: metav1.GroupVersionKind{
Group: "",
Expand Down Expand Up @@ -825,7 +824,7 @@ func TestGetValidationMessages(t *testing.T) {
if maxThreads > 0 {
handler.semaphore = make(chan struct{}, maxThreads)
}
review := &atypes.Request{
review := &admission.Request{
AdmissionRequest: admissionv1.AdmissionRequest{
Kind: metav1.GroupVersionKind{
Group: "",
Expand Down Expand Up @@ -872,7 +871,7 @@ func TestValidateConfigResource(t *testing.T) {
for _, tt := range tc {
t.Run(tt.TestName, func(t *testing.T) {
handler := validationHandler{}
req := &atypes.Request{
req := &admission.Request{
AdmissionRequest: admissionv1.AdmissionRequest{
Name: tt.Name,
},
Expand Down Expand Up @@ -924,7 +923,7 @@ func TestValidateProvider(t *testing.T) {
t.Fatalf("Error parsing yaml: %s", err)
}

req := &atypes.Request{
req := &admission.Request{
AdmissionRequest: admissionv1.AdmissionRequest{
Object: runtime.RawExtension{
Raw: b,
Expand Down

0 comments on commit 0761889

Please sign in to comment.