Open cjdcordeiro opened 3 weeks ago
Are you restricted to using bash or a language without json parsing available?
As a workaround, you can do the following, because if pro
is available then python3
must also be available.
pro api u.pro.status.is_attached.v1 | python3 -c "import sys, json; print(json.load(sys.stdin)['data']['attributes']['is_attached'])"
or alternatively
python3 -c "from uaclient.api.u.pro.status.is_attached.v1 import is_attached; print(is_attached().is_attached)"
@orndorffgrant your options are a good start. many systems have jq
installed by default as well which can give a non-zero exit code directly.
pro api u.pro.status.is_attached.v1 | jq --exit-status .data.attributes.is_attached
No restrictions here, at least for now (I could speculate some chiselled/distroless cases where utilities might be limited).
This is a suggestion for improvement, as it feels like other programs using the Pro client should rely on it to just provide a yes/no answer on this "status" question (e.g. something like pebble health
)
Please describe the scenario where the new feature would be useful
In situations where we programmatically use the
pro
client, it would be much easier if there was a dedicated CLI command or options that would simply return a boolean response to whether the machine is attached or not. Today we have to do this by parsing the output ofpro status
orpro api u.pro.status.is_attached.v1
which may introduce an additional dependency (likejq
) and forces the users/programs to know exactly which key provides the value ofDescribe the solution you'd like
Ideally a new command like
pro is-attached
or maybe an optionpro status --is-attached
.Current behavior
Currently need to
pro api u.pro.status.is_attached.v1 | jq .is_attached
.