@@ -447,13 +447,6 @@ func handleDomainGateway[T v1alpha1.DomainEntity](ctx context.Context, c *Contro
447447
448448func handleDomainCertificate [T v1alpha1.DomainEntity ](ctx context.Context , c * Controller , dom T , credentialNamespace , name , namespace , ownerId string ) (credentialName string , err error ) {
449449 h := CreateCertificateManager (c )
450- selector := labels .SelectorFromSet (labels.Set {
451- LabelOwnerIdentifierHash : sha1Sum (ownerId ),
452- })
453- certs , err := h .ListCertificates (ctx , metav1 .NamespaceAll , selector )
454- if err != nil {
455- return "" , fmt .Errorf ("failed to list certificates for %s: %w" , ownerId , err )
456- }
457450
458451 credentialName = h .GetCredentialName (namespace , name )
459452
@@ -466,49 +459,8 @@ func handleDomainCertificate[T v1alpha1.DomainEntity](ctx context.Context, c *Co
466459 OwnerId : ownerId ,
467460 OwnerGeneration : dom .GetMetadata ().Generation ,
468461 }
469- hash := info .Hash ()
470462
471- certsForDeletion := []ManagedCertificate {}
472- var (
473- selectedCert ManagedCertificate
474- consistent bool
475- )
476- for i := range certs {
477- cert := certs [i ]
478- if h .managerType == certManagerCertManagerIO && (cert .GetNamespace () != credentialNamespace || consistent ) {
479- certsForDeletion = append (certsForDeletion , cert )
480- continue
481- }
482- if cert .GetAnnotations ()[AnnotationResourceHash ] == hash {
483- // this certificate is already up to date
484- if selectedCert != nil {
485- certsForDeletion = append (certsForDeletion , selectedCert )
486- }
487- selectedCert = cert
488- consistent = true
489- continue
490- }
491- if selectedCert == nil {
492- // this is the first certificate that is not consistent
493- selectedCert = cert
494- continue
495- }
496- certsForDeletion = append (certsForDeletion , cert )
497- }
498-
499- if len (certsForDeletion ) > 0 {
500- if err = h .DeleteCertificates (ctx , certsForDeletion ); err != nil {
501- return "" , fmt .Errorf ("failed to delete outdated certificates for %s: %w" , ownerId , err )
502- }
503- }
504-
505- if selectedCert == nil { // create
506- err = h .CreateCertificate (ctx , info )
507- } else if ! consistent { // update
508- err = h .UpdateCertificate (ctx , selectedCert , info )
509- }
510-
511- return
463+ return credentialName , h .handleCertificate (ctx , info )
512464}
513465
514466func handleAdditionalCACertificate [T v1alpha1.DomainEntity ](ctx context.Context , c * Controller , dom T , credentialName , credentialNamespace string , ownerId string ) error {
0 commit comments