Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/controller/expansion/expansion_controller.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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