diff --git a/modules/common/test/helpers/tls.go b/modules/common/test/helpers/tls.go index 05f27e14..5e8b8e02 100644 --- a/modules/common/test/helpers/tls.go +++ b/modules/common/test/helpers/tls.go @@ -18,7 +18,7 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/certmanager" ) -// NewTLS - function to initialize and return a TLS struct. +// NewTLS - initialize and return a TLS struct. func NewTLS(secretName string, caSecretName []string, disableNonTLSListeners bool) *TLS { return &TLS{ SecretName: secretName, @@ -29,16 +29,16 @@ func NewTLS(secretName string, caSecretName []string, disableNonTLSListeners boo // GetCASecretNameFromIssuer retrieves the CASecretName from an issuer object. func GetCASecretNameFromIssuer(issuer *certmanager.Issuer) []string { - if issuer.CAIssuer != nil { - return []string{issuer.CAIssuer.SecretName} + if issuer.issuer != nil && issuer.issuer.Spec.CA != nil { + return []string{issuer.issuer.Spec.CA.SecretName} } return []string{} } // GetSecretNameFromCertificate retrieves the SecretName from a certificate object. func GetSecretNameFromCertificate(certificate *certmanager.Certificate) string { - if certificate.Certificate != nil { - return certificate.Certificate.Spec.SecretName + if certificate.certificate != nil { + return certificate.certificate.Spec.SecretName } return "" } diff --git a/modules/common/tls/tls.go b/modules/common/tls/tls.go index 7f519931..d5b8c1f1 100644 --- a/modules/common/tls/tls.go +++ b/modules/common/tls/tls.go @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ + package tls import ( @@ -47,16 +48,16 @@ func NewTLS(secretName string, caSecretName []string, disableNonTLSListeners boo // GetCASecretNameFromIssuer retrieves the CASecretName from an issuer object. func GetCASecretNameFromIssuer(issuer *certmanager.Issuer) []string { - if issuer.Spec.CA != nil { - return []string{issuer.Spec.CA.SecretName} + if issuer.issuer != nil && issuer.issuer.Spec.CA != nil { + return []string{issuer.issuer.Spec.CA.SecretName} } return []string{} } // GetSecretNameFromCertificate retrieves the SecretName from a certificate object. func GetSecretNameFromCertificate(certificate *certmanager.Certificate) string { - if certificate.Certificate != nil { - return certificate.Certificate.Spec.SecretName + if certificate.certificate != nil { + return certificate.certificate.Spec.SecretName } return "" }