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

Parsing different quantity formats #1895

Closed
avmohan opened this issue Dec 6, 2019 · 7 comments
Closed

Parsing different quantity formats #1895

avmohan opened this issue Dec 6, 2019 · 7 comments
Assignees

Comments

@avmohan
Copy link

avmohan commented Dec 6, 2019

Is there an equivalent of https://github.com/kubernetes/apimachinery/blob/adc6f4cd9e7d28fc1c1e5efc658d940d55c0f356/pkg/api/resource/quantity.go in java?

@rohanKanojia
Copy link
Member

rohanKanojia commented Dec 6, 2019

I think we have a class, try searching class named Quantity .

@avmohan
Copy link
Author

avmohan commented Dec 6, 2019

@avmohan
Copy link
Author

avmohan commented Dec 11, 2019

To clarify I was looking for something equivalent to https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/custom/Quantity.java

So that client can have behavior like Quantity (".5Mi") equals Quantity ("512Ki")
Do you think it's a good addition?

@rohanKanojia
Copy link
Member

Yes, I do think it's a valuable addition.

Our Quanity.java has been deprecated as per latest kubernetes releases. We need to modify it. Actually it's already there in model for parsing go structs, but https://github.com/kubernetes/apimachinery/blob/adc6f4cd9e7d28fc1c1e5efc658d940d55c0f356/pkg/api/resource/quantity.go doesn't follow standard kubernetes types format. Our go script assumes all structs in types.go, I think we need to manually generate Quantity.java for this to work.

@rohanKanojia
Copy link
Member

seemd related to #885

@rohanKanojia rohanKanojia self-assigned this Dec 30, 2019
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Dec 31, 2019
Added a normalize method and equals() method so that Quantity objects
could be compared by converting to normalized versions.
@rohanKanojia
Copy link
Member

@avmohan : Hi, I've created a PR to support this use case of comparing different Quantity objects of different formats. Could you please see if this would fulfil your use case or you are looking for something more flexible(like converting Quantities from one to other as implemented in official client)?

@avmohan
Copy link
Author

avmohan commented Jan 3, 2020

Thanks @rohanKanojia . This would work.

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

No branches or pull requests

2 participants