-
Notifications
You must be signed in to change notification settings - Fork 12
/
client_certificate.go
41 lines (37 loc) · 1.24 KB
/
client_certificate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package generators
import (
operatorv1alpha1 "github.com/3scale-ops/marin3r/apis/operator.marin3r/v1alpha1"
"github.com/3scale-ops/marin3r/pkg/reconcilers/lockedresources"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
func (cfg *GeneratorOptions) ClientCertificate() lockedresources.GeneratorFunction {
return func() client.Object {
return &operatorv1alpha1.DiscoveryServiceCertificate{
TypeMeta: metav1.TypeMeta{
Kind: "DiscoveryServiceCertificate",
APIVersion: operatorv1alpha1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: cfg.ClientCertificateName,
Namespace: cfg.Namespace,
Labels: cfg.labels(),
},
Spec: operatorv1alpha1.DiscoveryServiceCertificateSpec{
CommonName: cfg.ClientCertificateName,
ValidFor: int64(cfg.ClientCertificateDuration.Seconds()),
Signer: operatorv1alpha1.DiscoveryServiceCertificateSigner{
CASigned: &operatorv1alpha1.CASignedConfig{
SecretRef: corev1.SecretReference{
Name: cfg.SigningCertificateName,
Namespace: cfg.Namespace,
}},
},
SecretRef: corev1.SecretReference{
Name: cfg.ClientCertificateName,
},
},
}
}
}