fix: fallbackForInvalidSecret to return original secret (#1245)

This commit is contained in:
Jun
2024-08-25 15:59:12 +08:00
committed by GitHub
parent a5a28aebf6
commit a2c2d1d521
2 changed files with 16 additions and 10 deletions

View File

@@ -431,11 +431,14 @@ func (c *controller) ConvertGateway(convertOptions *common.ConvertOptions, wrapp
if err != nil { if err != nil {
if k8serrors.IsNotFound(err) { if k8serrors.IsNotFound(err) {
// If there is no matching secret, try to get it from configmap. // If there is no matching secret, try to get it from configmap.
secretName = httpsCredentialConfig.MatchSecretNameByDomain(rule.Host) matchSecretName := httpsCredentialConfig.MatchSecretNameByDomain(rule.Host)
if matchSecretName != "" {
namespace, secret := cert.ParseTLSSecret(matchSecretName)
if namespace == "" {
secretNamespace = c.options.SystemNamespace secretNamespace = c.options.SystemNamespace
namespace, secret := cert.ParseTLSSecret(secretName) } else {
if namespace != "" {
secretNamespace = namespace secretNamespace = namespace
}
secretName = secret secretName = secret
} }
} }

View File

@@ -417,11 +417,14 @@ func (c *controller) ConvertGateway(convertOptions *common.ConvertOptions, wrapp
if err != nil { if err != nil {
if k8serrors.IsNotFound(err) { if k8serrors.IsNotFound(err) {
// If there is no matching secret, try to get it from configmap. // If there is no matching secret, try to get it from configmap.
secretName = httpsCredentialConfig.MatchSecretNameByDomain(rule.Host) matchSecretName := httpsCredentialConfig.MatchSecretNameByDomain(rule.Host)
if matchSecretName != "" {
namespace, secret := cert.ParseTLSSecret(matchSecretName)
if namespace == "" {
secretNamespace = c.options.SystemNamespace secretNamespace = c.options.SystemNamespace
namespace, secret := cert.ParseTLSSecret(secretName) } else {
if namespace != "" {
secretNamespace = namespace secretNamespace = namespace
}
secretName = secret secretName = secret
} }
} }