Skip to content

Commit

Permalink
add KongVault reconciler
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Sep 13, 2024
1 parent 64eb7fc commit dcf1bca
Show file tree
Hide file tree
Showing 16 changed files with 560 additions and 6 deletions.
1 change: 1 addition & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ packages:
ConsumersSDK:
ConsumerGroupSDK:
PluginSDK:
VaultSDK:
MeSDK:
2 changes: 1 addition & 1 deletion config/rbac/role/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ rules:
- kongingresses
- konglicenses
- kongupstreampolicies
- kongvaults
- tcpingresses
- udpingresses
verbs:
Expand Down Expand Up @@ -167,6 +166,7 @@ rules:
- kongpluginbindings
- kongroutes
- kongservices
- kongvaults
verbs:
- get
- list
Expand Down
3 changes: 2 additions & 1 deletion controller/konnect/constraints/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type SupportedKonnectEntityType interface {
configurationv1alpha1.KongRoute |
configurationv1.KongConsumer |
configurationv1beta1.KongConsumerGroup |
configurationv1alpha1.KongPluginBinding
configurationv1alpha1.KongPluginBinding |
configurationv1alpha1.KongVault
// TODO: add other types

GetTypeName() string
Expand Down
15 changes: 15 additions & 0 deletions controller/konnect/ops/kongvault.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"
)

// VaultSDK is the interface for Konnect Vault SDK.
type VaultSDK interface {
CreateVault(ctx context.Context, controlPlaneID string, vault sdkkonnectcomp.VaultInput, opts ...sdkkonnectops.Option) (*sdkkonnectops.CreateVaultResponse, error)
UpsertVault(ctx context.Context, request sdkkonnectops.UpsertVaultRequest, opts ...sdkkonnectops.Option) (*sdkkonnectops.UpsertVaultResponse, error)
DeleteVault(ctx context.Context, controlPlaneID string, vaultID string, opts ...sdkkonnectops.Option) (*sdkkonnectops.DeleteVaultResponse, error)
}
264 changes: 264 additions & 0 deletions controller/konnect/ops/kongvault_mock.go

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

6 changes: 6 additions & 0 deletions controller/konnect/ops/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func Create[
return e, createConsumerGroup(ctx, sdk.GetConsumerGroupsSDK(), ent)
case *configurationv1alpha1.KongPluginBinding:
return e, createPlugin(ctx, cl, sdk.GetPluginSDK(), ent)
case *configurationv1alpha1.KongVault:
return e, createVault(ctx, sdk.GetVaultSDK(), ent)

// ---------------------------------------------------------------------
// TODO: add other Konnect types
Expand Down Expand Up @@ -102,6 +104,8 @@ func Delete[
return deleteConsumerGroup(ctx, sdk.GetConsumerGroupsSDK(), ent)
case *configurationv1alpha1.KongPluginBinding:
return deletePlugin(ctx, sdk.GetPluginSDK(), ent)
case *configurationv1alpha1.KongVault:
return deleteVault(ctx, sdk.GetVaultSDK(), ent)

// ---------------------------------------------------------------------
// TODO: add other Konnect types
Expand Down Expand Up @@ -165,6 +169,8 @@ func Update[
return ctrl.Result{}, updateConsumerGroup(ctx, sdk.GetConsumerGroupsSDK(), ent)
case *configurationv1alpha1.KongPluginBinding:
return ctrl.Result{}, updatePlugin(ctx, sdk.GetPluginSDK(), cl, ent)
case *configurationv1alpha1.KongVault:
return ctrl.Result{}, updateVault(ctx, sdk.GetVaultSDK(), ent)

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

0 comments on commit dcf1bca

Please sign in to comment.