kube-capacity
kube-capacity copied to clipboard
fix limit and request availability with -a with json and yaml
Closes #92
Add Available Resources to JSON/YAML Output
Description
Currently, when using the -a flag with JSON/YAML output formats, the available resources are not displayed in a clear format. This PR adds new fields requestsAvailable and limitsAvailable to show available resources explicitly while maintaining backward compatibility.
Changes
- Added new fields
requestsAvailableandlimitsAvailableto listResourceOutput struct - Updated buildListResourceOutput to calculate and populate available resources
- These fields are only included in the output when using the
-aflag
Examples
Without -a flag (unchanged):
{
"nodes": [
{
"name": "minikube",
"cpu": {
"requests": "1350m",
"requestsPercent": "11%",
"limits": "700m",
"limitsPercent": "5%"
},
"memory": {
"requests": "522Mi",
"requestsPercent": "6%",
"limits": "362Mi",
"limitsPercent": "4%"
}
}
]
}
### With `-a` flag (unchanged):
{
"nodes": [
{
"name": "minikube",
"cpu": {
"requests": "1350m",
"requestsPercent": "11%",
"requestsAvailable": "10650m",
"limits": "700m",
"limitsPercent": "5%",
"limitsAvailable": "11300m"
},
"memory": {
"requests": "522Mi",
"requestsPercent": "6%",
"requestsAvailable": "7315Mi",
"limits": "362Mi",
"limitsPercent": "4%",
"limitsAvailable": "7475Mi"
}
}
]
}
@robscott Here is a detailed MR that can be reviewed please
Hey @elyesbenamor, thanks for the contribution! Any chance you can rebase this PR?