Skip to content

Commit

Permalink
Add the basic TLS structure and helpers
Browse files Browse the repository at this point in the history
Signed-off-by: Veronika Fisarova <vfisarov@redhat.com>
  • Loading branch information
Deydra71 committed Sep 11, 2023
1 parent d7f3d24 commit de67678
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions modules/common/test/helpers/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 ""
}
9 changes: 5 additions & 4 deletions modules/common/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 ""
}

0 comments on commit de67678

Please sign in to comment.