runwhen-contrib / rw-public-codecollection

RunWhen Public Codecollection Repository - Open Source troubleshooting runbook library for Kubernetes and cloud infrastructure components.
https://registry.runwhen.com
Apache License 2.0
40 stars 5 forks source link

[Enhancement] k8s-kubectl-get assumes should support single results #72

Open stewartshea opened 1 year ago

stewartshea commented 1 year ago

Observation The k8s-kubectl-get codebundle has a hardcoded search prefix that assumes the result data is returned as a list, which isn't always the case. We need to adjust the keyword to support both single results and list results.

Current Outcome Currently a list must be returned by the kube api server.

Desired Outcome Support both single results and a list of results from the kube api server .

jon-funk commented 1 year ago

We should be able to add a conditional which checks for the list initially using search_json, and if this fails (returns None) we can fall back to singular, etc, and then continue on with the rest of the search pattern provided.

stewartshea commented 1 year ago

Yup, that's the idea I had in mind.