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 (kubernetes-client) : Throw exception when HasMetadata is used in resources(...) API (#3990) #4133

Merged
merged 1 commit into from
May 18, 2022

Conversation

rohanKanojia
Copy link
Member

Description

Fix #3990

Access to resources(...) DSL method with generic HasMetadata interface
shouldn't be allowed.

Signed-off-by: Rohan Kumar rohaan@redhat.com

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@rohanKanojia rohanKanojia marked this pull request as ready for review May 10, 2022 13:27
@shawkins
Copy link
Contributor

This was somewhat fixed by other upstream changes - you no longer get an npe, but an invalid url /api/v1/hasmetadatas

We could be doing a similar check for CustomResource or in general not allow any interface or abstract class. Generic is different in that it's a concrete class. It's hard in general for us to determine that a particular concrete class is invalid as a resource - the underlying logic is tolerant to both the group and version annotations being missing in which case the Config.getApiVersion is used.

@rohanKanojia
Copy link
Member Author

I had pointed this out in #3990 (comment)

Shall I add an additional check to throw IllegalArgumentException in case any interface is provided in resources(..) method?

@shawkins
Copy link
Contributor

Shall I add an additional check to throw IllegalArgumentException in case any interface is provided in resources(..) method?

Yes a check for interfaces or abstract would cover the HasMetadata case as well.

@manusa
Copy link
Member

manusa commented May 11, 2022

This was somewhat fixed by other upstream changes - you no longer get an npe, but an invalid url /api/v1/hasmetadatas

The fix should address the comment #3990 (comment)

which should mostly deal with UX. Users who perform such a call should get an explicit message stating that the operation is forbidden, and the suggested fix/alternative operation

Copy link
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

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

LGTM

…in `resources(...)` API (fabric8io#3990)

Access to `resources(...)` DSL method with generic HasMetadata interface
shouldn't be allowed.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa added this to the 6.0.0 milestone May 18, 2022
@sonarcloud
Copy link

sonarcloud bot commented May 18, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@manusa manusa merged commit aa89c52 into fabric8io:master May 18, 2022
@rohanKanojia rohanKanojia deleted the pr/issue3990 branch May 18, 2022 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants