Skip to content

Commit

Permalink
add tests and sample
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Sep 30, 2024
1 parent deb7f4c commit 9ec6a85
Show file tree
Hide file tree
Showing 10 changed files with 810 additions and 11 deletions.
98 changes: 98 additions & 0 deletions config/samples/konnect_sni.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
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
cert: |
-----BEGIN CERTIFICATE-----
MIIDPTCCAiUCFG5IolqRiKPMfzTI8peXlaF6cZODMA0GCSqGSIb3DQEBCwUAMFsx
CzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5
MRIwEAYDVQQKDAlLb25nIEluYy4xFDASBgNVBAMMC2tvbmdocS50ZWNoMB4XDTI0
MDkyNTA3MjIzOFoXDTM0MDkyMzA3MjIzOFowWzELMAkGA1UEBhMCVVMxCzAJBgNV
BAgMAkNBMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxEjAQBgNVBAoMCUtvbmcgSW5j
LjEUMBIGA1UEAwwLa29uZ2hxLnRlY2gwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
ggEKAoIBAQDXmNBzpWyJ0YUdfCamZpJiwRQMn5vVY8iKQrd3dD03DWyPHu/fXlrL
+QPTRip5d1SrxjzQ4S3fgme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AG3v93R5tAeSrn7DMHaZt
p+udsNw9mDPYHAzlYtnw1OE/I0ceR5UyCFSzCd00Q8ZYBLf9jRvsO/GUA4F51isE
8/7xyqSxJqDwzv9N8EGkqf/SfMKA3kK3Sc8u+ovhzJu8OxcY+qrpo4+vYWYeW42n
5XBwvWV2ovRMx7Ntw7FUc24=
-----END PRIVATE KEY-----
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongSNI
metadata:
name: sni-1
namespace: default
spec:
certificateRef:
name: cert-1
name: "test-sni.konghq.com"
2 changes: 1 addition & 1 deletion controller/konnect/ops/ops_kongsni.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func createSNI(
resp, err := sdk.CreateSniWithCertificate(ctx, sdkkonnectops.CreateSniWithCertificateRequest{
ControlPlaneID: cpID,
CertificateID: sni.Status.Konnect.CertificateID,
SNIWithoutParents: sdkkonnectcomp.SNIWithoutParents{},
SNIWithoutParents: kongSNIToSNIWithoutParents(sni),
})

if errWrapped := wrapErrIfKonnectOpFailed(err, CreateOp, sni); errWrapped != nil {
Expand Down
2 changes: 1 addition & 1 deletion controller/konnect/reconciler_certificateref.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func handleKongCertificateRef[T constraints.SupportedKonnectEntityType, TEnt con
// If referenced KongCertificate is being deleted, return an error so that we
// can remove the entity from Konnect first.
if delTimestamp := cert.GetDeletionTimestamp(); !delTimestamp.IsZero() {
return ctrl.Result{}, ReferencedKongUpstreamIsBeingDeleted{
return ctrl.Result{}, ReferencedKongCertificateIsBeingDeleted{
Reference: nn,
DeletionTimestamp: delTimestamp.Time,
}
Expand Down
Loading

0 comments on commit 9ec6a85

Please sign in to comment.