Skip to content

Commit

Permalink
chore: pkg imported more than once (#2851)
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill committed Jul 5, 2023
1 parent 6aad7b6 commit d8f2bbc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions pkg/controller/expansion/expansion_controller.go
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/open-policy-agent/gatekeeper/v3/pkg/util"
"github.com/open-policy-agent/gatekeeper/v3/pkg/watch"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -137,7 +136,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
versionedET := &expansionv1alpha1.ExpansionTemplate{}
err := r.Get(ctx, request.NamespacedName, versionedET)
if err != nil {
if !errors.IsNotFound(err) {
if !apierrors.IsNotFound(err) {
return reconcile.Result{}, err
}
deleted = true
Expand Down
3 changes: 1 addition & 2 deletions pkg/instrumentation/types.go
Expand Up @@ -2,7 +2,6 @@ package instrumentation

import (
constraintclient "github.com/open-policy-agent/frameworks/constraint/pkg/client"
"github.com/open-policy-agent/frameworks/constraint/pkg/instrumentation"
cfinstr "github.com/open-policy-agent/frameworks/constraint/pkg/instrumentation"
)

Expand All @@ -26,7 +25,7 @@ type StatsEntryWithDesc struct {

// ToStatsEntriesWithDesc will use the client passed in to adorn constraint framework instrumentation.StatsEntry structs
// with a description and returns an array of StatsEntryWithDesc.
func ToStatsEntriesWithDesc(client *constraintclient.Client, cfentries []*instrumentation.StatsEntry) []*StatsEntryWithDesc {
func ToStatsEntriesWithDesc(client *constraintclient.Client, cfentries []*cfinstr.StatsEntry) []*StatsEntryWithDesc {
var entriesWithDesc []*StatsEntryWithDesc
for _, se := range cfentries {
sewd := &StatsEntryWithDesc{
Expand Down
17 changes: 8 additions & 9 deletions pkg/instrumentation/types_test.go
Expand Up @@ -5,7 +5,6 @@ import (

constraintclient "github.com/open-policy-agent/frameworks/constraint/pkg/client"
"github.com/open-policy-agent/frameworks/constraint/pkg/client/drivers/rego"
"github.com/open-policy-agent/frameworks/constraint/pkg/instrumentation"
cfinstr "github.com/open-policy-agent/frameworks/constraint/pkg/instrumentation"
"github.com/open-policy-agent/gatekeeper/v3/pkg/target"
"github.com/stretchr/testify/assert"
Expand All @@ -22,19 +21,19 @@ func Test_ToStatsEntriesWithDesc(t *testing.T) {
testCases := []struct {
name string
client *constraintclient.Client
cfentries []*instrumentation.StatsEntry
cfentries []*cfinstr.StatsEntry
expected []*StatsEntryWithDesc
}{
{
name: "Empty input",
client: nil,
cfentries: []*instrumentation.StatsEntry{},
cfentries: []*cfinstr.StatsEntry{},
expected: nil,
},
{
name: "Single entry with one stat, unknown description",
client: nil,
cfentries: []*instrumentation.StatsEntry{
cfentries: []*cfinstr.StatsEntry{
{
Scope: "scope1",
StatsFor: "statsFor1",
Expand Down Expand Up @@ -77,7 +76,7 @@ func Test_ToStatsEntriesWithDesc(t *testing.T) {
{
name: "actual client, stat",
client: actualClient,
cfentries: []*instrumentation.StatsEntry{
cfentries: []*cfinstr.StatsEntry{
{
Scope: "scope1",
StatsFor: "statsFor1",
Expand All @@ -86,15 +85,15 @@ func Test_ToStatsEntriesWithDesc(t *testing.T) {
Name: "templateRunTimeNS",
Value: "value1",
Source: cfinstr.Source{
Type: instrumentation.EngineSourceType,
Type: cfinstr.EngineSourceType,
Value: "Rego",
},
},
{
Name: "constraintCount",
Value: "value1",
Source: cfinstr.Source{
Type: instrumentation.EngineSourceType,
Type: cfinstr.EngineSourceType,
Value: "Rego",
},
},
Expand All @@ -117,7 +116,7 @@ func Test_ToStatsEntriesWithDesc(t *testing.T) {
Name: "templateRunTimeNS",
Value: "value1",
Source: cfinstr.Source{
Type: instrumentation.EngineSourceType,
Type: cfinstr.EngineSourceType,
Value: "Rego",
},
},
Expand All @@ -128,7 +127,7 @@ func Test_ToStatsEntriesWithDesc(t *testing.T) {
Name: "constraintCount",
Value: "value1",
Source: cfinstr.Source{
Type: instrumentation.EngineSourceType,
Type: cfinstr.EngineSourceType,
Value: "Rego",
},
},
Expand Down
9 changes: 4 additions & 5 deletions pkg/webhook/policy_test.go
Expand Up @@ -24,7 +24,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
k8schema "k8s.io/apimachinery/pkg/runtime/schema"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
Expand Down Expand Up @@ -216,8 +215,8 @@ func (f *nsGetter) IsObjectNamespaced(obj runtime.Object) (bool, error) {
return false, nil
}

func (f *nsGetter) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error) {
return schema.GroupVersionKind{}, nil
func (f *nsGetter) GroupVersionKindFor(obj runtime.Object) (k8schema.GroupVersionKind, error) {
return k8schema.GroupVersionKind{}, nil
}

func (f *nsGetter) SubResource(_ string) ctrlclient.SubResourceClient {
Expand All @@ -243,8 +242,8 @@ func (f *errorNSGetter) IsObjectNamespaced(obj runtime.Object) (bool, error) {
return false, nil
}

func (f *errorNSGetter) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error) {
return schema.GroupVersionKind{}, nil
func (f *errorNSGetter) GroupVersionKindFor(obj runtime.Object) (k8schema.GroupVersionKind, error) {
return k8schema.GroupVersionKind{}, nil
}

func (f *errorNSGetter) SubResource(_ string) ctrlclient.SubResourceClient {
Expand Down

0 comments on commit d8f2bbc

Please sign in to comment.