Skip to content

Commit 21c6972

Browse files
committed
Use internal Volume struct for tls
This change switches the tls package over to using the lib-common copy of the Volume struct. This will allow us to append TLS volumes to the volume struct in each service Operator as we update the version of lib-common in each of them. Signed-off-by: Brendan Shephard <[email protected]>
1 parent 71a0e9d commit 21c6972

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

modules/common/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/onsi/ginkgo/v2 v2.20.1
1010
github.com/onsi/gomega v1.34.1
1111
github.com/openshift/api v3.9.0+incompatible
12+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d
1213
github.com/pkg/errors v0.9.1
1314
go.uber.org/zap v1.27.0
1415
gopkg.in/yaml.v3 v3.0.1

modules/common/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
8080
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
8181
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E=
8282
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
83+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d h1:6fA7kvhKRelVwNWxcMVe2d2lkN8MITY0OIudTBnmT+A=
84+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d/go.mod h1:tfgBeLRqmlH/NQkLPe7396rj+t0whv2wPuMb8Ttvh8w=
8385
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
8486
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
8587
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

modules/common/tls/tls.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3030
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
3131
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
32+
"github.com/openstack-k8s-operators/lib-common/modules/storage"
3233
appsv1 "k8s.io/api/apps/v1"
3334
corev1 "k8s.io/api/core/v1"
3435
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
@@ -382,15 +383,15 @@ func (s *Service) CreateVolumeMounts(serviceID string) []corev1.VolumeMount {
382383
}
383384

384385
// CreateVolume - add volume for TLS certificates and CA certificate for the service
385-
func (s *Service) CreateVolume(serviceID string) corev1.Volume {
386-
volume := corev1.Volume{}
386+
func (s *Service) CreateVolume(serviceID string) storage.Volume {
387+
volume := storage.Volume{}
387388
if serviceID == "" {
388389
serviceID = "default"
389390
}
390391
if s.SecretName != "" {
391-
volume = corev1.Volume{
392+
volume = storage.Volume{
392393
Name: serviceID + "-tls-certs",
393-
VolumeSource: corev1.VolumeSource{
394+
VolumeSource: storage.VolumeSource{
394395
Secret: &corev1.SecretVolumeSource{
395396
SecretName: s.SecretName,
396397
DefaultMode: ptr.To[int32](0400),

modules/common/tls/tls_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
. "github.com/onsi/gomega"
2626
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
27+
"github.com/openstack-k8s-operators/lib-common/modules/storage"
2728
)
2829

2930
func TestAPIEnabled(t *testing.T) {
@@ -206,20 +207,20 @@ func TestServiceCreateVolume(t *testing.T) {
206207
name string
207208
service *Service
208209
id string
209-
want corev1.Volume
210+
want storage.Volume
210211
}{
211212
{
212213
name: "No Secrets",
213214
service: &Service{},
214-
want: corev1.Volume{},
215+
want: storage.Volume{},
215216
},
216217
{
217218
name: "Only TLS Secret",
218219
service: &Service{SecretName: "cert-secret"},
219220
id: "foo",
220-
want: corev1.Volume{
221+
want: storage.Volume{
221222
Name: "foo-tls-certs",
222-
VolumeSource: corev1.VolumeSource{
223+
VolumeSource: storage.VolumeSource{
223224
Secret: &corev1.SecretVolumeSource{
224225
SecretName: "cert-secret",
225226
DefaultMode: ptr.To[int32](0400),
@@ -230,9 +231,9 @@ func TestServiceCreateVolume(t *testing.T) {
230231
{
231232
name: "Only TLS Secret no serviceID",
232233
service: &Service{SecretName: "cert-secret"},
233-
want: corev1.Volume{
234+
want: storage.Volume{
234235
Name: "default-tls-certs",
235-
VolumeSource: corev1.VolumeSource{
236+
VolumeSource: storage.VolumeSource{
236237
Secret: &corev1.SecretVolumeSource{
237238
SecretName: "cert-secret",
238239
DefaultMode: ptr.To[int32](0400),

modules/storage/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)