Skip to content

Commit

Permalink
feat: add KongCertificate reconciler (#643)
Browse files Browse the repository at this point in the history
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
  • Loading branch information
tao12345666333 authored Sep 26, 2024
1 parent f1fd23a commit ee76d6d
Show file tree
Hide file tree
Showing 19 changed files with 1,005 additions and 0 deletions.
1 change: 1 addition & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ packages:
KongCredentialAPIKeySDK:
KongCredentialBasicAuthSDK:
CACertificatesSDK:
CertificatesSDK:
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
[#510](https://github.com/Kong/gateway-operator/pull/510)
- Add `KongCACertificate` reconciler for Konnect CA certificates.
[#626](https://github.com/Kong/gateway-operator/pull/626)
- Add `KongCertificate` reconciler for Konnect Certificates.
[#643](https://github.com/Kong/gateway-operator/pull/643)
- Added command line flags to configure the certificate generator job's images.
[#516](https://github.com/Kong/gateway-operator/pull/516)
- Add `KongPluginBinding` reconciler for Konnect Plugins.
Expand Down
88 changes: 88 additions & 0 deletions config/samples/konnect_certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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: KongCertificate
apiVersion: configuration.konghq.com/v1alpha1
metadata:
name: cert-1
namespace: default
annotations:
konghq.com/tags: "infra"
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: test1
tags:
- production
c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Ey49vROdkTia133Wc7m71/D5
RDUqvSmAEHJyhTlzCbTO+JcNhC6cx3s102GNcVYHlAq3WoE5EV1YykUNJwUg4XPn
AggNkYOiXs6tf+uePmT8MddixFFgFxZ2bIqFhvnY+WqypHuxtwIepqKJjq5xZTiB
+lfp7SziCwKBgAivofdpXwLyfldy7I2T18zcOzBhfn01CgWdrahXFjEhnqEnfizb
u1OBx5l8CtmX1GJ+EWmnRlXYDUd7lZ71v19fNQdpmGKW+4TVDA0Fafqy6Jw6q9F6
bLBg20GUQQyrI2UGICk2XYaK2ec27rB/Le2zttfGpBiaco0h8rLy0SrjAoGBAM4/
UY/UOQsOrUTuT2wBf8LfNtUid9uSIZRNrplNrebxhJCkkB/uLyoN0iE9xncMcpW6
YmVH6c3IGwyHOnBFc1OHcapjukBApL5rVljQpwPVU1GKmHgdi8hHgmajRlqPtx3I
isRkVCPi5kqV8WueY3rgmNOGLnLJasBmE/gt4ihPAoGAG3v93R5tAeSrn7DMHaZt
p+udsNw9mDPYHAzlYtnw1OE/I0ceR5UyCFSzCd00Q8ZYBLf9jRvsO/GUA4F51isE
8/7xyqSxJqDwzv9N8EGkqf/SfMKA3kK3Sc8u+ovhzJu8OxcY+qrpo4+vYWYeW42n
5XBwvWV2ovRMx7Ntw7FUc24=
-----END PRIVATE KEY-----
1 change: 1 addition & 0 deletions controller/konnect/constraints/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type SupportedKonnectEntityType interface {
configurationv1alpha1.KongCredentialAPIKey |
configurationv1alpha1.KongUpstream |
configurationv1alpha1.KongCACertificate |
configurationv1alpha1.KongCertificate |
configurationv1alpha1.KongTarget |
configurationv1alpha1.KongVault
// TODO: add other types
Expand Down
15 changes: 15 additions & 0 deletions controller/konnect/ops/kongcertificate.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"
)

// CertificatesSDK is the interface for the CertificatesSDK.
type CertificatesSDK interface {
CreateCertificate(ctx context.Context, controlPlaneID string, certificate sdkkonnectcomp.CertificateInput, opts ...sdkkonnectops.Option) (*sdkkonnectops.CreateCertificateResponse, error)
UpsertCertificate(ctx context.Context, request sdkkonnectops.UpsertCertificateRequest, opts ...sdkkonnectops.Option) (*sdkkonnectops.UpsertCertificateResponse, error)
DeleteCertificate(ctx context.Context, controlPlaneID string, certificateID string, opts ...sdkkonnectops.Option) (*sdkkonnectops.DeleteCertificateResponse, error)
}
264 changes: 264 additions & 0 deletions controller/konnect/ops/kongcertificate_mock.go

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

Loading

0 comments on commit ee76d6d

Please sign in to comment.