Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: offer boolean CLI command for knowing if machine is attached #3287

Open
cjdcordeiro opened this issue Aug 29, 2024 · 3 comments
Open
Labels
feature idea for a new feature P - Low S - Triaged Must have priority label

Comments

@cjdcordeiro
Copy link

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 of pro status or pro api u.pro.status.is_attached.v1 which may introduce an additional dependency (like jq) and forces the users/programs to know exactly which key provides the value of

Describe the solution you'd like

Ideally a new command like pro is-attached or maybe an option pro status --is-attached.

Current behavior

Currently need to pro api u.pro.status.is_attached.v1 | jq .is_attached.

@cjdcordeiro cjdcordeiro added the feature idea for a new feature label Aug 29, 2024
@orndorffgrant
Copy link
Collaborator

orndorffgrant commented Aug 30, 2024

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)"

@rpocase
Copy link

rpocase commented Sep 16, 2024

@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

@cjdcordeiro
Copy link
Author

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)

@orndorffgrant orndorffgrant added S - Triaged Must have priority label P - Low labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature idea for a new feature P - Low S - Triaged Must have priority label
Projects
None yet
Development

No branches or pull requests

3 participants