diff --git a/controllers/secret/ca.go b/controllers/secret/ca.go index 4336d060..997bdd5a 100644 --- a/controllers/secret/ca.go +++ b/controllers/secret/ca.go @@ -180,8 +180,8 @@ func (r CAReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl key, _ = ca.CAPrivateKeyPem() instance.Data = map[string][]byte{ - certSecretKey: crt.Bytes(), - privateKeySecretKey: key.Bytes(), + corev1.TLSCertKey: crt.Bytes(), + corev1.TLSPrivateKeyKey: key.Bytes(), } group := new(errgroup.Group) diff --git a/controllers/secret/reconciler.go b/controllers/secret/reconciler.go index 66803217..6d6ebbea 100644 --- a/controllers/secret/reconciler.go +++ b/controllers/secret/reconciler.go @@ -25,7 +25,7 @@ func getCertificateAuthority(ctx context.Context, client client.Client, namespac return nil, MissingCaError{} } - ca, err = cert.NewCertificateAuthorityFromBytes(instance.Data[certSecretKey], instance.Data[privateKeySecretKey]) + ca, err = cert.NewCertificateAuthorityFromBytes(instance.Data[corev1.TLSCertKey], instance.Data[corev1.TLSPrivateKeyKey]) if err != nil { return } diff --git a/controllers/secret/tls.go b/controllers/secret/tls.go index f4a02307..0b1ad41d 100644 --- a/controllers/secret/tls.go +++ b/controllers/secret/tls.go @@ -66,7 +66,7 @@ func (r TLSReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctr } var shouldCreate bool - for _, key := range []string{certSecretKey, privateKeySecretKey} { + for _, key := range []string{corev1.TLSCertKey, corev1.TLSPrivateKeyKey} { if _, ok := instance.Data[key]; !ok { shouldCreate = true break @@ -85,13 +85,13 @@ func (r TLSReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctr return reconcile.Result{}, err } instance.Data = map[string][]byte{ - certSecretKey: crt.Bytes(), - privateKeySecretKey: key.Bytes(), + corev1.TLSCertKey: crt.Bytes(), + corev1.TLSPrivateKeyKey: key.Bytes(), } } else { var c *x509.Certificate var b *pem.Block - b, _ = pem.Decode(instance.Data[certSecretKey]) + b, _ = pem.Decode(instance.Data[corev1.TLSCertKey]) c, err = x509.ParseCertificate(b.Bytes) if err != nil { r.Log.Error(err, "cannot parse Capsule TLS")