Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nil check for IPConfigurationPropertiesFormat #340

Merged
merged 1 commit into from
May 17, 2022

Conversation

sergenyalcin
Copy link
Contributor

@sergenyalcin sergenyalcin commented May 13, 2022

Description of your changes

This PR fixes the nil pointer issue for the PublicIPAddress resource. When IPConfiguration field is not nil, we need to check whether the IPConfigurationPropertiesFormat (embedded) is nil because we are trying to access the fields of the embedded struct. For example; PrivateIPAllocationMethod, PrivateIPAddress, ProvisioningState.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

This PR was tested by filling manually the IPConfiguration field. Then the nil pointer issue was not observed.

Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
@@ -182,7 +182,7 @@ func GeneratePublicIPAddressObservation(az networkmgmt.PublicIPAddress) *v1alpha
v.ID = azure.ToString(az.ID)
v.Address = azure.ToString(az.IPAddress)
v.Version = string(az.PublicIPAddressVersion)
if az.IPConfiguration != nil {
if az.PublicIPAddressPropertiesFormat != nil && az.PublicIPAddressPropertiesFormat.IPConfiguration != nil && az.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat != nil {
v.IPConfiguration = &v1alpha3.IPConfiguration{
PrivateIPAllocationMethod: string(az.IPConfiguration.PrivateIPAllocationMethod),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all the referenced fields (PrivateIPAllocationMethod, PrivateIPAddress and ProvisioningState) embedded by the same struct (IPConfigurationPropertiesFormat)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ulucinar I checked, all the referenced fields are embedded by the same struct.

@ulucinar
Copy link
Collaborator

Thank you @sergenyalcin!

@ulucinar ulucinar merged commit 8714e68 into crossplane-contrib:master May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants