Early return instead of large code block

This commit is contained in:
Nick Sardo 2017-04-26 11:09:43 -07:00
parent 3af5f5c311
commit b2e5d441d2

View file

@ -436,7 +436,12 @@ func (l *L7) checkSSLCert() error {
// PrivateKey is write only, so compare certs alone. We're assuming that
// no one will change just the key. We can remember the key and compare,
// but a bug could end up leaking it, which feels worse.
if l.sslCert == nil || ingCert != l.sslCert.Certificate {
if l.sslCert != nil && ingCert == l.sslCert.Certificate {
return nil
}
// Controller needs to create or update the certificate.
// Generate the next certificate name to use.
newCertName := l.nextCertificateName()
// Perform a delete in case a certificate exists with the exact name
@ -458,7 +463,6 @@ func (l *L7) checkSSLCert() error {
// Save the current cert for cleanup after we update the target proxy.
l.oldSSLCert = l.sslCert
l.sslCert = cert
}
return nil
}