in pkg/controller/sync/sync.go [107:150]
func (s impl) getCertificatesToAttach(ingress *netv1.Ingress) (map[string]bool, []types.Id, error) {
// If a ManagedCertificate attached to Ingress does not exist, add an event to Ingress
// and return an error.
boundManagedCertificates := parse(ingress.Annotations[config.AnnotationManagedCertificatesKey])
for mcrtName := range boundManagedCertificates {
id := types.NewId(ingress.Namespace, mcrtName)
_, err := s.managedCertificate.Get(id)
if err == nil {
continue
}
if errors.IsNotFound(err) {
s.event.MissingCertificate(*ingress, mcrtName)
}
return nil, nil, fmt.Errorf("managedCertificate.Get(%s): %w", id.String(), err)
}
// Take already bound SslCertificate resources.
sslCertificates := make(map[string]bool, 0)
for sslCertificateName := range parse(ingress.Annotations[config.AnnotationPreSharedCertKey]) {
sslCertificates[sslCertificateName] = true
}
// Slice of ManagedCertificate ids that are attached to Ingress via annotation
// managed-certificates.
var managedCertificates []types.Id
for id, entry := range s.state.List() {
if id.Namespace != ingress.Namespace {
continue
}
if entry.SoftDeleted {
delete(sslCertificates, entry.SslCertificateName)
} else if _, e := boundManagedCertificates[id.Name]; e {
sslCertificates[entry.SslCertificateName] = true
managedCertificates = append(managedCertificates, id)
}
}
return sslCertificates, managedCertificates, nil
}