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) : edit(), patch() and other mutating operations shouldn't be allowed in NonNamespaceOperation (#3772) #3798

Merged
merged 1 commit into from Feb 4, 2022

Conversation

rohanKanojia
Copy link
Member

Description

Fix #3772

Remove reference to WritableOperation<T> interface from
NonNamespaceOperation as it exposes edit(), patch() and other
mutating operations.

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

…ations shouldn't be allowed in NonNamespaceOperation (fabric8io#3772)

Remove reference to `WritableOperation<T>` interface from
NonNamespaceOperation as it exposes `edit()`, `patch()` and other
mutating operations.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@sonarcloud
Copy link

sonarcloud bot commented Feb 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rohanKanojia rohanKanojia marked this pull request as ready for review February 3, 2022 17:02
@manusa manusa added this to the 5.12.1 milestone Feb 4, 2022
@manusa manusa merged commit 89ec394 into fabric8io:master Feb 4, 2022
@rohanKanojia rohanKanojia deleted the pr/issue3772 branch February 4, 2022 10:51
@shawkins
Copy link
Contributor

shawkins commented Feb 4, 2022

@rohanKanojia @manusa One small possibility is to allow the methods that pass in an object to not require withName as it can be inferred.

@manusa
Copy link
Member

manusa commented Feb 7, 2022

I created the issue for the edit and patch methods.

I assume that the PR just reverted the interface implementation to what it was before introducing the issue, right @rohanKanojia?

One small possibility is to allow the methods that pass in an object to not require withName as it can be inferred.

Yes. IIRC this was already possible before this PR was merged, so just adding the interfaces would be enough.

@rohanKanojia
Copy link
Member Author

I think these edit, patch interfaces were not part of NonNamespaceOperation before 5.2.0 . They were added by me during dry run implementation

https://github.com/fabric8io/kubernetes-client/blob/v5.1.0/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java

@manusa
Copy link
Member

manusa commented Feb 7, 2022

I was asking namely about replace. I understand that this one supports being called without withName.

@rohanKanojia
Copy link
Member Author

I'm not able to find replace available in NonNamespaceOperation in v5.1.0

Screenshot from 2022-02-07 19-07-54

@manusa
Copy link
Member

manusa commented Feb 7, 2022

This was introduced in the mentioned PR (#2832). However, this operation IIRC should work, since the name can be inferred from the resource.

In the current PR, you removed this. I'm assuming because of this. The issue only mentioned patch/edit, I only merged the PR because I was assuming this was the prior behavior.

So, as Steven suggested, this operation (I wouldn't do this for patch, only for replace) could be added back. And if I'm not mistaken, for the replace implementation, we already have the logic to retrieve the name, so it should be as simple as adding the interface in the right place.

Does this sound clearer now?

rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this pull request Feb 7, 2022
…espaceOperation

This was introduced by mistake in Dry Run implementation as part of
WritableOperation and was subsequently removed in
fabric8io#3798

But it makes sense for replace operation to work without name. It can be
inferred from the passed object.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this pull request Feb 7, 2022
…espaceOperation

This was introduced by mistake in Dry Run implementation as part of
WritableOperation and was subsequently removed in
fabric8io#3798

But it makes sense for replace operation to work without name. It can be
inferred from the passed object.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this pull request Feb 7, 2022
…espaceOperation

This was introduced by mistake in Dry Run implementation as part of
WritableOperation and was subsequently removed in
fabric8io#3798

But it makes sense for replace operation to work without name. It can be
inferred from the passed object.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit that referenced this pull request Feb 8, 2022
…espaceOperation

This was introduced by mistake in Dry Run implementation as part of
WritableOperation and was subsequently removed in
#3798

But it makes sense for replace operation to work without name. It can be
inferred from the passed object.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit to manusa/kubernetes-client that referenced this pull request Apr 5, 2022
…espaceOperation

This was introduced by mistake in Dry Run implementation as part of
WritableOperation and was subsequently removed in
fabric8io#3798

But it makes sense for replace operation to work without name. It can be
inferred from the passed object.

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

(cherry picked from commit ea07b7f)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
manusa pushed a commit to manusa/kubernetes-client that referenced this pull request Apr 5, 2022
…espaceOperation

This was introduced by mistake in Dry Run implementation as part of
WritableOperation and was subsequently removed in
fabric8io#3798

But it makes sense for replace operation to work without name. It can be
inferred from the passed object.

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

(cherry picked from commit ea07b7f)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
manusa pushed a commit that referenced this pull request Apr 5, 2022
…espaceOperation

This was introduced by mistake in Dry Run implementation as part of
WritableOperation and was subsequently removed in
#3798

But it makes sense for replace operation to work without name. It can be
inferred from the passed object.

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

(cherry picked from commit ea07b7f)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
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.

edit() should not be allowed as a ~~NonNamespaceOperation~~
3 participants