diff --git a/.mockery.yaml b/.mockery.yaml index fb370c56b..48e549d8f 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -1,15 +1,14 @@ quiet: False -inpackage: True disable-version-string: True with-expecter: True -filename: "{{ trimSuffix .InterfaceFile \".go\" | base | lower }}_mock.go" -dir: "{{ .InterfaceDir }}" +filename: "zz_generated.{{ trimSuffix .InterfaceFile \".go\" | base | lower }}_mock.go" +dir: "{{ .InterfaceDir }}/mocks" mockname: "Mock{{ .InterfaceName }}" -outpkg: "{{ .PackageName }}" +outpkg: "mocks" packages: - github.com/kong/gateway-operator/controller/konnect/ops: + github.com/kong/gateway-operator/controller/konnect/ops/sdk: interfaces: ControlPlaneSDK: ControlPlaneGroupSDK: diff --git a/controller/konnect/ops/ops.go b/controller/konnect/ops/ops.go index 94a1102a2..315f95433 100644 --- a/controller/konnect/ops/ops.go +++ b/controller/konnect/ops/ops.go @@ -12,6 +12,7 @@ import ( ctrllog "sigs.k8s.io/controller-runtime/pkg/log" "github.com/kong/gateway-operator/controller/konnect/constraints" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" "github.com/kong/gateway-operator/controller/pkg/log" "github.com/kong/gateway-operator/pkg/consts" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -46,7 +47,7 @@ func Create[ TEnt constraints.EntityType[T], ]( ctx context.Context, - sdk SDKWrapper, + sdk sdkops.SDKWrapper, cl client.Client, e TEnt, ) (*T, error) { @@ -164,7 +165,7 @@ func Create[ func Delete[ T constraints.SupportedKonnectEntityType, TEnt constraints.EntityType[T], -](ctx context.Context, sdk SDKWrapper, cl client.Client, e *T) error { +](ctx context.Context, sdk sdkops.SDKWrapper, cl client.Client, e *T) error { ent := TEnt(e) if ent.GetKonnectStatus().GetKonnectID() == "" { return fmt.Errorf( @@ -273,7 +274,7 @@ func Update[ TEnt constraints.EntityType[T], ]( ctx context.Context, - sdk SDKWrapper, + sdk sdkops.SDKWrapper, syncPeriod time.Duration, cl client.Client, e TEnt, diff --git a/controller/konnect/ops/ops_controlplane.go b/controller/konnect/ops/ops_controlplane.go index 9459f5747..84d425219 100644 --- a/controller/konnect/ops/ops_controlplane.go +++ b/controller/konnect/ops/ops_controlplane.go @@ -16,6 +16,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) @@ -25,8 +27,8 @@ import ( // is returned so it can be handled properly downstream. func createControlPlane( ctx context.Context, - sdk ControlPlaneSDK, - sdkGroups ControlPlaneGroupSDK, + sdk sdkops.ControlPlaneSDK, + sdkGroups sdkops.ControlPlaneGroupSDK, cl client.Client, cp *konnectv1alpha1.KonnectGatewayControlPlane, ) error { @@ -64,7 +66,7 @@ func createControlPlane( // It is assumed that the Konnect ControlPlane has a Konnect ID. func deleteControlPlane( ctx context.Context, - sdk ControlPlaneSDK, + sdk sdkops.ControlPlaneSDK, cp *konnectv1alpha1.KonnectGatewayControlPlane, ) error { id := cp.GetKonnectStatus().GetKonnectID() @@ -101,8 +103,8 @@ func deleteControlPlane( // be handled properly downstream. func updateControlPlane( ctx context.Context, - sdk ControlPlaneSDK, - sdkGroups ControlPlaneGroupSDK, + sdk sdkops.ControlPlaneSDK, + sdkGroups sdkops.ControlPlaneGroupSDK, cl client.Client, cp *konnectv1alpha1.KonnectGatewayControlPlane, ) error { @@ -159,7 +161,7 @@ func setGroupMembers( cl client.Client, cp *konnectv1alpha1.KonnectGatewayControlPlane, id string, - sdkGroups ControlPlaneGroupSDK, + sdkGroups sdkops.ControlPlaneGroupSDK, ) error { if len(cp.Spec.Members) == 0 || cp.Spec.ClusterType == nil || @@ -216,7 +218,7 @@ func (m membersByID) Swap(i, j int) { m[i], m[j] = m[j], m[i] } // that matches the UID of the provided KonnectGatewayControlPlane. func getControlPlaneForUID( ctx context.Context, - sdk ControlPlaneSDK, + sdk sdkops.ControlPlaneSDK, cp *konnectv1alpha1.KonnectGatewayControlPlane, ) (string, error) { reqList := sdkkonnectops.ListControlPlanesRequest{ diff --git a/controller/konnect/ops/ops_controlplane_test.go b/controller/konnect/ops/ops_controlplane_test.go index d05b94374..be4ec4ffb 100644 --- a/controller/konnect/ops/ops_controlplane_test.go +++ b/controller/konnect/ops/ops_controlplane_test.go @@ -20,6 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" @@ -33,7 +34,7 @@ func TestCreateControlPlane(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockCPTuple func(*testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) + mockCPTuple func(*testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) objects []client.Object expectedErrContains string expectedErrType error @@ -41,9 +42,9 @@ func TestCreateControlPlane(t *testing.T) { }{ { name: "success", - mockCPTuple: func(t *testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) - sdkGroups := NewMockControlPlaneGroupSDK(t) + mockCPTuple: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) + sdkGroups := sdkmocks.NewMockControlPlaneGroupSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ Spec: konnectv1alpha1.KonnectGatewayControlPlaneSpec{ CreateControlPlaneRequest: sdkkonnectcomp.CreateControlPlaneRequest{ @@ -72,9 +73,9 @@ func TestCreateControlPlane(t *testing.T) { }, { name: "fail", - mockCPTuple: func(t *testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) - sdkGroups := NewMockControlPlaneGroupSDK(t) + mockCPTuple: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) + sdkGroups := sdkmocks.NewMockControlPlaneGroupSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "cp-1", @@ -125,9 +126,9 @@ func TestCreateControlPlane(t *testing.T) { }, }, }, - mockCPTuple: func(t *testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) - sdkGroups := NewMockControlPlaneGroupSDK(t) + mockCPTuple: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) + sdkGroups := sdkmocks.NewMockControlPlaneGroupSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "cpg-1", @@ -194,9 +195,9 @@ func TestCreateControlPlane(t *testing.T) { }, }, }, - mockCPTuple: func(t *testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) - sdkGroups := NewMockControlPlaneGroupSDK(t) + mockCPTuple: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) + sdkGroups := sdkmocks.NewMockControlPlaneGroupSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "cpg-1", @@ -275,14 +276,14 @@ func TestDeleteControlPlane(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockCPPair func(*testing.T) (*MockControlPlaneSDK, *konnectv1alpha1.KonnectGatewayControlPlane) + mockCPPair func(*testing.T) (*sdkmocks.MockControlPlaneSDK, *konnectv1alpha1.KonnectGatewayControlPlane) expectedErr bool assertions func(*testing.T, *konnectv1alpha1.KonnectGatewayControlPlane) }{ { name: "success", - mockCPPair: func(t *testing.T) (*MockControlPlaneSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) + mockCPPair: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ Spec: konnectv1alpha1.KonnectGatewayControlPlaneSpec{ CreateControlPlaneRequest: sdkkonnectcomp.CreateControlPlaneRequest{ @@ -310,8 +311,8 @@ func TestDeleteControlPlane(t *testing.T) { }, { name: "fail", - mockCPPair: func(t *testing.T) (*MockControlPlaneSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) + mockCPPair: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "cp-1", @@ -345,8 +346,8 @@ func TestDeleteControlPlane(t *testing.T) { }, { name: "not found error is ignored and considered a success when trying to delete", - mockCPPair: func(t *testing.T) (*MockControlPlaneSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) + mockCPPair: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "cp-1", @@ -403,15 +404,15 @@ func TestUpdateControlPlane(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockCPTuple func(*testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) + mockCPTuple func(*testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) expectedErr bool expectedID string }{ { name: "success", - mockCPTuple: func(t *testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) - sdkGroups := NewMockControlPlaneGroupSDK(t) + mockCPTuple: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) + sdkGroups := sdkmocks.NewMockControlPlaneGroupSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ Spec: konnectv1alpha1.KonnectGatewayControlPlaneSpec{ CreateControlPlaneRequest: sdkkonnectcomp.CreateControlPlaneRequest{ @@ -450,9 +451,9 @@ func TestUpdateControlPlane(t *testing.T) { }, { name: "fail", - mockCPTuple: func(t *testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) - sdkGroups := NewMockControlPlaneGroupSDK(t) + mockCPTuple: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) + sdkGroups := sdkmocks.NewMockControlPlaneGroupSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "cp-1", @@ -495,9 +496,9 @@ func TestUpdateControlPlane(t *testing.T) { }, { name: "when not found then try to create", - mockCPTuple: func(t *testing.T) (*MockControlPlaneSDK, *MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { - sdk := NewMockControlPlaneSDK(t) - sdkGroups := NewMockControlPlaneGroupSDK(t) + mockCPTuple: func(t *testing.T) (*sdkmocks.MockControlPlaneSDK, *sdkmocks.MockControlPlaneGroupSDK, *konnectv1alpha1.KonnectGatewayControlPlane) { + sdk := sdkmocks.NewMockControlPlaneSDK(t) + sdkGroups := sdkmocks.NewMockControlPlaneGroupSDK(t) cp := &konnectv1alpha1.KonnectGatewayControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "cp-1", @@ -592,7 +593,7 @@ func TestCreateAndUpdateControlPlane_KubernetesMetadataConsistency(t *testing.T) }, }, } - sdk = NewMockSDKFactory(t) + sdk = sdkmocks.NewMockSDKFactory(t) sdkControlPlanes = sdk.SDK.ControlPlaneSDK fakeClient = fake.NewClientBuilder().Build() ) @@ -640,7 +641,7 @@ func TestSetGroupMembers(t *testing.T) { name string group *konnectv1alpha1.KonnectGatewayControlPlane cps []client.Object - sdk func(t *testing.T) *MockControlPlaneGroupSDK + sdk func(t *testing.T) *sdkmocks.MockControlPlaneGroupSDK expectedErr bool }{ { @@ -657,8 +658,8 @@ func TestSetGroupMembers(t *testing.T) { }, }, }, - sdk: func(t *testing.T) *MockControlPlaneGroupSDK { - sdk := NewMockControlPlaneGroupSDK(t) + sdk: func(t *testing.T) *sdkmocks.MockControlPlaneGroupSDK { + sdk := sdkmocks.NewMockControlPlaneGroupSDK(t) return sdk }, }, @@ -694,8 +695,8 @@ func TestSetGroupMembers(t *testing.T) { }, }, }, - sdk: func(t *testing.T) *MockControlPlaneGroupSDK { - sdk := NewMockControlPlaneGroupSDK(t) + sdk: func(t *testing.T) *sdkmocks.MockControlPlaneGroupSDK { + sdk := sdkmocks.NewMockControlPlaneGroupSDK(t) sdk.EXPECT(). PutControlPlanesIDGroupMemberships( mock.Anything, @@ -743,8 +744,8 @@ func TestSetGroupMembers(t *testing.T) { Status: konnectv1alpha1.KonnectGatewayControlPlaneStatus{}, }, }, - sdk: func(t *testing.T) *MockControlPlaneGroupSDK { - sdk := NewMockControlPlaneGroupSDK(t) + sdk: func(t *testing.T) *sdkmocks.MockControlPlaneGroupSDK { + sdk := sdkmocks.NewMockControlPlaneGroupSDK(t) return sdk }, expectedErr: true, @@ -795,8 +796,8 @@ func TestSetGroupMembers(t *testing.T) { }, }, }, - sdk: func(t *testing.T) *MockControlPlaneGroupSDK { - sdk := NewMockControlPlaneGroupSDK(t) + sdk: func(t *testing.T) *sdkmocks.MockControlPlaneGroupSDK { + sdk := sdkmocks.NewMockControlPlaneGroupSDK(t) sdk.EXPECT(). PutControlPlanesIDGroupMemberships( mock.Anything, @@ -860,8 +861,8 @@ func TestSetGroupMembers(t *testing.T) { }, }, }, - sdk: func(t *testing.T) *MockControlPlaneGroupSDK { - sdk := NewMockControlPlaneGroupSDK(t) + sdk: func(t *testing.T) *sdkmocks.MockControlPlaneGroupSDK { + sdk := sdkmocks.NewMockControlPlaneGroupSDK(t) return sdk }, expectedErr: true, diff --git a/controller/konnect/ops/ops_credentialacl.go b/controller/konnect/ops/ops_credentialacl.go index 8ac30a881..fe1266cd8 100644 --- a/controller/konnect/ops/ops_credentialacl.go +++ b/controller/konnect/ops/ops_credentialacl.go @@ -10,12 +10,14 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createKongCredentialACL( ctx context.Context, - sdk KongCredentialACLSDK, + sdk sdkops.KongCredentialACLSDK, cred *configurationv1alpha1.KongCredentialACL, ) error { cpID := cred.GetControlPlaneID() @@ -51,7 +53,7 @@ func createKongCredentialACL( // if the operation fails. func updateKongCredentialACL( ctx context.Context, - sdk KongCredentialACLSDK, + sdk sdkops.KongCredentialACLSDK, cred *configurationv1alpha1.KongCredentialACL, ) error { cpID := cred.GetControlPlaneID() @@ -106,7 +108,7 @@ func updateKongCredentialACL( // It returns an error if the operation fails. func deleteKongCredentialACL( ctx context.Context, - sdk KongCredentialACLSDK, + sdk sdkops.KongCredentialACLSDK, cred *configurationv1alpha1.KongCredentialACL, ) error { cpID := cred.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_credentialapikey.go b/controller/konnect/ops/ops_credentialapikey.go index 445fda564..e00758796 100644 --- a/controller/konnect/ops/ops_credentialapikey.go +++ b/controller/konnect/ops/ops_credentialapikey.go @@ -10,12 +10,14 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createKongCredentialAPIKey( ctx context.Context, - sdk KongCredentialAPIKeySDK, + sdk sdkops.KongCredentialAPIKeySDK, cred *configurationv1alpha1.KongCredentialAPIKey, ) error { cpID := cred.GetControlPlaneID() @@ -51,7 +53,7 @@ func createKongCredentialAPIKey( // if the operation fails. func updateKongCredentialAPIKey( ctx context.Context, - sdk KongCredentialAPIKeySDK, + sdk sdkops.KongCredentialAPIKeySDK, cred *configurationv1alpha1.KongCredentialAPIKey, ) error { cpID := cred.GetControlPlaneID() @@ -85,7 +87,7 @@ func updateKongCredentialAPIKey( // It returns an error if the operation fails. func deleteKongCredentialAPIKey( ctx context.Context, - sdk KongCredentialAPIKeySDK, + sdk sdkops.KongCredentialAPIKeySDK, cred *configurationv1alpha1.KongCredentialAPIKey, ) error { cpID := cred.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_credentialbasicauth.go b/controller/konnect/ops/ops_credentialbasicauth.go index cac1d77aa..05d5283bf 100644 --- a/controller/konnect/ops/ops_credentialbasicauth.go +++ b/controller/konnect/ops/ops_credentialbasicauth.go @@ -10,12 +10,14 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createKongCredentialBasicAuth( ctx context.Context, - sdk KongCredentialBasicAuthSDK, + sdk sdkops.KongCredentialBasicAuthSDK, cred *configurationv1alpha1.KongCredentialBasicAuth, ) error { cpID := cred.GetControlPlaneID() @@ -51,7 +53,7 @@ func createKongCredentialBasicAuth( // if the operation fails. func updateKongCredentialBasicAuth( ctx context.Context, - sdk KongCredentialBasicAuthSDK, + sdk sdkops.KongCredentialBasicAuthSDK, cred *configurationv1alpha1.KongCredentialBasicAuth, ) error { cpID := cred.GetControlPlaneID() @@ -84,7 +86,7 @@ func updateKongCredentialBasicAuth( // It returns an error if the operation fails. func deleteKongCredentialBasicAuth( ctx context.Context, - sdk KongCredentialBasicAuthSDK, + sdk sdkops.KongCredentialBasicAuthSDK, cred *configurationv1alpha1.KongCredentialBasicAuth, ) error { cpID := cred.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_credentialhmac.go b/controller/konnect/ops/ops_credentialhmac.go index 2a80c4af9..e9245467f 100644 --- a/controller/konnect/ops/ops_credentialhmac.go +++ b/controller/konnect/ops/ops_credentialhmac.go @@ -9,12 +9,14 @@ import ( sdkkonnecterrs "github.com/Kong/sdk-konnect-go/models/sdkerrors" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createKongCredentialHMAC( ctx context.Context, - sdk KongCredentialHMACSDK, + sdk sdkops.KongCredentialHMACSDK, cred *configurationv1alpha1.KongCredentialHMAC, ) error { cpID := cred.GetControlPlaneID() @@ -50,7 +52,7 @@ func createKongCredentialHMAC( // if the operation fails. func updateKongCredentialHMAC( ctx context.Context, - sdk KongCredentialHMACSDK, + sdk sdkops.KongCredentialHMACSDK, cred *configurationv1alpha1.KongCredentialHMAC, ) error { cpID := cred.GetControlPlaneID() @@ -105,7 +107,7 @@ func updateKongCredentialHMAC( // It returns an error if the operation fails. func deleteKongCredentialHMAC( ctx context.Context, - sdk KongCredentialHMACSDK, + sdk sdkops.KongCredentialHMACSDK, cred *configurationv1alpha1.KongCredentialHMAC, ) error { cpID := cred.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_credentialjwt.go b/controller/konnect/ops/ops_credentialjwt.go index 420a3a289..ade3486aa 100644 --- a/controller/konnect/ops/ops_credentialjwt.go +++ b/controller/konnect/ops/ops_credentialjwt.go @@ -9,12 +9,14 @@ import ( sdkkonnecterrs "github.com/Kong/sdk-konnect-go/models/sdkerrors" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createKongCredentialJWT( ctx context.Context, - sdk KongCredentialJWTSDK, + sdk sdkops.KongCredentialJWTSDK, cred *configurationv1alpha1.KongCredentialJWT, ) error { cpID := cred.GetControlPlaneID() @@ -50,7 +52,7 @@ func createKongCredentialJWT( // if the operation fails. func updateKongCredentialJWT( ctx context.Context, - sdk KongCredentialJWTSDK, + sdk sdkops.KongCredentialJWTSDK, cred *configurationv1alpha1.KongCredentialJWT, ) error { cpID := cred.GetControlPlaneID() @@ -105,7 +107,7 @@ func updateKongCredentialJWT( // It returns an error if the operation fails. func deleteKongCredentialJWT( ctx context.Context, - sdk KongCredentialJWTSDK, + sdk sdkops.KongCredentialJWTSDK, cred *configurationv1alpha1.KongCredentialJWT, ) error { cpID := cred.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_kongcacertificate.go b/controller/konnect/ops/ops_kongcacertificate.go index a56a8ef9c..b40a8fb1b 100644 --- a/controller/konnect/ops/ops_kongcacertificate.go +++ b/controller/konnect/ops/ops_kongcacertificate.go @@ -9,6 +9,8 @@ import ( sdkkonnecterrs "github.com/Kong/sdk-konnect-go/models/sdkerrors" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) @@ -16,7 +18,7 @@ import ( // It sets the KonnectID and the Programmed condition in the KongCACertificate status. func createCACertificate( ctx context.Context, - sdk CACertificatesSDK, + sdk sdkops.CACertificatesSDK, cert *configurationv1alpha1.KongCACertificate, ) error { cpID := cert.GetControlPlaneID() @@ -48,7 +50,7 @@ func createCACertificate( // It returns an error if the KongCACertificate does not have a KonnectID. func updateCACertificate( ctx context.Context, - sdk CACertificatesSDK, + sdk sdkops.CACertificatesSDK, cert *configurationv1alpha1.KongCACertificate, ) error { cpID := cert.GetControlPlaneID() @@ -82,7 +84,7 @@ func updateCACertificate( // It returns an error if the operation fails. func deleteCACertificate( ctx context.Context, - sdk CACertificatesSDK, + sdk sdkops.CACertificatesSDK, cert *configurationv1alpha1.KongCACertificate, ) error { id := cert.Status.Konnect.GetKonnectID() diff --git a/controller/konnect/ops/ops_kongcertificate.go b/controller/konnect/ops/ops_kongcertificate.go index 489856df1..bed709c46 100644 --- a/controller/konnect/ops/ops_kongcertificate.go +++ b/controller/konnect/ops/ops_kongcertificate.go @@ -9,6 +9,8 @@ import ( sdkkonnecterrs "github.com/Kong/sdk-konnect-go/models/sdkerrors" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) @@ -16,7 +18,7 @@ import ( // It sets the KonnectID and the Programmed condition in the KongCertificate status. func createCertificate( ctx context.Context, - sdk CertificatesSDK, + sdk sdkops.CertificatesSDK, cert *configurationv1alpha1.KongCertificate, ) error { cpID := cert.GetControlPlaneID() @@ -48,7 +50,7 @@ func createCertificate( // It returns an error if the KongCertificate does not have a KonnectID. func updateCertificate( ctx context.Context, - sdk CertificatesSDK, + sdk sdkops.CertificatesSDK, cert *configurationv1alpha1.KongCertificate, ) error { cpID := cert.GetControlPlaneID() @@ -103,7 +105,7 @@ func updateCertificate( // It returns an error if the operation fails. func deleteCertificate( ctx context.Context, - sdk CertificatesSDK, + sdk sdkops.CertificatesSDK, cert *configurationv1alpha1.KongCertificate, ) error { id := cert.Status.Konnect.GetKonnectID() diff --git a/controller/konnect/ops/ops_kongconsumer.go b/controller/konnect/ops/ops_kongconsumer.go index 9ad864be1..6894bc62a 100644 --- a/controller/konnect/ops/ops_kongconsumer.go +++ b/controller/konnect/ops/ops_kongconsumer.go @@ -15,6 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" "github.com/kong/gateway-operator/controller/pkg/log" "github.com/kong/gateway-operator/pkg/consts" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -26,8 +27,8 @@ import ( func createConsumer( ctx context.Context, - sdk ConsumersSDK, - cgSDK ConsumerGroupSDK, + sdk sdkops.ConsumersSDK, + cgSDK sdkops.ConsumerGroupSDK, cl client.Client, consumer *configurationv1.KongConsumer, ) error { @@ -69,8 +70,8 @@ func createConsumer( // It returns an error if the KongConsumer does not have a ControlPlaneRef. func updateConsumer( ctx context.Context, - sdk ConsumersSDK, - cgSDK ConsumerGroupSDK, + sdk sdkops.ConsumersSDK, + cgSDK sdkops.ConsumerGroupSDK, cl client.Client, consumer *configurationv1.KongConsumer, ) error { @@ -114,7 +115,7 @@ func handleConsumerGroupAssignments( ctx context.Context, consumer *configurationv1.KongConsumer, cl client.Client, - cgSDK ConsumerGroupSDK, + cgSDK sdkops.ConsumerGroupSDK, cpID string, ) error { // Resolve the Konnect IDs of the ConsumerGroups referenced by the KongConsumer. @@ -149,7 +150,7 @@ func handleConsumerGroupAssignments( func reconcileConsumerGroupsWithKonnect( ctx context.Context, desiredConsumerGroupsIDs []string, - cgSDK ConsumerGroupSDK, + cgSDK sdkops.ConsumerGroupSDK, cpID string, consumer *configurationv1.KongConsumer, ) error { @@ -292,7 +293,7 @@ func resolveConsumerGroupsKonnectIDs( // It returns an error if the operation fails. func deleteConsumer( ctx context.Context, - sdk ConsumersSDK, + sdk sdkops.ConsumersSDK, consumer *configurationv1.KongConsumer, ) error { id := consumer.Status.Konnect.GetKonnectID() @@ -335,7 +336,7 @@ func kongConsumerToSDKConsumerInput( // getKongConsumerForUID lists consumers in Konnect with given k8s uid as its tag. func getKongConsumerForUID( ctx context.Context, - sdk ConsumersSDK, + sdk sdkops.ConsumersSDK, consumer *configurationv1.KongConsumer, ) (string, error) { cpID := consumer.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_kongconsumergroup.go b/controller/konnect/ops/ops_kongconsumergroup.go index c0efd0834..f86c69e84 100644 --- a/controller/konnect/ops/ops_kongconsumergroup.go +++ b/controller/konnect/ops/ops_kongconsumergroup.go @@ -11,12 +11,14 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1beta1 "github.com/kong/kubernetes-configuration/api/configuration/v1beta1" ) func createConsumerGroup( ctx context.Context, - sdk ConsumerGroupSDK, + sdk sdkops.ConsumerGroupSDK, group *configurationv1beta1.KongConsumerGroup, ) error { if group.GetControlPlaneID() == "" { @@ -47,7 +49,7 @@ func createConsumerGroup( // It returns an error if the KongConsumerGroup does not have a ControlPlaneRef. func updateConsumerGroup( ctx context.Context, - sdk ConsumerGroupSDK, + sdk sdkops.ConsumerGroupSDK, group *configurationv1beta1.KongConsumerGroup, ) error { cpID := group.GetControlPlaneID() @@ -75,7 +77,7 @@ func updateConsumerGroup( // It returns an error if the operation fails. func deleteConsumerGroup( ctx context.Context, - sdk ConsumerGroupSDK, + sdk sdkops.ConsumerGroupSDK, consumer *configurationv1beta1.KongConsumerGroup, ) error { id := consumer.Status.Konnect.GetKonnectID() @@ -117,7 +119,7 @@ func kongConsumerGroupToSDKConsumerGroupInput( // getKongConsumerGroupForUID lists consumer groups in Konnect with given k8s uid as its tag. func getKongConsumerGroupForUID( ctx context.Context, - sdk ConsumerGroupSDK, + sdk sdkops.ConsumerGroupSDK, cg *configurationv1beta1.KongConsumerGroup, ) (string, error) { cpID := cg.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_kongdataplaneclientcertificate.go b/controller/konnect/ops/ops_kongdataplaneclientcertificate.go index d4d582eaf..bd7748e4f 100644 --- a/controller/konnect/ops/ops_kongdataplaneclientcertificate.go +++ b/controller/konnect/ops/ops_kongdataplaneclientcertificate.go @@ -8,6 +8,8 @@ import ( sdkkonnecterrs "github.com/Kong/sdk-konnect-go/models/sdkerrors" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) @@ -15,7 +17,7 @@ import ( // It sets the KonnectID and the Programmed condition in the KongDataPlaneClientCertificate status. func createKongDataPlaneClientCertificate( ctx context.Context, - sdk DataPlaneClientCertificatesSDK, + sdk sdkops.DataPlaneClientCertificatesSDK, cert *configurationv1alpha1.KongDataPlaneClientCertificate, ) error { cpID := cert.GetControlPlaneID() @@ -49,7 +51,7 @@ func createKongDataPlaneClientCertificate( // It returns an error if the operation fails. func deleteKongDataPlaneClientCertificate( ctx context.Context, - sdk DataPlaneClientCertificatesSDK, + sdk sdkops.DataPlaneClientCertificatesSDK, cert *configurationv1alpha1.KongDataPlaneClientCertificate, ) error { id := cert.Status.Konnect.GetKonnectID() diff --git a/controller/konnect/ops/ops_kongkey.go b/controller/konnect/ops/ops_kongkey.go index 4f2ce3a68..efe3d7e72 100644 --- a/controller/konnect/ops/ops_kongkey.go +++ b/controller/konnect/ops/ops_kongkey.go @@ -11,6 +11,8 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) @@ -18,7 +20,7 @@ import ( // It sets the KonnectID and the Programmed condition in the KongKey status. func createKey( ctx context.Context, - sdk KeysSDK, + sdk sdkops.KeysSDK, key *configurationv1alpha1.KongKey, ) error { cpID := key.GetControlPlaneID() @@ -52,7 +54,7 @@ func createKey( // It returns an error if the KongKey does not have a KonnectID. func updateKey( ctx context.Context, - sdk KeysSDK, + sdk sdkops.KeysSDK, key *configurationv1alpha1.KongKey, ) error { cpID := key.GetControlPlaneID() @@ -99,7 +101,7 @@ func updateKey( // It returns an error if the operation fails. func deleteKey( ctx context.Context, - sdk KeysSDK, + sdk sdkops.KeysSDK, key *configurationv1alpha1.KongKey, ) error { id := key.Status.Konnect.GetKonnectID() @@ -153,7 +155,7 @@ func kongKeyToKeyInput(key *configurationv1alpha1.KongKey) sdkkonnectcomp.KeyInp func getKongKeyForUID( ctx context.Context, - sdk KeysSDK, + sdk sdkops.KeysSDK, key *configurationv1alpha1.KongKey, ) (string, error) { resp, err := sdk.ListKey(ctx, sdkkonnectops.ListKeyRequest{ diff --git a/controller/konnect/ops/ops_kongkeyset.go b/controller/konnect/ops/ops_kongkeyset.go index 5809a72ee..a0038555c 100644 --- a/controller/konnect/ops/ops_kongkeyset.go +++ b/controller/konnect/ops/ops_kongkeyset.go @@ -11,6 +11,8 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) @@ -18,7 +20,7 @@ import ( // It sets the KonnectID and the Programmed condition in the KongKeySet status. func createKeySet( ctx context.Context, - sdk KeySetsSDK, + sdk sdkops.KeySetsSDK, keySet *configurationv1alpha1.KongKeySet, ) error { cpID := keySet.GetControlPlaneID() @@ -53,7 +55,7 @@ func createKeySet( // It returns an error if the KongKeySet does not have a KonnectID. func updateKeySet( ctx context.Context, - sdk KeySetsSDK, + sdk sdkops.KeySetsSDK, keySet *configurationv1alpha1.KongKeySet, ) error { cpID := keySet.GetControlPlaneID() @@ -100,7 +102,7 @@ func updateKeySet( // It returns an error if the operation fails. func deleteKeySet( ctx context.Context, - sdk KeySetsSDK, + sdk sdkops.KeySetsSDK, keySet *configurationv1alpha1.KongKeySet, ) error { id := keySet.Status.Konnect.GetKonnectID() @@ -138,7 +140,7 @@ func kongKeySetToKeySetInput(keySet *configurationv1alpha1.KongKeySet) sdkkonnec func getKongKeySetForUID( ctx context.Context, - sdk KeySetsSDK, + sdk sdkops.KeySetsSDK, keySet *configurationv1alpha1.KongKeySet, ) (string, error) { resp, err := sdk.ListKeySet(ctx, sdkkonnectops.ListKeySetRequest{ diff --git a/controller/konnect/ops/ops_kongpluginbinding.go b/controller/konnect/ops/ops_kongpluginbinding.go index d076270c0..c035d5143 100644 --- a/controller/konnect/ops/ops_kongpluginbinding.go +++ b/controller/konnect/ops/ops_kongpluginbinding.go @@ -14,6 +14,7 @@ import ( ctrllog "sigs.k8s.io/controller-runtime/pkg/log" "github.com/kong/gateway-operator/controller/konnect/constraints" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" configurationv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" @@ -29,7 +30,7 @@ import ( func createPlugin( ctx context.Context, cl client.Client, - sdk PluginSDK, + sdk sdkops.PluginSDK, pluginBinding *configurationv1alpha1.KongPluginBinding, ) error { controlPlaneID := pluginBinding.GetControlPlaneID() @@ -66,7 +67,7 @@ func createPlugin( // if the operation fails. func updatePlugin( ctx context.Context, - sdk PluginSDK, + sdk sdkops.PluginSDK, cl client.Client, pb *configurationv1alpha1.KongPluginBinding, ) error { @@ -105,7 +106,7 @@ func updatePlugin( // It returns an error if the operation fails. func deletePlugin( ctx context.Context, - sdk PluginSDK, + sdk sdkops.PluginSDK, pb *configurationv1alpha1.KongPluginBinding, ) error { id := pb.GetKonnectID() @@ -132,7 +133,7 @@ func deletePlugin( // getPluginForUID lists plugins in Konnect with given k8s uid as its tag. func getPluginForUID( ctx context.Context, - sdk PluginSDK, + sdk sdkops.PluginSDK, pluginBinding *configurationv1alpha1.KongPluginBinding, ) (string, error) { cpID := pluginBinding.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_kongroute.go b/controller/konnect/ops/ops_kongroute.go index c65c6f23b..6d2b69f12 100644 --- a/controller/konnect/ops/ops_kongroute.go +++ b/controller/konnect/ops/ops_kongroute.go @@ -12,12 +12,14 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createRoute( ctx context.Context, - sdk RoutesSDK, + sdk sdkops.RoutesSDK, route *configurationv1alpha1.KongRoute, ) error { if route.GetControlPlaneID() == "" { @@ -45,7 +47,7 @@ func createRoute( // if the operation fails. func updateRoute( ctx context.Context, - sdk RoutesSDK, + sdk sdkops.RoutesSDK, route *configurationv1alpha1.KongRoute, ) error { cpID := route.GetControlPlaneID() @@ -93,7 +95,7 @@ func updateRoute( // It returns an error if the operation fails. func deleteRoute( ctx context.Context, - sdk RoutesSDK, + sdk sdkops.RoutesSDK, route *configurationv1alpha1.KongRoute, ) error { id := route.GetKonnectStatus().GetKonnectID() @@ -157,7 +159,7 @@ func kongRouteToSDKRouteInput( // that matches the UID of the provided KongRoute. func getKongRouteForUID( ctx context.Context, - sdk RoutesSDK, + sdk sdkops.RoutesSDK, r *configurationv1alpha1.KongRoute, ) (string, error) { reqList := sdkkonnectops.ListRouteRequest{ diff --git a/controller/konnect/ops/ops_kongservice.go b/controller/konnect/ops/ops_kongservice.go index f4f77490a..6ebef8454 100644 --- a/controller/konnect/ops/ops_kongservice.go +++ b/controller/konnect/ops/ops_kongservice.go @@ -11,12 +11,14 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createService( ctx context.Context, - sdk ServicesSDK, + sdk sdkops.ServicesSDK, svc *configurationv1alpha1.KongService, ) error { if svc.GetControlPlaneID() == "" { @@ -47,7 +49,7 @@ func createService( // if the operation fails. func updateService( ctx context.Context, - sdk ServicesSDK, + sdk sdkops.ServicesSDK, svc *configurationv1alpha1.KongService, ) error { if svc.GetControlPlaneID() == "" { @@ -97,7 +99,7 @@ func updateService( // It returns an error if the operation fails. func deleteService( ctx context.Context, - sdk ServicesSDK, + sdk sdkops.ServicesSDK, svc *configurationv1alpha1.KongService, ) error { id := svc.GetKonnectStatus().GetKonnectID() @@ -154,7 +156,7 @@ func kongServiceToSDKServiceInput( // that matches the UID of the provided KongService. func getKongServiceForUID( ctx context.Context, - sdk ServicesSDK, + sdk sdkops.ServicesSDK, svc *configurationv1alpha1.KongService, ) (string, error) { reqList := sdkkonnectops.ListServiceRequest{ diff --git a/controller/konnect/ops/ops_kongservice_test.go b/controller/konnect/ops/ops_kongservice_test.go index 214b94739..09a96449e 100644 --- a/controller/konnect/ops/ops_kongservice_test.go +++ b/controller/konnect/ops/ops_kongservice_test.go @@ -15,6 +15,7 @@ import ( k8stypes "k8s.io/apimachinery/pkg/types" konnectconsts "github.com/kong/gateway-operator/controller/konnect/consts" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" @@ -24,15 +25,15 @@ func TestCreateKongService(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockServicePair func(*testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) + mockServicePair func(*testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) assertions func(*testing.T, *configurationv1alpha1.KongService) expectedErrContains string expectedErrType error }{ { name: "success", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -73,8 +74,8 @@ func TestCreateKongService(t *testing.T) { }, { name: "fail - no control plane ID in status returns an error and does not create the Service in Konnect", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -97,8 +98,8 @@ func TestCreateKongService(t *testing.T) { }, { name: "fail", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -137,8 +138,8 @@ func TestCreateKongService(t *testing.T) { }, { name: "409 Conflict causes a list to find a matching (by UID) service and update it instead of creating a new one", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -202,14 +203,14 @@ func TestDeleteKongService(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockServicePair func(*testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) + mockServicePair func(*testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) expectedErr bool assertions func(*testing.T, *configurationv1alpha1.KongService) }{ { name: "success", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ Spec: configurationv1alpha1.KongServiceSpec{ KongServiceAPISpec: configurationv1alpha1.KongServiceAPISpec{ @@ -240,8 +241,8 @@ func TestDeleteKongService(t *testing.T) { }, { name: "fail", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ Spec: configurationv1alpha1.KongServiceSpec{ KongServiceAPISpec: configurationv1alpha1.KongServiceAPISpec{ @@ -274,8 +275,8 @@ func TestDeleteKongService(t *testing.T) { }, { name: "not found error is ignored and considered a success when trying to delete", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ Spec: configurationv1alpha1.KongServiceSpec{ KongServiceAPISpec: configurationv1alpha1.KongServiceAPISpec{ @@ -331,14 +332,14 @@ func TestUpdateKongService(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockServicePair func(*testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) + mockServicePair func(*testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) expectedErr bool assertions func(*testing.T, *configurationv1alpha1.KongService) }{ { name: "success", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ Spec: configurationv1alpha1.KongServiceSpec{ KongServiceAPISpec: configurationv1alpha1.KongServiceAPISpec{ @@ -382,8 +383,8 @@ func TestUpdateKongService(t *testing.T) { }, { name: "fail", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -429,8 +430,8 @@ func TestUpdateKongService(t *testing.T) { }, { name: "when not found then try to create", - mockServicePair: func(t *testing.T) (*MockServicesSDK, *configurationv1alpha1.KongService) { - sdk := NewMockServicesSDK(t) + mockServicePair: func(t *testing.T) (*sdkmocks.MockServicesSDK, *configurationv1alpha1.KongService) { + sdk := sdkmocks.NewMockServicesSDK(t) svc := &configurationv1alpha1.KongService{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", diff --git a/controller/konnect/ops/ops_kongsni.go b/controller/konnect/ops/ops_kongsni.go index f6a276e88..0082370a9 100644 --- a/controller/konnect/ops/ops_kongsni.go +++ b/controller/konnect/ops/ops_kongsni.go @@ -13,12 +13,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createSNI( ctx context.Context, - sdk SNIsSDK, + sdk sdkops.SNIsSDK, sni *configurationv1alpha1.KongSNI, ) error { cpID := sni.GetControlPlaneID() @@ -50,7 +52,7 @@ func createSNI( func updateSNI( ctx context.Context, - sdk SNIsSDK, + sdk sdkops.SNIsSDK, sni *configurationv1alpha1.KongSNI, ) error { cpID := sni.GetControlPlaneID() @@ -104,7 +106,7 @@ func updateSNI( func deleteSNI( ctx context.Context, - sdk SNIsSDK, + sdk sdkops.SNIsSDK, sni *configurationv1alpha1.KongSNI, ) error { cpID := sni.GetControlPlaneID() @@ -155,7 +157,7 @@ func kongSNIToSNIWithoutParents(sni *configurationv1alpha1.KongSNI) sdkkonnectco } // getKongSNIForUID returns the Konnect ID of the Konnect SNI that matches the UID of the provided SNI. -func getKongSNIForUID(ctx context.Context, sdk SNIsSDK, sni *configurationv1alpha1.KongSNI) (string, error) { +func getKongSNIForUID(ctx context.Context, sdk sdkops.SNIsSDK, sni *configurationv1alpha1.KongSNI) (string, error) { resp, err := sdk.ListSni(ctx, sdkkonnectops.ListSniRequest{ ControlPlaneID: sni.GetControlPlaneID(), Tags: lo.ToPtr(UIDLabelForObject(sni)), diff --git a/controller/konnect/ops/ops_kongtarget.go b/controller/konnect/ops/ops_kongtarget.go index 1addec4b3..b38177d4e 100644 --- a/controller/konnect/ops/ops_kongtarget.go +++ b/controller/konnect/ops/ops_kongtarget.go @@ -13,12 +13,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createTarget( ctx context.Context, - sdk TargetsSDK, + sdk sdkops.TargetsSDK, target *configurationv1alpha1.KongTarget, ) error { cpID := target.GetControlPlaneID() @@ -51,7 +53,7 @@ func createTarget( func updateTarget( ctx context.Context, - sdk TargetsSDK, + sdk sdkops.TargetsSDK, target *configurationv1alpha1.KongTarget, ) error { cpID := target.GetControlPlaneID() @@ -78,7 +80,7 @@ func updateTarget( func deleteTarget( ctx context.Context, - sdk TargetsSDK, + sdk sdkops.TargetsSDK, target *configurationv1alpha1.KongTarget, ) error { cpID := target.GetControlPlaneID() @@ -133,7 +135,7 @@ func kongTargetToTargetWithoutParents(target *configurationv1alpha1.KongTarget) // that matches the UID of the provided KongTarget. func getKongTargetForUID( ctx context.Context, - sdk TargetsSDK, + sdk sdkops.TargetsSDK, target *configurationv1alpha1.KongTarget, ) (string, error) { reqList := sdkkonnectops.ListTargetWithUpstreamRequest{ diff --git a/controller/konnect/ops/ops_kongupstream.go b/controller/konnect/ops/ops_kongupstream.go index 9652bcd6f..65980cee0 100644 --- a/controller/konnect/ops/ops_kongupstream.go +++ b/controller/konnect/ops/ops_kongupstream.go @@ -11,12 +11,14 @@ import ( "github.com/samber/lo" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) func createUpstream( ctx context.Context, - sdk UpstreamsSDK, + sdk sdkops.UpstreamsSDK, upstream *configurationv1alpha1.KongUpstream, ) error { if upstream.GetControlPlaneID() == "" { @@ -47,7 +49,7 @@ func createUpstream( // if the operation fails. func updateUpstream( ctx context.Context, - sdk UpstreamsSDK, + sdk sdkops.UpstreamsSDK, upstream *configurationv1alpha1.KongUpstream, ) error { if upstream.GetControlPlaneID() == "" { @@ -97,7 +99,7 @@ func updateUpstream( // It returns an error if the operation fails. func deleteUpstream( ctx context.Context, - sdk UpstreamsSDK, + sdk sdkops.UpstreamsSDK, svc *configurationv1alpha1.KongUpstream, ) error { id := svc.GetKonnectStatus().GetKonnectID() @@ -157,7 +159,7 @@ func kongUpstreamToSDKUpstreamInput( // getKongUpstreamForUID lists upstreams in Konnect with given k8s uid as its tag. func getKongUpstreamForUID( ctx context.Context, - sdk UpstreamsSDK, + sdk sdkops.UpstreamsSDK, u *configurationv1alpha1.KongUpstream, ) (string, error) { cpID := u.GetControlPlaneID() diff --git a/controller/konnect/ops/ops_kongupstream_test.go b/controller/konnect/ops/ops_kongupstream_test.go index 0b1f71cfc..77bfe8e1d 100644 --- a/controller/konnect/ops/ops_kongupstream_test.go +++ b/controller/konnect/ops/ops_kongupstream_test.go @@ -15,6 +15,7 @@ import ( k8stypes "k8s.io/apimachinery/pkg/types" konnectconsts "github.com/kong/gateway-operator/controller/konnect/consts" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" @@ -24,14 +25,14 @@ func TestCreateKongUpstream(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockUpstreamPair func(*testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) + mockUpstreamPair func(*testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) expectedErr bool assertions func(*testing.T, *configurationv1alpha1.KongUpstream) }{ { name: "success", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -70,8 +71,8 @@ func TestCreateKongUpstream(t *testing.T) { }, { name: "fail - no control plane ID in status returns an error and does not create the Upstream in Konnect", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -94,8 +95,8 @@ func TestCreateKongUpstream(t *testing.T) { }, { name: "fail", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -155,14 +156,14 @@ func TestDeleteKongUpstream(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockUpstreamPair func(*testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) + mockUpstreamPair func(*testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) expectedErr bool assertions func(*testing.T, *configurationv1alpha1.KongUpstream) }{ { name: "success", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ Spec: configurationv1alpha1.KongUpstreamSpec{ KongUpstreamAPISpec: configurationv1alpha1.KongUpstreamAPISpec{ @@ -193,8 +194,8 @@ func TestDeleteKongUpstream(t *testing.T) { }, { name: "fail", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ Spec: configurationv1alpha1.KongUpstreamSpec{ KongUpstreamAPISpec: configurationv1alpha1.KongUpstreamAPISpec{ @@ -227,8 +228,8 @@ func TestDeleteKongUpstream(t *testing.T) { }, { name: "not found error is ignored and considered a success when trying to delete", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ Spec: configurationv1alpha1.KongUpstreamSpec{ KongUpstreamAPISpec: configurationv1alpha1.KongUpstreamAPISpec{ @@ -284,14 +285,14 @@ func TestUpdateKongUpstream(t *testing.T) { ctx := context.Background() testCases := []struct { name string - mockUpstreamPair func(*testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) + mockUpstreamPair func(*testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) expectedErr bool assertions func(*testing.T, *configurationv1alpha1.KongUpstream) }{ { name: "success", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ Spec: configurationv1alpha1.KongUpstreamSpec{ KongUpstreamAPISpec: configurationv1alpha1.KongUpstreamAPISpec{ @@ -335,8 +336,8 @@ func TestUpdateKongUpstream(t *testing.T) { }, { name: "fail", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", @@ -384,8 +385,8 @@ func TestUpdateKongUpstream(t *testing.T) { }, { name: "when not found then try to create", - mockUpstreamPair: func(t *testing.T) (*MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { - sdk := NewMockUpstreamsSDK(t) + mockUpstreamPair: func(t *testing.T) (*sdkmocks.MockUpstreamsSDK, *configurationv1alpha1.KongUpstream) { + sdk := sdkmocks.NewMockUpstreamsSDK(t) svc := &configurationv1alpha1.KongUpstream{ ObjectMeta: metav1.ObjectMeta{ Name: "svc-1", diff --git a/controller/konnect/ops/ops_kongvault.go b/controller/konnect/ops/ops_kongvault.go index 7a0efd5c2..d49e22162 100644 --- a/controller/konnect/ops/ops_kongvault.go +++ b/controller/konnect/ops/ops_kongvault.go @@ -13,10 +13,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" ) -func createVault(ctx context.Context, sdk VaultSDK, vault *configurationv1alpha1.KongVault) error { +func createVault(ctx context.Context, sdk sdkops.VaultSDK, vault *configurationv1alpha1.KongVault) error { cpID := vault.GetControlPlaneID() if cpID == "" { return CantPerformOperationWithoutControlPlaneIDError{Entity: vault, Op: CreateOp} @@ -40,7 +42,7 @@ func createVault(ctx context.Context, sdk VaultSDK, vault *configurationv1alpha1 return nil } -func updateVault(ctx context.Context, sdk VaultSDK, vault *configurationv1alpha1.KongVault) error { +func updateVault(ctx context.Context, sdk sdkops.VaultSDK, vault *configurationv1alpha1.KongVault) error { cpID := vault.GetControlPlaneID() if cpID == "" { return CantPerformOperationWithoutControlPlaneIDError{Entity: vault, Op: UpdateOp} @@ -86,7 +88,7 @@ func updateVault(ctx context.Context, sdk VaultSDK, vault *configurationv1alpha1 return nil } -func deleteVault(ctx context.Context, sdk VaultSDK, vault *configurationv1alpha1.KongVault) error { +func deleteVault(ctx context.Context, sdk sdkops.VaultSDK, vault *configurationv1alpha1.KongVault) error { cpID := vault.GetControlPlaneID() if cpID == "" { return fmt.Errorf( @@ -143,7 +145,7 @@ func kongVaultToVaultInput(vault *configurationv1alpha1.KongVault) (sdkkonnectco func getKongVaultForUID( ctx context.Context, - sdk VaultSDK, + sdk sdkops.VaultSDK, vault *configurationv1alpha1.KongVault, ) (string, error) { resp, err := sdk.ListVault(ctx, sdkkonnectops.ListVaultRequest{ diff --git a/controller/konnect/ops/ops_kongvault_test.go b/controller/konnect/ops/ops_kongvault_test.go index bf7535693..8a2974a63 100644 --- a/controller/konnect/ops/ops_kongvault_test.go +++ b/controller/konnect/ops/ops_kongvault_test.go @@ -15,6 +15,8 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) @@ -29,14 +31,14 @@ func mustConvertKongVaultToVaultInput(t *testing.T, vault *configurationv1alpha1 func TestCreateKongVault(t *testing.T) { testCases := []struct { name string - mockVaultPair func(*testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) + mockVaultPair func(*testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) expectedErr bool assertions func(*testing.T, *configurationv1alpha1.KongVault) }{ { name: "success", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { - sdk := NewMockVaultSDK(t) + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { + sdk := sdkmocks.NewMockVaultSDK(t) vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-1", @@ -73,7 +75,7 @@ func TestCreateKongVault(t *testing.T) { }, { name: "failed - no control plane ID in Konnect status", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-no-cpid", @@ -87,7 +89,7 @@ func TestCreateKongVault(t *testing.T) { }, Status: configurationv1alpha1.KongVaultStatus{}, } - return NewMockVaultSDK(t), vault + return sdkmocks.NewMockVaultSDK(t), vault }, expectedErr: true, assertions: func(t *testing.T, vault *configurationv1alpha1.KongVault) { @@ -96,8 +98,8 @@ func TestCreateKongVault(t *testing.T) { }, { name: "fail - upstream returns non-OK response", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { - sdk := NewMockVaultSDK(t) + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { + sdk := sdkmocks.NewMockVaultSDK(t) vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-1", @@ -152,14 +154,14 @@ func TestCreateKongVault(t *testing.T) { func TestUpdateKongVault(t *testing.T) { testCases := []struct { name string - mockVaultPair func(*testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) + mockVaultPair func(*testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) expectedErr bool assertions func(*testing.T, *configurationv1alpha1.KongVault) }{ { name: "success", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { - sdk := NewMockVaultSDK(t) + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { + sdk := sdkmocks.NewMockVaultSDK(t) vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-1", @@ -205,8 +207,8 @@ func TestUpdateKongVault(t *testing.T) { }, { name: "fail - upstream returns non-OK response", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { - sdk := NewMockVaultSDK(t) + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { + sdk := sdkmocks.NewMockVaultSDK(t) vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-1", @@ -246,8 +248,8 @@ func TestUpdateKongVault(t *testing.T) { }, { name: "try to create when not found", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { - sdk := NewMockVaultSDK(t) + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { + sdk := sdkmocks.NewMockVaultSDK(t) vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-1", @@ -314,13 +316,13 @@ func TestUpdateKongVault(t *testing.T) { func TestDeleteKongVault(t *testing.T) { testCases := []struct { name string - mockVaultPair func(*testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) + mockVaultPair func(*testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) expectedErr bool }{ { name: "success", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { - sdk := NewMockVaultSDK(t) + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { + sdk := sdkmocks.NewMockVaultSDK(t) vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-1", @@ -343,8 +345,8 @@ func TestDeleteKongVault(t *testing.T) { }, { name: "fail", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { - sdk := NewMockVaultSDK(t) + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { + sdk := sdkmocks.NewMockVaultSDK(t) vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-1", @@ -370,8 +372,8 @@ func TestDeleteKongVault(t *testing.T) { }, { name: "not found error treated as successful delete", - mockVaultPair: func(t *testing.T) (*MockVaultSDK, *configurationv1alpha1.KongVault) { - sdk := NewMockVaultSDK(t) + mockVaultPair: func(t *testing.T) (*sdkmocks.MockVaultSDK, *configurationv1alpha1.KongVault) { + sdk := sdkmocks.NewMockVaultSDK(t) vault := &configurationv1alpha1.KongVault{ ObjectMeta: metav1.ObjectMeta{ Name: "vault-1", diff --git a/controller/konnect/ops/controlplane.go b/controller/konnect/ops/sdk/controlplane.go similarity index 98% rename from controller/konnect/ops/controlplane.go rename to controller/konnect/ops/sdk/controlplane.go index 4424845df..9e362b84f 100644 --- a/controller/konnect/ops/controlplane.go +++ b/controller/konnect/ops/sdk/controlplane.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/controlplanegroup.go b/controller/konnect/ops/sdk/controlplanegroup.go similarity index 97% rename from controller/konnect/ops/controlplanegroup.go rename to controller/konnect/ops/sdk/controlplanegroup.go index ff125f47b..d0ef2bc38 100644 --- a/controller/konnect/ops/controlplanegroup.go +++ b/controller/konnect/ops/sdk/controlplanegroup.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/credentialacl.go b/controller/konnect/ops/sdk/credentialacl.go similarity index 98% rename from controller/konnect/ops/credentialacl.go rename to controller/konnect/ops/sdk/credentialacl.go index 18806baf3..0f5ce006b 100644 --- a/controller/konnect/ops/credentialacl.go +++ b/controller/konnect/ops/sdk/credentialacl.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/credentialapikey.go b/controller/konnect/ops/sdk/credentialapikey.go similarity index 98% rename from controller/konnect/ops/credentialapikey.go rename to controller/konnect/ops/sdk/credentialapikey.go index 5ce5c8e70..ecd87ce03 100644 --- a/controller/konnect/ops/credentialapikey.go +++ b/controller/konnect/ops/sdk/credentialapikey.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/credentialbasicauth.go b/controller/konnect/ops/sdk/credentialbasicauth.go similarity index 98% rename from controller/konnect/ops/credentialbasicauth.go rename to controller/konnect/ops/sdk/credentialbasicauth.go index bb5b2e320..9e4c68d0e 100644 --- a/controller/konnect/ops/credentialbasicauth.go +++ b/controller/konnect/ops/sdk/credentialbasicauth.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/credentialhmac.go b/controller/konnect/ops/sdk/credentialhmac.go similarity index 98% rename from controller/konnect/ops/credentialhmac.go rename to controller/konnect/ops/sdk/credentialhmac.go index b2f95b076..17533bf93 100644 --- a/controller/konnect/ops/credentialhmac.go +++ b/controller/konnect/ops/sdk/credentialhmac.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/credentialjwt.go b/controller/konnect/ops/sdk/credentialjwt.go similarity index 98% rename from controller/konnect/ops/credentialjwt.go rename to controller/konnect/ops/sdk/credentialjwt.go index d7a0599d7..c714f6a21 100644 --- a/controller/konnect/ops/credentialjwt.go +++ b/controller/konnect/ops/sdk/credentialjwt.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongcacertificate.go b/controller/konnect/ops/sdk/kongcacertificate.go similarity index 98% rename from controller/konnect/ops/kongcacertificate.go rename to controller/konnect/ops/sdk/kongcacertificate.go index 01e339c65..ff1b4f699 100644 --- a/controller/konnect/ops/kongcacertificate.go +++ b/controller/konnect/ops/sdk/kongcacertificate.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongcertificate.go b/controller/konnect/ops/sdk/kongcertificate.go similarity index 98% rename from controller/konnect/ops/kongcertificate.go rename to controller/konnect/ops/sdk/kongcertificate.go index 3e5fa2cfe..564ccae02 100644 --- a/controller/konnect/ops/kongcertificate.go +++ b/controller/konnect/ops/sdk/kongcertificate.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongconsumer.go b/controller/konnect/ops/sdk/kongconsumer.go similarity index 98% rename from controller/konnect/ops/kongconsumer.go rename to controller/konnect/ops/sdk/kongconsumer.go index 106e5cf3f..60a15b115 100644 --- a/controller/konnect/ops/kongconsumer.go +++ b/controller/konnect/ops/sdk/kongconsumer.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongconsumergroup.go b/controller/konnect/ops/sdk/kongconsumergroup.go similarity index 99% rename from controller/konnect/ops/kongconsumergroup.go rename to controller/konnect/ops/sdk/kongconsumergroup.go index 027890d76..932caf525 100644 --- a/controller/konnect/ops/kongconsumergroup.go +++ b/controller/konnect/ops/sdk/kongconsumergroup.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongdataplanecertificate.go b/controller/konnect/ops/sdk/kongdataplanecertificate.go similarity index 98% rename from controller/konnect/ops/kongdataplanecertificate.go rename to controller/konnect/ops/sdk/kongdataplanecertificate.go index b77fdd837..387c3feb8 100644 --- a/controller/konnect/ops/kongdataplanecertificate.go +++ b/controller/konnect/ops/sdk/kongdataplanecertificate.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongkey.go b/controller/konnect/ops/sdk/kongkey.go similarity index 98% rename from controller/konnect/ops/kongkey.go rename to controller/konnect/ops/sdk/kongkey.go index 37a8f5adb..df75c8880 100644 --- a/controller/konnect/ops/kongkey.go +++ b/controller/konnect/ops/sdk/kongkey.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongkeyset.go b/controller/konnect/ops/sdk/kongkeyset.go similarity index 98% rename from controller/konnect/ops/kongkeyset.go rename to controller/konnect/ops/sdk/kongkeyset.go index 0ec19c83f..13efef839 100644 --- a/controller/konnect/ops/kongkeyset.go +++ b/controller/konnect/ops/sdk/kongkeyset.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongroute.go b/controller/konnect/ops/sdk/kongroute.go similarity index 98% rename from controller/konnect/ops/kongroute.go rename to controller/konnect/ops/sdk/kongroute.go index 08cb761ae..f6ede2889 100644 --- a/controller/konnect/ops/kongroute.go +++ b/controller/konnect/ops/sdk/kongroute.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongservice.go b/controller/konnect/ops/sdk/kongservice.go similarity index 98% rename from controller/konnect/ops/kongservice.go rename to controller/konnect/ops/sdk/kongservice.go index f5a7702eb..a997b0a9b 100644 --- a/controller/konnect/ops/kongservice.go +++ b/controller/konnect/ops/sdk/kongservice.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongsni.go b/controller/konnect/ops/sdk/kongsni.go similarity index 98% rename from controller/konnect/ops/kongsni.go rename to controller/konnect/ops/sdk/kongsni.go index 530111e7f..1689edf58 100644 --- a/controller/konnect/ops/kongsni.go +++ b/controller/konnect/ops/sdk/kongsni.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongtarget.go b/controller/konnect/ops/sdk/kongtarget.go similarity index 98% rename from controller/konnect/ops/kongtarget.go rename to controller/konnect/ops/sdk/kongtarget.go index d8411e18f..a7969ac60 100644 --- a/controller/konnect/ops/kongtarget.go +++ b/controller/konnect/ops/sdk/kongtarget.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongupstream.go b/controller/konnect/ops/sdk/kongupstream.go similarity index 98% rename from controller/konnect/ops/kongupstream.go rename to controller/konnect/ops/sdk/kongupstream.go index 3b15fe1f4..a843a9d1c 100644 --- a/controller/konnect/ops/kongupstream.go +++ b/controller/konnect/ops/sdk/kongupstream.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/kongvault.go b/controller/konnect/ops/sdk/kongvault.go similarity index 98% rename from controller/konnect/ops/kongvault.go rename to controller/konnect/ops/sdk/kongvault.go index d3d140977..f34454bdf 100644 --- a/controller/konnect/ops/kongvault.go +++ b/controller/konnect/ops/sdk/kongvault.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/me.go b/controller/konnect/ops/sdk/me.go similarity index 96% rename from controller/konnect/ops/me.go rename to controller/konnect/ops/sdk/me.go index 12f79c72e..59deb9774 100644 --- a/controller/konnect/ops/me.go +++ b/controller/konnect/ops/sdk/me.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/sdkfactory_mock.go b/controller/konnect/ops/sdk/mocks/sdkfactory_mock.go similarity index 66% rename from controller/konnect/ops/sdkfactory_mock.go rename to controller/konnect/ops/sdk/mocks/sdkfactory_mock.go index d06724084..a5714c932 100644 --- a/controller/konnect/ops/sdkfactory_mock.go +++ b/controller/konnect/ops/sdk/mocks/sdkfactory_mock.go @@ -1,9 +1,11 @@ -package ops +package mocks import ( "testing" "github.com/stretchr/testify/require" + + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" ) type MockSDKWrapper struct { @@ -31,7 +33,7 @@ type MockSDKWrapper struct { DataPlaneCertificatesSDK *MockDataPlaneClientCertificatesSDK } -var _ SDKWrapper = MockSDKWrapper{} +var _ sdkops.SDKWrapper = MockSDKWrapper{} func NewMockSDKWrapperWithT(t *testing.T) *MockSDKWrapper { return &MockSDKWrapper{ @@ -60,91 +62,91 @@ func NewMockSDKWrapperWithT(t *testing.T) *MockSDKWrapper { } } -func (m MockSDKWrapper) GetControlPlaneSDK() ControlPlaneSDK { +func (m MockSDKWrapper) GetControlPlaneSDK() sdkops.ControlPlaneSDK { return m.ControlPlaneSDK } -func (m MockSDKWrapper) GetControlPlaneGroupSDK() ControlPlaneGroupSDK { +func (m MockSDKWrapper) GetControlPlaneGroupSDK() sdkops.ControlPlaneGroupSDK { return m.ControlPlaneGroupSDK } -func (m MockSDKWrapper) GetServicesSDK() ServicesSDK { +func (m MockSDKWrapper) GetServicesSDK() sdkops.ServicesSDK { return m.ServicesSDK } -func (m MockSDKWrapper) GetRoutesSDK() RoutesSDK { +func (m MockSDKWrapper) GetRoutesSDK() sdkops.RoutesSDK { return m.RoutesSDK } -func (m MockSDKWrapper) GetConsumersSDK() ConsumersSDK { +func (m MockSDKWrapper) GetConsumersSDK() sdkops.ConsumersSDK { return m.ConsumersSDK } -func (m MockSDKWrapper) GetConsumerGroupsSDK() ConsumerGroupSDK { +func (m MockSDKWrapper) GetConsumerGroupsSDK() sdkops.ConsumerGroupSDK { return m.ConsumerGroupSDK } -func (m MockSDKWrapper) GetPluginSDK() PluginSDK { +func (m MockSDKWrapper) GetPluginSDK() sdkops.PluginSDK { return m.PluginSDK } -func (m MockSDKWrapper) GetUpstreamsSDK() UpstreamsSDK { +func (m MockSDKWrapper) GetUpstreamsSDK() sdkops.UpstreamsSDK { return m.UpstreamsSDK } -func (m MockSDKWrapper) GetBasicAuthCredentialsSDK() KongCredentialBasicAuthSDK { +func (m MockSDKWrapper) GetBasicAuthCredentialsSDK() sdkops.KongCredentialBasicAuthSDK { return m.KongCredentialsBasicAuthSDK } -func (m MockSDKWrapper) GetAPIKeyCredentialsSDK() KongCredentialAPIKeySDK { +func (m MockSDKWrapper) GetAPIKeyCredentialsSDK() sdkops.KongCredentialAPIKeySDK { return m.KongCredentialsAPIKeySDK } -func (m MockSDKWrapper) GetACLCredentialsSDK() KongCredentialACLSDK { +func (m MockSDKWrapper) GetACLCredentialsSDK() sdkops.KongCredentialACLSDK { return m.KongCredentialsACLSDK } -func (m MockSDKWrapper) GetJWTCredentialsSDK() KongCredentialJWTSDK { +func (m MockSDKWrapper) GetJWTCredentialsSDK() sdkops.KongCredentialJWTSDK { return m.KongCredentialsJWTSDK } -func (m MockSDKWrapper) GetHMACCredentialsSDK() KongCredentialHMACSDK { +func (m MockSDKWrapper) GetHMACCredentialsSDK() sdkops.KongCredentialHMACSDK { return m.KongCredentialsHMACSDK } -func (m MockSDKWrapper) GetTargetsSDK() TargetsSDK { +func (m MockSDKWrapper) GetTargetsSDK() sdkops.TargetsSDK { return m.TargetsSDK } -func (m MockSDKWrapper) GetVaultSDK() VaultSDK { +func (m MockSDKWrapper) GetVaultSDK() sdkops.VaultSDK { return m.VaultSDK } -func (m MockSDKWrapper) GetMeSDK() MeSDK { +func (m MockSDKWrapper) GetMeSDK() sdkops.MeSDK { return m.MeSDK } -func (m MockSDKWrapper) GetCACertificatesSDK() CACertificatesSDK { +func (m MockSDKWrapper) GetCACertificatesSDK() sdkops.CACertificatesSDK { return m.CACertificatesSDK } -func (m MockSDKWrapper) GetCertificatesSDK() CertificatesSDK { +func (m MockSDKWrapper) GetCertificatesSDK() sdkops.CertificatesSDK { return m.CertificatesSDK } -func (m MockSDKWrapper) GetKeysSDK() KeysSDK { +func (m MockSDKWrapper) GetKeysSDK() sdkops.KeysSDK { return m.KeysSDK } -func (m MockSDKWrapper) GetKeySetsSDK() KeySetsSDK { +func (m MockSDKWrapper) GetKeySetsSDK() sdkops.KeySetsSDK { return m.KeySetsSDK } -func (m MockSDKWrapper) GetSNIsSDK() SNIsSDK { +func (m MockSDKWrapper) GetSNIsSDK() sdkops.SNIsSDK { return m.SNIsSDK } -func (m MockSDKWrapper) GetDataPlaneCertificatesSDK() DataPlaneClientCertificatesSDK { +func (m MockSDKWrapper) GetDataPlaneCertificatesSDK() sdkops.DataPlaneClientCertificatesSDK { return m.DataPlaneCertificatesSDK } @@ -153,7 +155,7 @@ type MockSDKFactory struct { SDK *MockSDKWrapper } -var _ SDKFactory = MockSDKFactory{} +var _ sdkops.SDKFactory = MockSDKFactory{} func NewMockSDKFactory(t *testing.T) *MockSDKFactory { return &MockSDKFactory{ @@ -162,7 +164,7 @@ func NewMockSDKFactory(t *testing.T) *MockSDKFactory { } } -func (m MockSDKFactory) NewKonnectSDK(_ string, _ SDKToken) SDKWrapper { +func (m MockSDKFactory) NewKonnectSDK(_ string, _ sdkops.SDKToken) sdkops.SDKWrapper { require.NotNil(m.t, m.SDK) return *m.SDK } diff --git a/controller/konnect/ops/controlplane_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.controlplane_mock.go similarity index 99% rename from controller/konnect/ops/controlplane_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.controlplane_mock.go index b627f8b21..1f200854a 100644 --- a/controller/konnect/ops/controlplane_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.controlplane_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/controlplanegroup_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.controlplanegroup_mock.go similarity index 99% rename from controller/konnect/ops/controlplanegroup_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.controlplanegroup_mock.go index 3fdcc4d64..d9195d88e 100644 --- a/controller/konnect/ops/controlplanegroup_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.controlplanegroup_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/credentialacl_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.credentialacl_mock.go similarity index 99% rename from controller/konnect/ops/credentialacl_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.credentialacl_mock.go index 9728a9fce..5dcc6bbcf 100644 --- a/controller/konnect/ops/credentialacl_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.credentialacl_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/credentialapikey_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.credentialapikey_mock.go similarity index 99% rename from controller/konnect/ops/credentialapikey_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.credentialapikey_mock.go index 27ceea7c0..32fa88083 100644 --- a/controller/konnect/ops/credentialapikey_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.credentialapikey_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/credentialbasicauth_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.credentialbasicauth_mock.go similarity index 99% rename from controller/konnect/ops/credentialbasicauth_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.credentialbasicauth_mock.go index 1b293f0f7..401d6c224 100644 --- a/controller/konnect/ops/credentialbasicauth_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.credentialbasicauth_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/credentialhmac_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.credentialhmac_mock.go similarity index 99% rename from controller/konnect/ops/credentialhmac_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.credentialhmac_mock.go index d63f42e22..7d19d9a3a 100644 --- a/controller/konnect/ops/credentialhmac_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.credentialhmac_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/credentialjwt_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.credentialjwt_mock.go similarity index 99% rename from controller/konnect/ops/credentialjwt_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.credentialjwt_mock.go index acdb8776e..d0d19bb84 100644 --- a/controller/konnect/ops/credentialjwt_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.credentialjwt_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongcacertificate_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongcacertificate_mock.go similarity index 99% rename from controller/konnect/ops/kongcacertificate_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongcacertificate_mock.go index aa24ca47a..07b4f3c41 100644 --- a/controller/konnect/ops/kongcacertificate_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongcacertificate_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongcertificate_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongcertificate_mock.go similarity index 99% rename from controller/konnect/ops/kongcertificate_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongcertificate_mock.go index 4751e0227..36c82447e 100644 --- a/controller/konnect/ops/kongcertificate_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongcertificate_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongconsumer_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongconsumer_mock.go similarity index 99% rename from controller/konnect/ops/kongconsumer_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongconsumer_mock.go index b39da0b7f..34c10c73d 100644 --- a/controller/konnect/ops/kongconsumer_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongconsumer_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongconsumergroup_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongconsumergroup_mock.go similarity index 99% rename from controller/konnect/ops/kongconsumergroup_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongconsumergroup_mock.go index 247a43ae4..9d9ea3658 100644 --- a/controller/konnect/ops/kongconsumergroup_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongconsumergroup_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongdataplanecertificate_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongdataplanecertificate_mock.go similarity index 99% rename from controller/konnect/ops/kongdataplanecertificate_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongdataplanecertificate_mock.go index 09b768a76..807ad14f7 100644 --- a/controller/konnect/ops/kongdataplanecertificate_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongdataplanecertificate_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongkey_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongkey_mock.go similarity index 99% rename from controller/konnect/ops/kongkey_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongkey_mock.go index 279ad8cb6..0b6e5e17e 100644 --- a/controller/konnect/ops/kongkey_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongkey_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongkeyset_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongkeyset_mock.go similarity index 99% rename from controller/konnect/ops/kongkeyset_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongkeyset_mock.go index 72ddb0e2e..a9e0b8fc7 100644 --- a/controller/konnect/ops/kongkeyset_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongkeyset_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongroute_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongroute_mock.go similarity index 99% rename from controller/konnect/ops/kongroute_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongroute_mock.go index 40b235b87..234b085e1 100644 --- a/controller/konnect/ops/kongroute_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongroute_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongservice_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongservice_mock.go similarity index 99% rename from controller/konnect/ops/kongservice_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongservice_mock.go index 166b64bc0..860eaab48 100644 --- a/controller/konnect/ops/kongservice_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongservice_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongsni_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongsni_mock.go similarity index 99% rename from controller/konnect/ops/kongsni_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongsni_mock.go index 8aae92f11..4ca87585b 100644 --- a/controller/konnect/ops/kongsni_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongsni_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongtarget_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongtarget_mock.go similarity index 99% rename from controller/konnect/ops/kongtarget_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongtarget_mock.go index 7988af137..27532039c 100644 --- a/controller/konnect/ops/kongtarget_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongtarget_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongupstream_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongupstream_mock.go similarity index 99% rename from controller/konnect/ops/kongupstream_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongupstream_mock.go index c39927bc5..31f7956cd 100644 --- a/controller/konnect/ops/kongupstream_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongupstream_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/kongvault_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.kongvault_mock.go similarity index 99% rename from controller/konnect/ops/kongvault_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.kongvault_mock.go index d305d9d65..fc1bd93e4 100644 --- a/controller/konnect/ops/kongvault_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.kongvault_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/me_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.me_mock.go similarity index 99% rename from controller/konnect/ops/me_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.me_mock.go index 83d832fd4..e8ef07f87 100644 --- a/controller/konnect/ops/me_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.me_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/plugin_mock.go b/controller/konnect/ops/sdk/mocks/zz_generated.plugin_mock.go similarity index 99% rename from controller/konnect/ops/plugin_mock.go rename to controller/konnect/ops/sdk/mocks/zz_generated.plugin_mock.go index 970b9a844..f004e1699 100644 --- a/controller/konnect/ops/plugin_mock.go +++ b/controller/konnect/ops/sdk/mocks/zz_generated.plugin_mock.go @@ -1,6 +1,6 @@ // Code generated by mockery. DO NOT EDIT. -package ops +package mocks import ( context "context" diff --git a/controller/konnect/ops/plugin.go b/controller/konnect/ops/sdk/plugin.go similarity index 98% rename from controller/konnect/ops/plugin.go rename to controller/konnect/ops/sdk/plugin.go index 9f378d0bc..3fccd6404 100644 --- a/controller/konnect/ops/plugin.go +++ b/controller/konnect/ops/sdk/plugin.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( "context" diff --git a/controller/konnect/ops/sdkfactory.go b/controller/konnect/ops/sdk/sdkfactory.go similarity index 99% rename from controller/konnect/ops/sdkfactory.go rename to controller/konnect/ops/sdk/sdkfactory.go index c904c9b7d..8823b9c99 100644 --- a/controller/konnect/ops/sdkfactory.go +++ b/controller/konnect/ops/sdk/sdkfactory.go @@ -1,4 +1,4 @@ -package ops +package sdk import ( sdkkonnectgo "github.com/Kong/sdk-konnect-go" diff --git a/controller/konnect/reconciler_generic.go b/controller/konnect/reconciler_generic.go index 38532c804..47907d24d 100644 --- a/controller/konnect/reconciler_generic.go +++ b/controller/konnect/reconciler_generic.go @@ -19,6 +19,7 @@ import ( "github.com/kong/gateway-operator/controller/konnect/constraints" "github.com/kong/gateway-operator/controller/konnect/ops" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" "github.com/kong/gateway-operator/controller/pkg/log" "github.com/kong/gateway-operator/pkg/consts" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -39,7 +40,7 @@ const ( // KonnectEntityReconciler reconciles a Konnect entities. // It uses the generic type constraints to constrain the supported types. type KonnectEntityReconciler[T constraints.SupportedKonnectEntityType, TEnt constraints.EntityType[T]] struct { - sdkFactory ops.SDKFactory + sdkFactory sdkops.SDKFactory DevelopmentMode bool Client client.Client SyncPeriod time.Duration @@ -66,7 +67,7 @@ func NewKonnectEntityReconciler[ T constraints.SupportedKonnectEntityType, TEnt constraints.EntityType[T], ]( - sdkFactory ops.SDKFactory, + sdkFactory sdkops.SDKFactory, developmentMode bool, client client.Client, opts ...KonnectEntityReconcilerOption[T, TEnt], @@ -439,7 +440,7 @@ func (r *KonnectEntityReconciler[T, TEnt]) Reconcile( serverURL := ops.NewServerURL(apiAuth.Spec.ServerURL) sdk := r.sdkFactory.NewKonnectSDK( serverURL.String(), - ops.SDKToken(token), + sdkops.SDKToken(token), ) if delTimestamp := ent.GetDeletionTimestamp(); !delTimestamp.IsZero() { diff --git a/controller/konnect/reconciler_konnectapiauth.go b/controller/konnect/reconciler_konnectapiauth.go index e4adf584c..77074db9c 100644 --- a/controller/konnect/reconciler_konnectapiauth.go +++ b/controller/konnect/reconciler_konnectapiauth.go @@ -16,6 +16,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "github.com/kong/gateway-operator/controller/konnect/ops" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" "github.com/kong/gateway-operator/controller/pkg/log" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -24,7 +25,7 @@ import ( // KonnectAPIAuthConfigurationReconciler reconciles a KonnectAPIAuthConfiguration object. type KonnectAPIAuthConfigurationReconciler struct { - sdkFactory ops.SDKFactory + sdkFactory sdkops.SDKFactory developmentMode bool client client.Client } @@ -42,7 +43,7 @@ const ( // NewKonnectAPIAuthConfigurationReconciler creates a new KonnectAPIAuthConfigurationReconciler. func NewKonnectAPIAuthConfigurationReconciler( - sdkFactory ops.SDKFactory, + sdkFactory sdkops.SDKFactory, developmentMode bool, client client.Client, ) *KonnectAPIAuthConfigurationReconciler { @@ -129,7 +130,7 @@ func (r *KonnectAPIAuthConfigurationReconciler) Reconcile( serverURL := ops.NewServerURL(apiAuth.Spec.ServerURL) sdk := r.sdkFactory.NewKonnectSDK( serverURL.String(), - ops.SDKToken(token), + sdkops.SDKToken(token), ) // TODO(pmalek): check if api auth config has a valid status condition diff --git a/modules/manager/controller_setup.go b/modules/manager/controller_setup.go index 9b4c5e18e..e7723baef 100644 --- a/modules/manager/controller_setup.go +++ b/modules/manager/controller_setup.go @@ -23,7 +23,7 @@ import ( "github.com/kong/gateway-operator/controller/kongplugininstallation" "github.com/kong/gateway-operator/controller/konnect" "github.com/kong/gateway-operator/controller/konnect/constraints" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkops "github.com/kong/gateway-operator/controller/konnect/ops/sdk" "github.com/kong/gateway-operator/controller/pkg/log" "github.com/kong/gateway-operator/controller/specialized" "github.com/kong/gateway-operator/internal/utils/index" @@ -506,7 +506,7 @@ func SetupControllers(mgr manager.Manager, c *Config) (map[string]ControllerDef, return nil, err } - sdkFactory := ops.NewSDKFactory() + sdkFactory := sdkops.NewSDKFactory() konnectControllers := map[string]ControllerDef{ KonnectAPIAuthConfigurationControllerName: { Enabled: c.KonnectControllersEnabled, diff --git a/test/envtest/kongconsumercredential_acl_test.go b/test/envtest/kongconsumercredential_acl_test.go index 43d1dc973..23e010886 100644 --- a/test/envtest/kongconsumercredential_acl_test.go +++ b/test/envtest/kongconsumercredential_acl_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -75,7 +75,7 @@ func TestKongConsumerCredential_ACL(t *testing.T) { "k8s-version:v1alpha1", } - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) factory.SDK.KongCredentialsACLSDK.EXPECT(). CreateACLWithConsumer( mock.Anything, diff --git a/test/envtest/kongconsumercredential_apikey_test.go b/test/envtest/kongconsumercredential_apikey_test.go index b1c952922..60313e6e3 100644 --- a/test/envtest/kongconsumercredential_apikey_test.go +++ b/test/envtest/kongconsumercredential_apikey_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -74,7 +74,7 @@ func TestKongConsumerCredential_APIKey(t *testing.T) { "k8s-version:v1alpha1", } - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) factory.SDK.KongCredentialsAPIKeySDK.EXPECT(). CreateKeyAuthWithConsumer( mock.Anything, diff --git a/test/envtest/kongconsumercredential_basicauth_test.go b/test/envtest/kongconsumercredential_basicauth_test.go index ab1252fa4..6d6566dc4 100644 --- a/test/envtest/kongconsumercredential_basicauth_test.go +++ b/test/envtest/kongconsumercredential_basicauth_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -76,7 +76,7 @@ func TestKongConsumerCredential_BasicAuth(t *testing.T) { "k8s-version:v1alpha1", } - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) factory.SDK.KongCredentialsBasicAuthSDK.EXPECT(). CreateBasicAuthWithConsumer( mock.Anything, diff --git a/test/envtest/kongconsumercredential_hmac_test.go b/test/envtest/kongconsumercredential_hmac_test.go index 7171ef650..aa5525f17 100644 --- a/test/envtest/kongconsumercredential_hmac_test.go +++ b/test/envtest/kongconsumercredential_hmac_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -74,7 +74,7 @@ func TestKongConsumerCredential_HMAC(t *testing.T) { "k8s-version:v1alpha1", } - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) factory.SDK.KongCredentialsHMACSDK.EXPECT(). CreateHmacAuthWithConsumer( mock.Anything, diff --git a/test/envtest/kongconsumercredential_jwt_test.go b/test/envtest/kongconsumercredential_jwt_test.go index e8fd3f031..efa0497e5 100644 --- a/test/envtest/kongconsumercredential_jwt_test.go +++ b/test/envtest/kongconsumercredential_jwt_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -74,7 +74,7 @@ func TestKongConsumerCredential_JWT(t *testing.T) { "k8s-version:v1alpha1", } - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) factory.SDK.KongCredentialsJWTSDK.EXPECT(). CreateJwtWithConsumer( mock.Anything, diff --git a/test/envtest/kongpluginbinding_managed_test.go b/test/envtest/kongpluginbinding_managed_test.go index 3aeaaa732..ac378cda3 100644 --- a/test/envtest/kongpluginbinding_managed_test.go +++ b/test/envtest/kongpluginbinding_managed_test.go @@ -19,7 +19,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/pkg/consts" @@ -54,7 +54,7 @@ func TestKongPluginBindingManaged(t *testing.T) { apiAuth := deploy.KonnectAPIAuthConfigurationWithProgrammed(t, ctx, clientNamespaced) cp := deploy.KonnectGatewayControlPlaneWithID(t, ctx, clientNamespaced, apiAuth) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK require.NoError(t, manager.SetupCacheIndicesForKonnectTypes(ctx, mgr, false)) diff --git a/test/envtest/kongpluginbinding_unmanaged_test.go b/test/envtest/kongpluginbinding_unmanaged_test.go index d25e6e424..7f19d060b 100644 --- a/test/envtest/kongpluginbinding_unmanaged_test.go +++ b/test/envtest/kongpluginbinding_unmanaged_test.go @@ -18,7 +18,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/pkg/consts" @@ -47,7 +47,7 @@ func TestKongPluginBindingUnmanaged(t *testing.T) { apiAuth := deploy.KonnectAPIAuthConfigurationWithProgrammed(t, ctx, clientNamespaced) cp := deploy.KonnectGatewayControlPlaneWithID(t, ctx, clientNamespaced, apiAuth) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK require.NoError(t, manager.SetupCacheIndicesForKonnectTypes(ctx, mgr, false)) diff --git a/test/envtest/konnect_entities_gatewaycontrolplane_test.go b/test/envtest/konnect_entities_gatewaycontrolplane_test.go index 8755d6861..3e466ed4e 100644 --- a/test/envtest/konnect_entities_gatewaycontrolplane_test.go +++ b/test/envtest/konnect_entities_gatewaycontrolplane_test.go @@ -20,6 +20,7 @@ import ( "github.com/kong/gateway-operator/controller/konnect" "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/test/helpers/deploy" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" @@ -39,7 +40,7 @@ var konnectGatewayControlPlaneTestCases = []konnectEntityReconcilerTestCase{ }, ) }, - mockExpectations: func(t *testing.T, sdk *ops.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) { + mockExpectations: func(t *testing.T, sdk *sdkmocks.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) { sdk.ControlPlaneSDK.EXPECT(). CreateControlPlane( mock.Anything, @@ -108,7 +109,7 @@ var konnectGatewayControlPlaneTestCases = []konnectEntityReconcilerTestCase{ }, ) }, - mockExpectations: func(t *testing.T, sdk *ops.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) { + mockExpectations: func(t *testing.T, sdk *sdkmocks.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) { sdk.ControlPlaneSDK.EXPECT(). CreateControlPlane( mock.Anything, @@ -251,7 +252,7 @@ var konnectGatewayControlPlaneTestCases = []konnectEntityReconcilerTestCase{ }, ) }, - mockExpectations: func(t *testing.T, sdk *ops.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) { + mockExpectations: func(t *testing.T, sdk *sdkmocks.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) { sdk.ControlPlaneSDK.EXPECT(). CreateControlPlane( mock.Anything, @@ -383,7 +384,7 @@ var konnectGatewayControlPlaneTestCases = []konnectEntityReconcilerTestCase{ }, ) }, - mockExpectations: func(t *testing.T, sdk *ops.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) { + mockExpectations: func(t *testing.T, sdk *sdkmocks.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) { sdk.ControlPlaneSDK.EXPECT(). CreateControlPlane( mock.Anything, diff --git a/test/envtest/konnect_entities_kongcacertificate_test.go b/test/envtest/konnect_entities_kongcacertificate_test.go index 2f4d31b70..6ac0733c4 100644 --- a/test/envtest/konnect_entities_kongcacertificate_test.go +++ b/test/envtest/konnect_entities_kongcacertificate_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -31,7 +31,7 @@ func TestKongCACertificate(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongcertificate_test.go b/test/envtest/konnect_entities_kongcertificate_test.go index dd8fcf509..229786ec7 100644 --- a/test/envtest/konnect_entities_kongcertificate_test.go +++ b/test/envtest/konnect_entities_kongcertificate_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -31,7 +31,7 @@ func TestKongCertificate(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongconsumer_test.go b/test/envtest/konnect_entities_kongconsumer_test.go index fe2fe0726..7632d645e 100644 --- a/test/envtest/konnect_entities_kongconsumer_test.go +++ b/test/envtest/konnect_entities_kongconsumer_test.go @@ -18,7 +18,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -35,7 +35,7 @@ func TestKongConsumer(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK reconcilers := []Reconciler{ konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongconsumergroup_test.go b/test/envtest/konnect_entities_kongconsumergroup_test.go index 5724574b8..0cfcd4c37 100644 --- a/test/envtest/konnect_entities_kongconsumergroup_test.go +++ b/test/envtest/konnect_entities_kongconsumergroup_test.go @@ -19,6 +19,7 @@ import ( "github.com/kong/gateway-operator/controller/konnect" "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -34,7 +35,7 @@ func TestKongConsumerGroup(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK reconcilers := []Reconciler{ konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongdataplaneclientcertificate_test.go b/test/envtest/konnect_entities_kongdataplaneclientcertificate_test.go index e5d88ec01..f19a2df0b 100644 --- a/test/envtest/konnect_entities_kongdataplaneclientcertificate_test.go +++ b/test/envtest/konnect_entities_kongdataplaneclientcertificate_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -31,7 +31,7 @@ func TestKongDataPlaneClientCertificate(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongkey_test.go b/test/envtest/konnect_entities_kongkey_test.go index 349b5db1b..6b3e3df82 100644 --- a/test/envtest/konnect_entities_kongkey_test.go +++ b/test/envtest/konnect_entities_kongkey_test.go @@ -17,7 +17,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -41,7 +41,7 @@ func TestKongKey(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongkeyset_test.go b/test/envtest/konnect_entities_kongkeyset_test.go index b50b46e90..7d9841b81 100644 --- a/test/envtest/konnect_entities_kongkeyset_test.go +++ b/test/envtest/konnect_entities_kongkeyset_test.go @@ -17,7 +17,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -38,7 +38,7 @@ func TestKongKeySet(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongroute_test.go b/test/envtest/konnect_entities_kongroute_test.go index 0361d2c31..eaa08d9db 100644 --- a/test/envtest/konnect_entities_kongroute_test.go +++ b/test/envtest/konnect_entities_kongroute_test.go @@ -16,7 +16,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -32,7 +32,7 @@ func TestKongRoute(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongservice_test.go b/test/envtest/konnect_entities_kongservice_test.go index a1eca241a..f2c260ca8 100644 --- a/test/envtest/konnect_entities_kongservice_test.go +++ b/test/envtest/konnect_entities_kongservice_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -31,7 +31,7 @@ func TestKongService(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongsni_test.go b/test/envtest/konnect_entities_kongsni_test.go index a42d749e8..042a5182c 100644 --- a/test/envtest/konnect_entities_kongsni_test.go +++ b/test/envtest/konnect_entities_kongsni_test.go @@ -16,7 +16,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -32,7 +32,7 @@ func TestKongSNI(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongtarget_test.go b/test/envtest/konnect_entities_kongtarget_test.go index 1440180dd..9b1aea7a9 100644 --- a/test/envtest/konnect_entities_kongtarget_test.go +++ b/test/envtest/konnect_entities_kongtarget_test.go @@ -16,7 +16,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -31,7 +31,7 @@ func TestKongTarget(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongupstream_test.go b/test/envtest/konnect_entities_kongupstream_test.go index 636879ff1..ac0060f52 100644 --- a/test/envtest/konnect_entities_kongupstream_test.go +++ b/test/envtest/konnect_entities_kongupstream_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -31,7 +31,7 @@ func TestKongUpstream(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_kongvault_test.go b/test/envtest/konnect_entities_kongvault_test.go index 14d726ed5..590ed775f 100644 --- a/test/envtest/konnect_entities_kongvault_test.go +++ b/test/envtest/konnect_entities_kongvault_test.go @@ -17,7 +17,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -33,7 +33,7 @@ func TestKongVault(t *testing.T) { t.Log("Setting up the manager with reconcilers") mgr, logs := NewManager(t, ctx, cfg, scheme.Get()) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK reconcilers := []Reconciler{ konnect.NewKonnectEntityReconciler(factory, false, mgr.GetClient(), diff --git a/test/envtest/konnect_entities_suite_test.go b/test/envtest/konnect_entities_suite_test.go index 97c91e1ce..4f9bd1080 100644 --- a/test/envtest/konnect_entities_suite_test.go +++ b/test/envtest/konnect_entities_suite_test.go @@ -14,7 +14,7 @@ import ( "github.com/kong/gateway-operator/controller/konnect" "github.com/kong/gateway-operator/controller/konnect/constraints" - "github.com/kong/gateway-operator/controller/konnect/ops" + sdkmocks "github.com/kong/gateway-operator/controller/konnect/ops/sdk/mocks" "github.com/kong/gateway-operator/modules/manager/scheme" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" @@ -31,7 +31,7 @@ func TestKonnectEntityReconcilers(t *testing.T) { type konnectEntityReconcilerTestCase struct { name string objectOps func(ctx context.Context, t *testing.T, cl client.Client, ns *corev1.Namespace) - mockExpectations func(t *testing.T, sdk *ops.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) + mockExpectations func(t *testing.T, sdk *sdkmocks.MockSDKWrapper, cl client.Client, ns *corev1.Namespace) eventuallyPredicate func(ctx context.Context, t *assert.CollectT, cl client.Client, ns *corev1.Namespace) } @@ -65,7 +65,7 @@ func testNewKonnectEntityReconciler[ require.NoError(t, mgr.GetClient().Create(ctx, ns)) cl := client.NewNamespacedClient(mgr.GetClient(), ns.Name) - factory := ops.NewMockSDKFactory(t) + factory := sdkmocks.NewMockSDKFactory(t) sdk := factory.SDK StartReconcilers(ctx, t, mgr, logs, konnect.NewKonnectEntityReconciler[T, TEnt](factory, false, cl))