Adding utils.format_quantity
What type of PR is this?
/kind feature
What this PR does / why we need it:
PR adds a utils.format_quantity, which converts a decimal number into a canonical kubernetes quantity.
There is already utils.parse_quantity which I used in my project, but I also needed a way to convert a Decimal number back into a Kubernetes quantity. This PR proposes to add this functionality to the Python K8s client.
Which issue(s) this PR fixes:
Fixes #2205
Special notes for your reviewer:
I couldn't find any tests for the utils modules, neither the parse_quantity function. I'd be very happy to add some tests for format_quantity, but so far I just didn't find the right place for them. Please let me know where I should put them.
Does this PR introduce a user-facing change?
Adding `utils.format_quantity` to convert decimal numbers into a canonical Kubernetes quantity.
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
I think that's not applicable for this change - I'm not sure though.
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: rkschamer / name: René Kschamer (76ffd7139bab637485196e1e7fabd499c9a148ab, d1deeebf7ebdd93661255f6bf583d1c42846b5e5, 0f3f8eca8fbd770afacd62c9d13233d688fbb22f)
Welcome @rkschamer!
It looks like this is your first PR to kubernetes-client/python 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.
You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.
You can also check if kubernetes-client/python has its own contribution guidelines.
You may want to refer to our testing guide if you run into trouble with your tests not passing.
If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!
Thank you, and welcome to Kubernetes. :smiley:
/kind feature
I couldn't find any tests for the utils modules, neither the parse_quantity function. I'd be very happy to add some tests for format_quantity, but so far I just didn't find the right place for them. Please let me know where I should put them.
You could use https://github.com/kubernetes-client/python/blob/master/kubernetes/e2e_test/test_utils.py
Perfect, thank you. I've now added the tests for format_quantity and also took the liberty to add a test for parse_quantity. Since pytest haven't been used in test_utils.py I refrained from using @pytest.mark.parametrize. Please let me know if I should change this.
With the tests, I now consider my change as ready for review and hence, I've also changed to an actual PR.
Hi @roycaihw,
I don't want to be pushy, but do you think, you can have a look on the PR?
Thank you, René
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.
This bot triages PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the PR is closed
You can:
- Mark this PR as fresh with
/remove-lifecycle stale - Close this PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.
This bot triages PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the PR is closed
You can:
- Mark this PR as fresh with
/remove-lifecycle stale - Close this PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
I appreciate any review on the PR.
/remove-lifecycle stale
Dear reviewers, can you help to review this PR?
Much appreciated.
/assign @kubernetes/sig-pr-reviews /remove-lifecycle rotten /help
thanks for the PR
/lgtm /approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: rkschamer, yliaog
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [yliaog]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment