Skip to content

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

@robscott
Copy link
Owner

Hey @elyesbenamor, thanks for the contribution! Any chance you can rebase this PR?

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

2 participants