Skip to content

Commit 46b1064

Browse files
committed
pkg/storage/util: receive specific lister on GetInfrastructure function
1 parent 57078a8 commit 46b1064

File tree

11 files changed

+24
-23
lines changed

11 files changed

+24
-23
lines changed

pkg/operator/bootstrap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (c *Controller) Bootstrap() error {
4343
return err
4444
}
4545

46-
infra, err := util.GetInfrastructure(&c.listers.StorageListers)
46+
infra, err := util.GetInfrastructure(c.listers.StorageListers.Infrastructures)
4747
if err != nil {
4848
return fmt.Errorf("unable to get infrastructure resource: %w", err)
4949
}
@@ -112,7 +112,7 @@ func (c *Controller) createPVC(accessMode corev1.PersistentVolumeAccessMode, cla
112112
storageClassName := "standard-csi"
113113

114114
// This is a Workaround for Bug#1862991 Tracker for removel on Bug#1866240
115-
if infra, err := util.GetInfrastructure(&c.listers.StorageListers); err != nil {
115+
if infra, err := util.GetInfrastructure(c.listers.StorageListers.Infrastructures); err != nil {
116116
return err
117117
} else if infra.Status.PlatformStatus.Type == configapiv1.OvirtPlatformType {
118118
storageClassName = "ovirt-csi-sc"

pkg/storage/azure/azure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
668668
return nil
669669
}
670670

671-
infra, err := util.GetInfrastructure(d.Listers)
671+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
672672
if err != nil {
673673
util.UpdateCondition(
674674
cr,

pkg/storage/gcs/gcs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (d *driver) getGCSClient() (*gstorage.Client, error) {
8585
func GetConfig(listers *regopclient.StorageListers) (*GCS, error) {
8686
gcsConfig := &GCS{}
8787

88-
infra, err := util.GetInfrastructure(listers)
88+
infra, err := util.GetInfrastructure(listers.Infrastructures)
8989
if err != nil {
9090
return nil, err
9191
}

pkg/storage/ibmcos/ibmcos.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (d *driver) UpdateEffectiveConfig() (*imageregistryv1.ImageRegistryConfigSt
105105
}
106106

107107
// Load infrastructure values
108-
infra, err := util.GetInfrastructure(d.Listers)
108+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
109109
if err != nil {
110110
return nil, err
111111
}
@@ -137,7 +137,7 @@ func (d *driver) UpdateEffectiveConfig() (*imageregistryv1.ImageRegistryConfigSt
137137
// resource key, and bucket.
138138
func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
139139
// Get Infrastructure spec
140-
infra, err := util.GetInfrastructure(d.Listers)
140+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
141141
if err != nil {
142142
return err
143143
}
@@ -685,7 +685,7 @@ func (d *driver) bucketExists(bucketName string, serviceInstanceCRN string) erro
685685
// getIBMCOSClient returns a client that allows us to interact
686686
// with the IBM COS service.
687687
func (d *driver) getIBMCOSClient(serviceInstanceCRN string) (*s3.S3, error) {
688-
infra, err := util.GetInfrastructure(d.Listers)
688+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
689689
if err != nil {
690690
return nil, err
691691
}

pkg/storage/oss/oss.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (d *driver) UpdateEffectiveConfig() error {
7070
}
7171

7272
// Load infrastructure values
73-
infra, err := util.GetInfrastructure(d.Listers)
73+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
7474
if err != nil {
7575
return err
7676
}
@@ -326,7 +326,7 @@ func (d *driver) StorageChanged(cr *imageregistryv1.Config) bool {
326326
// CreateStorage attempts to create an OSS bucket
327327
// and apply any provided tags
328328
func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
329-
infra, err := util.GetInfrastructure(d.Listers)
329+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
330330
if err != nil {
331331
return err
332332
}

pkg/storage/s3/s3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (d *driver) UpdateEffectiveConfig() error {
131131
}
132132

133133
// Load infrastructure values
134-
infra, err := util.GetInfrastructure(d.Listers)
134+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
135135
if err != nil {
136136
return err
137137
}
@@ -594,7 +594,7 @@ func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
594594
return err
595595
}
596596

597-
infra, err := util.GetInfrastructure(d.Listers)
597+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
598598
if err != nil {
599599
return err
600600
}

pkg/storage/storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func GetPlatformStorage(listers *regopclient.StorageListers) (imageregistryv1.Im
170170
var cfg imageregistryv1.ImageRegistryConfigStorage
171171
replicas := int32(1)
172172

173-
infra, err := util.GetInfrastructure(listers)
173+
infra, err := util.GetInfrastructure(listers.Infrastructures)
174174
if err != nil {
175175
return imageregistryv1.ImageRegistryConfigStorage{}, replicas, err
176176
}

pkg/storage/swift/swift.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func GetConfig(listers *regopclient.StorageListers) (*Swift, error) {
109109
}
110110

111111
var cloudName string
112-
cloudInfra, err := util.GetInfrastructure(listers)
112+
cloudInfra, err := util.GetInfrastructure(listers.Infrastructures)
113113
if err != nil {
114114
if !apimachineryerrors.IsNotFound(err) {
115115
return nil, fmt.Errorf("failed to get cluster infrastructure info: %v", err)
@@ -436,7 +436,7 @@ func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
436436
return err
437437
}
438438

439-
infra, err := util.GetInfrastructure(d.Listers)
439+
infra, err := util.GetInfrastructure(d.Listers.Infrastructures)
440440
if err != nil {
441441
return fmt.Errorf("failed to get cluster infrastructure info: %v", err)
442442
}

pkg/storage/util/util.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
configv1 "github.com/openshift/api/config/v1"
1313
imageregistryv1 "github.com/openshift/api/imageregistry/v1"
1414
operatorapi "github.com/openshift/api/operator/v1"
15+
configlisters "github.com/openshift/client-go/config/listers/config/v1"
1516

1617
regopclient "github.com/openshift/cluster-image-registry-operator/pkg/client"
1718
"github.com/openshift/cluster-image-registry-operator/pkg/defaults"
@@ -60,8 +61,8 @@ func UpdateCondition(cr *imageregistryv1.Config, conditionType string, status op
6061

6162
// GetInfrastructure gets information about the cloud platform that the cluster is
6263
// installed on including the Type, Region, and other platform specific information.
63-
func GetInfrastructure(listers *regopclient.StorageListers) (*configv1.Infrastructure, error) {
64-
return listers.Infrastructures.Get("cluster")
64+
func GetInfrastructure(lister configlisters.InfrastructureLister) (*configv1.Infrastructure, error) {
65+
return lister.Get("cluster")
6566
}
6667

6768
// GetValueFromSecret gets value for key in a secret
@@ -77,7 +78,7 @@ func GetValueFromSecret(sec *corev1.Secret, key string) (string, error) {
7778
// medium that the registry will use
7879
func GenerateStorageName(listers *regopclient.StorageListers, additionalInfo ...string) (string, error) {
7980
// Get the infrastructure name
80-
infra, err := GetInfrastructure(listers)
81+
infra, err := GetInfrastructure(listers.Infrastructures)
8182
if err != nil {
8283
return "", err
8384
}

test/e2e/aws_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestAWSDefaults(t *testing.T) {
6262
t.Fatalf("unable to get listers from mock lister: %v", err)
6363
}
6464

65-
infra, err := util.GetInfrastructure(&mockLister.StorageListers)
65+
infra, err := util.GetInfrastructure(mockLister.StorageListers.Infrastructures)
6666
if err != nil {
6767
t.Fatalf("unable to get install configuration: %v", err)
6868
}
@@ -335,7 +335,7 @@ func TestAWSUnableToCreateBucketOnStartup(t *testing.T) {
335335
t.Fatalf("unable to get listers from mock lister: %v", err)
336336
}
337337

338-
infra, err := util.GetInfrastructure(&mockLister.StorageListers)
338+
infra, err := util.GetInfrastructure(mockLister.StorageListers.Infrastructures)
339339
if err != nil {
340340
t.Fatalf("unable to get install configuration: %v", err)
341341
}
@@ -389,7 +389,7 @@ func TestAWSUpdateCredentials(t *testing.T) {
389389
t.Fatalf("unable to get listers from mock lister: %v", err)
390390
}
391391

392-
infra, err := util.GetInfrastructure(&mockLister.StorageListers)
392+
infra, err := util.GetInfrastructure(mockLister.StorageListers.Infrastructures)
393393
if err != nil {
394394
t.Fatalf("unable to get install configuration: %v", err)
395395
}
@@ -471,7 +471,7 @@ func TestAWSChangeS3Encryption(t *testing.T) {
471471
t.Fatalf("unable to get listers from mock lister: %v", err)
472472
}
473473

474-
infra, err := util.GetInfrastructure(&mockLister.StorageListers)
474+
infra, err := util.GetInfrastructure(mockLister.StorageListers.Infrastructures)
475475
if err != nil {
476476
t.Fatalf("unable to get install configuration: %v", err)
477477
}
@@ -676,7 +676,7 @@ func TestAWSFinalizerDeleteS3Bucket(t *testing.T) {
676676
t.Fatalf("unable to get listers from mock lister: %v", err)
677677
}
678678

679-
infra, err := util.GetInfrastructure(&mockLister.StorageListers)
679+
infra, err := util.GetInfrastructure(mockLister.StorageListers.Infrastructures)
680680
if err != nil {
681681
t.Fatalf("unable to get install configuration: %v", err)
682682
}

0 commit comments

Comments
 (0)