multipass icon indicating copy to clipboard operation
multipass copied to clipboard

Discern between images and blueprints in `multipass find`

Open sharder996 opened this issue 2 years ago • 1 comments

This PR adds the flags --images and --blueprints which modifies the behaviour of multipass find causing it to display only images or blueprints respectively. Additionally, when no flag is specified, multipass will make the distinction between images and blueprints by separating them. Sample output is as follows:

scott:build-debug$ bin/multipass find
Blueprint                   Aliases           Version          Description
anbox-cloud-appliance                         latest           Anbox Cloud Appliance
charm-dev                                     latest           A development and testing environment for charmers
docker                                        latest           A Docker environment with Portainer and related tools
jellyfin                                      latest           Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube                                      latest           minikube is local Kubernetes

Image                       Aliases           Version          Description
snapcraft:core18            18.04             20201111         Snapcraft builder for Core 18
snapcraft:core20            20.04             20210921         Snapcraft builder for Core 20
snapcraft:core22            22.04             20220426         Snapcraft builder for Core 22
snapcraft:devel                               20220808         Snapcraft builder for the devel series
core                        core16            20200818         Ubuntu Core 16
core18                                        20211124         Ubuntu Core 18
18.04                       bionic            20220712         Ubuntu 18.04 LTS
20.04                       focal,lts         20220810         Ubuntu 20.04 LTS
22.04                       jammy             20220810         Ubuntu 22.04 LTS
daily:22.10                 devel,kinetic     20220808         Ubuntu 22.10
appliance:adguard-home                        20200812         Ubuntu AdGuard Home Appliance
appliance:mosquitto                           20200812         Ubuntu Mosquitto Appliance
appliance:nextcloud                           20200812         Ubuntu Nextcloud Appliance
appliance:openhab                             20200812         Ubuntu openHAB Home Appliance
appliance:plexmediaserver                     20200812         Ubuntu Plex Media Server Appliance
scott:build-debug$ bin/multipass find --images
Image                       Aliases           Version          Description
snapcraft:core18            18.04             20201111         Snapcraft builder for Core 18
snapcraft:core20            20.04             20210921         Snapcraft builder for Core 20
snapcraft:core22            22.04             20220426         Snapcraft builder for Core 22
snapcraft:devel                               20220808         Snapcraft builder for the devel series
core                        core16            20200818         Ubuntu Core 16
core18                                        20211124         Ubuntu Core 18
18.04                       bionic            20220712         Ubuntu 18.04 LTS
20.04                       focal,lts         20220810         Ubuntu 20.04 LTS
22.04                       jammy             20220810         Ubuntu 22.04 LTS
daily:22.10                 devel,kinetic     20220808         Ubuntu 22.10
appliance:adguard-home                        20200812         Ubuntu AdGuard Home Appliance
appliance:mosquitto                           20200812         Ubuntu Mosquitto Appliance
appliance:nextcloud                           20200812         Ubuntu Nextcloud Appliance
appliance:openhab                             20200812         Ubuntu openHAB Home Appliance
appliance:plexmediaserver                     20200812         Ubuntu Plex Media Server Appliance
scott:build-debug$ bin/multipass find --blueprints
Blueprint                   Aliases           Version          Description
anbox-cloud-appliance                         latest           Anbox Cloud Appliance
charm-dev                                     latest           A development and testing environment for charmers
docker                                        latest           A Docker environment with Portainer and related tools
jellyfin                                      latest           Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube                                      latest           minikube is local Kubernetes
scott:build-debug$ bin/multipass find daily:
Blueprint                   Aliases           Version          Description
No blueprints found.

Image                       Aliases           Version          Description
daily:18.04                 bionic            20220810         Ubuntu 18.04 LTS
daily:20.04                 focal,lts         20220810         Ubuntu 20.04 LTS
daily:22.04                 jammy             20220810         Ubuntu 22.04 LTS
daily:22.10                 devel,kinetic     20220808         Ubuntu 22.10
scott:build-debug$ bin/multipass find docker
Blueprint                   Aliases           Version          Description
docker                                        latest           A Docker environment with Portainer and related tools

Image                       Aliases           Version          Description
No images found.

Note: this output is an initial first draft of what this new form of output will look like and suggestions on how to make it better are welcome!

Fixes #2678

sharder996 avatar Aug 10 '22 22:08 sharder996

Codecov Report

Merging #2701 (1e62841) into main (48df08c) will increase coverage by 0.06%. The diff coverage is 94.88%.

@@            Coverage Diff             @@
##             main    #2701      +/-   ##
==========================================
+ Coverage   86.83%   86.89%   +0.06%     
==========================================
  Files         231      231              
  Lines       11982    12042      +60     
==========================================
+ Hits        10404    10464      +60     
  Misses       1578     1578              
Impacted Files Coverage Δ
include/multipass/vm_blueprint_provider.h 100.00% <ø> (ø)
src/client/cli/cmd/find.cpp 93.87% <77.77%> (+12.48%) :arrow_up:
src/daemon/daemon.cpp 62.83% <88.67%> (-0.15%) :arrow_down:
src/daemon/default_vm_image_vault.cpp 86.14% <92.85%> (+0.62%) :arrow_up:
...lude/multipass/exceptions/image_vault_exceptions.h 100.00% <100.00%> (ø)
...ueprint_provider/default_vm_blueprint_provider.cpp 99.22% <100.00%> (+0.01%) :arrow_up:
src/client/cli/formatter/csv_formatter.cpp 100.00% <100.00%> (ø)
src/client/cli/formatter/json_formatter.cpp 100.00% <100.00%> (ø)
src/client/cli/formatter/table_formatter.cpp 99.37% <100.00%> (+0.07%) :arrow_up:
src/client/cli/formatter/yaml_formatter.cpp 100.00% <100.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Aug 10 '22 23:08 codecov[bot]

Hey Scott, I think this looks good. One thing I would change is putting the images first in the results. I am debating what to do with the Ubuntu Core appliances. They are images, but they are more aligned with Blueprints in terms of intended usage. I think for now they are ok to keep in the images section.

nathan-j-hart avatar Jan 26 '23 09:01 nathan-j-hart

Looking at the output, I think it would be good to add a newline at the end as well, to match the newline separating sections.

ricab avatar Jan 26 '23 10:01 ricab

Hey @nathan-j-hart, iirc the intention behind putting blueprints first was an effort to promote them.

sharder996 avatar Jan 27 '23 20:01 sharder996

Ok, that makes some sense, but I do think that the majority of users will want to launch a bare OS first. Putting Blueprints first may be confusing / frustrating.

nathan-j-hart avatar Jan 31 '23 10:01 nathan-j-hart

Regarding order, I think it would be best to put the "regular" Ubuntu images at the top, ordered most recent to oldest. I think that should be consistent with what people are looking for when they want to find an image. I am on the fence about keeping it in chronological order or putting the most recent LTS first, but leaning towards keeping it chronological. Perhaps we can come up with another way to highlight the most recent LTS as the preferred/default option?

nathan-j-hart avatar Jan 31 '23 10:01 nathan-j-hart

I would also prefer showing images first. It makes more sense to me, it is like starting the story at the beginning. Other than that, we currently sort the output alphabetically, in this and other commands. That is certainly something we can revisit, but I think we can separate that decision from this PR.

I will point out: I am not quite sure that what comes first is what's more prominent in the user's eye. Unlike other media, a terminal moves down to the next prompt and leaves the last part of the previous command's output right in front of the eyes. If the output is long enough, the beginning gets cut off. If we wanted, we could change this by automatically opening a pager (i.e. pipping the output to less). That's what git does with some commands. But I imagine we have other priorities.

ricab avatar Jan 31 '23 11:01 ricab

@nathan-j-hart @ricab Updated order of blueprints/images and updated PR description to reflect the changes.

sharder996 avatar Feb 16 '23 18:02 sharder996

This looks good to me. Nice job Scott!

nathan-j-hart avatar Feb 23 '23 14:02 nathan-j-hart

This is going to fail to bors because it need this change first

bors cancel

sharder996 avatar Mar 13 '23 14:03 sharder996

Canceled.

bors[bot] avatar Mar 13 '23 14:03 bors[bot]

Ok, should work now

bors r+

sharder996 avatar Mar 13 '23 14:03 sharder996

bors cancel

ricab avatar Mar 13 '23 14:03 ricab

Canceled.

bors[bot] avatar Mar 13 '23 14:03 bors[bot]

Hey @sharder996, cancelled so that bors records the right reviewer. You can use "bors retry" in such situations.

bors r+

ricab avatar Mar 13 '23 14:03 ricab

Build failed:

bors[bot] avatar Mar 13 '23 14:03 bors[bot]

bors r+

ricab avatar Mar 13 '23 16:03 ricab

Canceled.

bors[bot] avatar Mar 13 '23 18:03 bors[bot]

bors retry

sharder996 avatar Mar 13 '23 18:03 sharder996

Timed out.

bors[bot] avatar Mar 13 '23 21:03 bors[bot]

bors retry

sharder996 avatar Mar 14 '23 03:03 sharder996

Build failed (retrying...):

bors[bot] avatar Mar 14 '23 07:03 bors[bot]

Build failed:

bors[bot] avatar Mar 14 '23 07:03 bors[bot]

bors retry

ricab avatar Mar 14 '23 15:03 ricab

This PR was included in a batch that timed out, it will be automatically retried

bors[bot] avatar Mar 14 '23 22:03 bors[bot]

Timed out.

bors[bot] avatar Mar 15 '23 04:03 bors[bot]