Skip to content

Commit

Permalink
feat(konnect): add KongKeySet reconciler
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Sep 27, 2024
1 parent f7dba50 commit acb7c28
Show file tree
Hide file tree
Showing 20 changed files with 907 additions and 6 deletions.
1 change: 1 addition & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ packages:
CACertificatesSDK:
CertificatesSDK:
KeysSDK:
KeySetsSDK:
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
[#597](https://github.com/Kong/gateway-operator/pull/597)
- Add `KongKey` reconciler for Konnect Keys.
[#646](https://github.com/Kong/gateway-operator/pull/646)
- Add `KongKeySet` reconciler for Konnect KeySets.
[#646](https://github.com/Kong/gateway-operator/pull/646)
- The `DataPlaneKonnectExtension` CRD has been introduced. Such a CRD can be attached
to a `DataPlane` via the extensions field to have a konnect-flavored `DataPlane`.
[#453](https://github.com/Kong/gateway-operator/pull/453), [#578](https://github.com/Kong/gateway-operator/pull/578)
Expand Down
39 changes: 39 additions & 0 deletions config/samples/konnect_kongkeyset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
kind: KonnectAPIAuthConfiguration
apiVersion: konnect.konghq.com/v1alpha1
metadata:
name: konnect-api-auth-dev-1
namespace: default
spec:
type: token
token: kpat_XXXXXXXXXXXXXXXXXXX
serverURL: us.api.konghq.tech
---
kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha1
metadata:
name: test1
namespace: default
spec:
name: test1
labels:
app: test1
key1: test1
konnect:
authRef:
name: konnect-api-auth-dev-1
---
kind: KongKeySet
apiVersion: configuration.konghq.com/v1alpha1
metadata:
name: key-set-1
namespace: default
annotations:
konghq.com/tags: "infra"
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: test1
name: key-set-1
tags:
- production
3 changes: 2 additions & 1 deletion controller/konnect/constraints/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ type SupportedKonnectEntityType interface {
configurationv1alpha1.KongCertificate |
configurationv1alpha1.KongTarget |
configurationv1alpha1.KongVault |
configurationv1alpha1.KongKey
configurationv1alpha1.KongKey |
configurationv1alpha1.KongKeySet
// TODO: add other types

GetTypeName() string
Expand Down
15 changes: 15 additions & 0 deletions controller/konnect/ops/kongkeyset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ops

import (
"context"

sdkkonnectcomp "github.com/Kong/sdk-konnect-go/models/components"
sdkkonnectops "github.com/Kong/sdk-konnect-go/models/operations"
)

// KeySetsSDK is the interface for the KeySetsSDK.
type KeySetsSDK interface {
CreateKeySet(ctx context.Context, controlPlaneID string, keySet sdkkonnectcomp.KeySetInput, opts ...sdkkonnectops.Option) (*sdkkonnectops.CreateKeySetResponse, error)
UpsertKeySet(ctx context.Context, request sdkkonnectops.UpsertKeySetRequest, opts ...sdkkonnectops.Option) (*sdkkonnectops.UpsertKeySetResponse, error)
DeleteKeySet(ctx context.Context, controlPlaneID string, keySetID string, opts ...sdkkonnectops.Option) (*sdkkonnectops.DeleteKeySetResponse, error)
}
264 changes: 264 additions & 0 deletions controller/konnect/ops/kongkeyset_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions controller/konnect/ops/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func Create[
return e, createVault(ctx, sdk.GetVaultSDK(), ent)
case *configurationv1alpha1.KongKey:
return e, createKey(ctx, sdk.GetKeysSDK(), ent)

case *configurationv1alpha1.KongKeySet:
return e, createKeySet(ctx, sdk.GetKeySetsSDK(), ent)
// ---------------------------------------------------------------------
// TODO: add other Konnect types

Expand Down Expand Up @@ -134,7 +135,8 @@ func Delete[
return deleteVault(ctx, sdk.GetVaultSDK(), ent)
case *configurationv1alpha1.KongKey:
return deleteKey(ctx, sdk.GetKeysSDK(), ent)

case *configurationv1alpha1.KongKeySet:
return deleteKeySet(ctx, sdk.GetKeySetsSDK(), ent)
// ---------------------------------------------------------------------
// TODO: add other Konnect types

Expand Down Expand Up @@ -233,6 +235,8 @@ func Update[
return ctrl.Result{}, updateVault(ctx, sdk.GetVaultSDK(), ent)
case *configurationv1alpha1.KongKey:
return ctrl.Result{}, updateKey(ctx, sdk.GetKeysSDK(), ent)
case *configurationv1alpha1.KongKeySet:
return ctrl.Result{}, updateKeySet(ctx, sdk.GetKeySetsSDK(), ent)

// ---------------------------------------------------------------------
// TODO: add other Konnect types
Expand Down
Loading

0 comments on commit acb7c28

Please sign in to comment.