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 limit and request availability with -a with json and yaml #174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elyesbenamor
Copy link

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 requestsAvailable and limitsAvailable to listResourceOutput struct
  • Updated buildListResourceOutput to calculate and populate available resources
  • These fields are only included in the output when using the -a flag

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"
      }
    }
  ]
}

@elyesbenamor
Copy link
Author

@robscott Here is a detailed MR that can be reviewed please

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.

Option --available is not supported in combinaison with yaml or json output
1 participant