Skip to content

Commit 0ecaaab

Browse files
committed
Add nil validation for IBM Cloud and Power VS infrastructure status in ibmcos
1 parent 2089184 commit 0ecaaab

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/storage/ibmcos/ibmcos.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ func (d *driver) UpdateEffectiveConfig() (*imageregistryv1.ImageRegistryConfigSt
112112

113113
var clusterLocation string
114114
if infra.Status.PlatformStatus != nil {
115-
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType {
115+
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType && infra.Status.PlatformStatus.IBMCloud != nil {
116116
clusterLocation = infra.Status.PlatformStatus.IBMCloud.Location
117117
}
118-
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType {
118+
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType && infra.Status.PlatformStatus.PowerVS != nil {
119119
clusterLocation, err = cosRegionForPowerVSRegion(infra.Status.PlatformStatus.PowerVS.Region)
120120
if err != nil {
121121
return nil, err
@@ -144,11 +144,11 @@ func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
144144

145145
// Set configs from Infrastructure
146146
if infra.Status.PlatformStatus != nil {
147-
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType {
147+
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType && infra.Status.PlatformStatus.IBMCloud != nil {
148148
d.Config.Location = infra.Status.PlatformStatus.IBMCloud.Location
149149
d.Config.ResourceGroupName = infra.Status.PlatformStatus.IBMCloud.ResourceGroupName
150150
}
151-
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType {
151+
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType && infra.Status.PlatformStatus.PowerVS != nil {
152152
d.Config.Location, err = cosRegionForPowerVSRegion(infra.Status.PlatformStatus.PowerVS.Region)
153153
if err != nil {
154154
return err
@@ -692,10 +692,10 @@ func (d *driver) getIBMCOSClient(serviceInstanceCRN string) (*s3.S3, error) {
692692

693693
IBMCOSLocation := imageregistryv1.ImageRegistryConfigStorageIBMCOS{}.Location
694694
if infra.Status.PlatformStatus != nil {
695-
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType {
695+
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType && infra.Status.PlatformStatus.IBMCloud != nil {
696696
IBMCOSLocation = infra.Status.PlatformStatus.IBMCloud.Location
697697
}
698-
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType {
698+
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType && infra.Status.PlatformStatus.PowerVS != nil {
699699
IBMCOSLocation, err = cosRegionForPowerVSRegion(infra.Status.PlatformStatus.PowerVS.Region)
700700
if err != nil {
701701
return nil, err

0 commit comments

Comments
 (0)