diff --git a/modules/common/go.mod b/modules/common/go.mod index c64419c1..e5a4e79b 100644 --- a/modules/common/go.mod +++ b/modules/common/go.mod @@ -10,6 +10,7 @@ require ( github.com/onsi/gomega v1.28.0 github.com/openshift/api v3.9.0+incompatible github.com/pkg/errors v0.9.1 + github.com/stretchr/testify v1.8.1 go.uber.org/zap v1.26.0 k8s.io/api v0.26.9 k8s.io/apimachinery v0.26.9 @@ -76,6 +77,7 @@ require ( require ( github.com/kr/pretty v0.3.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect ) diff --git a/modules/common/tls/tls.go b/modules/common/tls/tls.go index 16606d29..ef3b0efe 100644 --- a/modules/common/tls/tls.go +++ b/modules/common/tls/tls.go @@ -78,6 +78,7 @@ func (t *TLS) CreateVolumeMounts() []corev1.VolumeMount { var volumeMounts []corev1.VolumeMount if t.Service != nil && t.Service.SecretName != "" { + fmt.Println("Creating tls-certs volume for:", t.Service.SecretName) volumeMounts = append(volumeMounts, corev1.VolumeMount{ Name: "tls-crt", MountPath: "/etc/pki/tls/certs/tls.crt", @@ -93,6 +94,7 @@ func (t *TLS) CreateVolumeMounts() []corev1.VolumeMount { } if t.Ca != nil && t.Ca.CaSecretName != "" { + fmt.Println("Creating ca-certs volume for:", t.Ca.CaSecretName) volumeMounts = append(volumeMounts, corev1.VolumeMount{ Name: "ca-certs", MountPath: "/etc/pki/ca-trust/extracted/pem", @@ -108,6 +110,7 @@ func (t *TLS) CreateVolumes() []corev1.Volume { var volumes []corev1.Volume if t.Service != nil && t.Service.SecretName != "" { + fmt.Println("Creating tls-certs volume mount for:", t.Service.SecretName) volumes = append(volumes, corev1.Volume{ Name: "tls-certs", VolumeSource: corev1.VolumeSource{ @@ -120,6 +123,8 @@ func (t *TLS) CreateVolumes() []corev1.Volume { } if t.Ca != nil && t.Ca.CaSecretName != "" { + fmt.Println("Creating ca-certs volume mount for:", t.Ca.CaSecretName) + volumes = append(volumes, corev1.Volume{ Name: "ca-certs", VolumeSource: corev1.VolumeSource{ diff --git a/modules/common/tls/tls_test.go b/modules/common/tls/tls_test.go index 8b494a12..d8cecd89 100644 --- a/modules/common/tls/tls_test.go +++ b/modules/common/tls/tls_test.go @@ -17,10 +17,38 @@ limitations under the License. package tls import ( + "os" "strings" "testing" + + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" +) + +var ( + k8sClient client.Client ) +func TestMain(m *testing.M) { + t := &envtest.Environment{} + + cfg, err := t.Start() + if err != nil { + panic(err) + } + + k8sClient, err = client.New(cfg, client.Options{}) + if err != nil { + panic(err) + } + + code := m.Run() + + t.Stop() + + os.Exit(code) +} + func TestCreateVolumeMounts(t *testing.T) { tests := []struct { name string