ocm describe cluster does not work with %user%
Closed this issue · 3 comments
this format works for ocm list cluster
and ocm cluster login
, if it's possible to use it in describe that would be great
Interesting, the way this currently works in a few commands is the string gets interpolated into a like
API query e.g. search=name like '...' or id like '...'
, which supports SQL-like %
wildcards.
Debatable whether bug or feature, but we do already document "%test%" in a few --help texts, so that's decided 😉
$ ocm list cluster %aaaa%
ID NAME API URL OPENSHIFT_VERSION PRODUCT ID CLOUD_PROVIDER REGION ID STATE
17hdunrj3mlfl6o05akaaaaoe3ma674l 60f1ac56-4c33-4162-b186-35bd NONE NONE ocp NONE NONE ready
17krceg9jhcjv0psi16u1u2go7ljjajb 384f53d9-116d-4827-aaaa-a7ff NONE 4.2.0-0.okd-2019-0 ocp NONE NONE ready
However, ocm list cluster
already supplies % on both sides in the query, so they can be omitted:
$ ocm list cluster aaaa
ID NAME API URL OPENSHIFT_VERSION PRODUCT ID CLOUD_PROVIDER REGION ID STATE
17hdunrj3mlfl6o05akaaaaoe3ma674l 60f1ac56-4c33-4162-b186-35bd NONE NONE ocp NONE NONE ready
17krceg9jhcjv0psi16u1u2go7ljjajb 384f53d9-116d-4827-aaaa-a7ff NONE 4.2.0-0.okd-2019-0 ocp NONE NONE ready
$ ocm list cluster aaaa --debug
...
I0623 11:34:37.781306 590334 dump.go:138] Request URL is 'https://api.stage.openshift.com/api/clusters_mgmt/v1/clusters?page=1&search=name+like+%27%25aaaa%25%27+or+id+like+%27%25aaaa%25%27&size=100'
...
Still, it can be useful in the middle:
$ ocm list cluster aa%aaa 2021-06-23T11:39:03+03:00
ID NAME API URL OPENSHIFT_VERSION PRODUCT ID CLOUD_PROVIDER REGION ID STATE
17q2j923bp0297hmj372i74sr076194b 1aa31aaa-cfce-419c-b1ea-811a NONE NONE ocp NONE NONE ready
ocm describe cluster currently queries for exactly 1 cluster, using search=name = '...' or id = '...' or external_id = '...'
and limiting size=1
in the unlikely case of multiple matches (which wins is pretty arbitrary, not ideal).
If it were to support % queries, it should rather loop over all results, describing them all (with say empty line or ---
between them).
Given precedent of kubectl describe
working on multiple objects, I think this makes sense 👍
PRs welcome :)
Not sure I have bandwidth for it so if someone wants to pickup the glove / future me feel free to PR
thanks @cben for your detailed response!
Seems this is holding on for a while and I don't have any complaints on my end :)