gmeghnag / omc

OpenShift Must-Gather Client
Apache License 2.0
153 stars 63 forks source link

Fixes #154: Getting resources with singular/short names #155

Closed clarku closed 6 months ago

clarku commented 6 months ago

When a qualified resource name is used in omc get, the <resourceType> variable is used to set a value in the vars.GetArgs object here. The code here uses the value of <resourceNamePlural>.<resourceGroup> to retrieve this value. A mismatch between the values of <resourceType> and <resourceNamePlural>.<resourceGroup> would cause the described bug in https://github.com/gmeghnag/omc/issues/154.

The resourceType variable is populated directly from the command line. Therefore, this mismatch will occur if the shortname or singular resource name is used as part of the qualified resource name.

For example with the MachineConfigPool resource, Command Result
omc get mcp.machineconfiguration.openshift.io master
omc get machineconfigpool.machineconfiguration.openshift.io master
omc get machineconfigpools.machineconfiguration.openshift.io master

This PR fixes this bug by using <resourceNamePlural>.<resourceGroup> to populate the vars.GetArgs argument where a resource with a specific name needs to be retrieved. This is for both theomc get <resource>/<name> and omc get <resource> <name> forms of retrieving a resource.