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

fix: expose util for rest status return #3310

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

rikatz
Copy link
Contributor

@rikatz rikatz commented Dec 11, 2023

Closes: #3309

Description

During the implementation of kubernetes-sigs/cluster-api-provider-vsphere#2535 we have realized it is hard to check what was the error returned from the rest/http layer of vAPI.

This PR creates a util function that can be used to check if a returned error from rest contains a specific http Status code.

Closes: #3309

Type of change

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update
  • Build related change

How Has This Been Tested?

Extended current rest Session test to also do an invalid internal call and check the returned error

Checklist:

  • My code follows the CONTRIBUTION guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

@rikatz
Copy link
Contributor Author

rikatz commented Dec 11, 2023

Hum, this error is not related with my change

Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Thanks @rikatz , lgtm. This should also close #1639
We were thinking exposing the error type, but IsStatusError is simpler and we can revisit exposing the type later if needed.

@rikatz
Copy link
Contributor Author

rikatz commented Dec 11, 2023

Thanks Doug, merging here

@rikatz rikatz merged commit e54d539 into vmware:main Dec 11, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose error type checker for rest client
3 participants