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 18, 2024
1 parent ce6c450 commit 46725b6
Show file tree
Hide file tree
Showing 13 changed files with 554 additions and 2 deletions.
1 change: 1 addition & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ packages:
ConsumerGroupSDK:
PluginSDK:
UpstreamsSDK:
VaultSDK:
MeSDK:
1 change: 0 additions & 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
3 changes: 2 additions & 1 deletion controller/konnect/constraints/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type SupportedKonnectEntityType interface {
configurationv1.KongConsumer |
configurationv1beta1.KongConsumerGroup |
configurationv1alpha1.KongPluginBinding |
configurationv1alpha1.KongUpstream
configurationv1alpha1.KongUpstream |
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 @@ -66,6 +66,8 @@ func Create[
return e, createPlugin(ctx, cl, sdk.GetPluginSDK(), ent)
case *configurationv1alpha1.KongUpstream:
return e, createUpstream(ctx, sdk.GetUpstreamsSDK(), ent)
case *configurationv1alpha1.KongVault:
return e, createVault(ctx, sdk.GetVaultSDK(), ent)

// ---------------------------------------------------------------------
// TODO: add other Konnect types
Expand Down Expand Up @@ -106,6 +108,8 @@ func Delete[
return deletePlugin(ctx, sdk.GetPluginSDK(), ent)
case *configurationv1alpha1.KongUpstream:
return deleteUpstream(ctx, sdk.GetUpstreamsSDK(), ent)
case *configurationv1alpha1.KongVault:
return deleteVault(ctx, sdk.GetVaultSDK(), ent)

// ---------------------------------------------------------------------
// TODO: add other Konnect types
Expand Down Expand Up @@ -171,6 +175,8 @@ func Update[
return ctrl.Result{}, updatePlugin(ctx, sdk.GetPluginSDK(), cl, ent)
case *configurationv1alpha1.KongUpstream:
return ctrl.Result{}, updateUpstream(ctx, sdk.GetUpstreamsSDK(), ent)
case *configurationv1alpha1.KongVault:
return ctrl.Result{}, updateVault(ctx, sdk.GetVaultSDK(), ent)

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

0 comments on commit 46725b6

Please sign in to comment.