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

Add support for all-projects to incus image list and API #400

Conversation

MaheshPunjabi
Copy link
Contributor

@MaheshPunjabi MaheshPunjabi commented Jan 18, 2024

incus image list --all-projects
+------------------------+-------+--------------+--------+--------------------------------------+--------------+-----------+-----------+-----------------------------+
|        PROJECT         | ALIAS | FINGERPRINT  | PUBLIC |             DESCRIPTION              | ARCHITECTURE |   TYPE    |   SIZE    |         UPLOAD DATE         |
+------------------------+-------+--------------+--------+--------------------------------------+--------------+-----------+-----------+-----------------------------+
| default                |       | 4183ea2d1572 | no     | Ubuntu jammy amd64 (20240202_07:42)  | x86_64       | CONTAINER | 119.16MiB | Feb 2, 2024 at 3:40pm (UTC) |
+------------------------+-------+--------------+--------+--------------------------------------+--------------+-----------+-----------+-----------------------------+
| isolated-image-project |       | 826ea49a23d5 | no     | Ubuntu focal amd64 (20240202_07:42)  | x86_64       | CONTAINER | 116.56MiB | Feb 2, 2024 at 2:47pm (UTC) |
+------------------------+-------+--------------+--------+--------------------------------------+--------------+-----------+-----------+-----------------------------+
| isolated-image-project |       | b19f914bc653 | no     | Ubuntu mantic amd64 (20240202_07:42) | x86_64       | CONTAINER | 121.15MiB | Feb 2, 2024 at 2:46pm (UTC) |
+------------------------+-------+--------------+--------+--------------------------------------+--------------+-----------+-----------+-----------------------------+
| isolated-image-project |       | eb3294bde5ef | no     | Ubuntu bionic amd64 (20240202_07:42) | x86_64       | CONTAINER | 108.19MiB | Feb 2, 2024 at 3:40pm (UTC) |
+------------------------+-------+--------------+--------+--------------------------------------+--------------+-----------+-----------+-----------------------------+
curl --unix-socket /var/lib/incus/unix.socket incus/1.0/images?all-projects=true | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   423  100   423    0     0  72159      0 --:--:-- --:--:-- --:--:-- 84600
{
  "type": "sync",
  "status": "Success",
  "status_code": 200,
  "operation": "",
  "error_code": 0,
  "error": "",
  "metadata": [
    "/1.0/images/e5e192274efc8503436c81582d3f2bd0cea32cfcb6474c73e3bd807535bc4dcf",
    "/1.0/images/b176f45e4193026c02df29de34fb113491c123a8c0edde778f5048a6a1a108c3",
    "/1.0/images/b99e5a672bccbee9bbe7d88595e348efc0f5d68083666e7cc80d7c5aeb6cdc6c",
    "/1.0/images/f0dda6b9661893d499ffc73943a98b8cac29ba7cd8e19e88993631f1b085187b"
  ]
}

What was changed?

Following guidance from issue 390 with a couple of additional changes to support project column in output.

  • api: images_all_projects :

  • new API extension to both internal/version/api.go and doc/api-extensions.md

  • incusd/images: Add support for all_projects:

  • Add support for all-projects to cmd/incusd/images.go for the imagesGet function.

  • Include adding the all-projects to the swagger comments on imagesGet.

  • Also, add Project field to Image struct and update value in GetImageByFingerprintPrefix in shared/api/image.go and internal/server/db/images.go respectively

  • doc/rest-api: Refresh swagger YAML

  • Re-generate the swagger YAML data

  • client: Add GetImagesAllProjects

  • Add a new GetImagesAllProjects function to client/incus_images.go and add that function to the ImageServer interface in client/interfaces.go

  • Implement it in client/simplestreams_images.go as an alias for the standard GetImages.

  • incus/image: Add --all-projects flag to list

  • Add the new argument to cmd/incus/image.go, when passed, call GetImagesAllProjects instead of GetImages.

  • Also, add shorthad char e(for Project) and print project name when passed

  • i18n: Update translation templates

  • Re-generate the translation template for the new CLI string.


Tests:

gofmt -d passed(for api.go)
make completed fine

@github-actions github-actions bot added Documentation Documentation needs updating API Changes to the REST API labels Jan 18, 2024
doc/api-extensions.md Outdated Show resolved Hide resolved
@stgraber
Copy link
Member

Looks good, just suggested a small edit to make it slightly clearer what API endpoint is touched and what's added.

As we're going to want the pull request to include all the commits for this new feature, I'm going to mark the pull request as draft for now. Feel free to add the commits to this one as you get them ready and I'll keep an eye and review as they show up.

@stgraber stgraber marked this pull request as draft January 18, 2024 04:34
@MaheshPunjabi MaheshPunjabi force-pushed the i390_add_support_for_all-projects_to_incus_image_list branch from 9a42a8c to f6c4baa Compare January 18, 2024 18:56
cmd/incusd/images.go Outdated Show resolved Hide resolved
@MaheshPunjabi MaheshPunjabi force-pushed the i390_add_support_for_all-projects_to_incus_image_list branch 3 times, most recently from 2824d99 to 384204e Compare February 3, 2024 03:45
@MaheshPunjabi MaheshPunjabi changed the title api: images_all_projects Add support for all-projects to incus image list and API Feb 3, 2024
@MaheshPunjabi
Copy link
Contributor Author

@stgraber Do I need to do anything to resolve these conflicts?

@MaheshPunjabi MaheshPunjabi marked this pull request as ready for review February 8, 2024 02:29
@stgraber stgraber force-pushed the i390_add_support_for_all-projects_to_incus_image_list branch from ffdd6f5 to d1fd0ec Compare February 10, 2024 22:57
@stgraber
Copy link
Member

Did the rebase now, going to do a full review shortly

Signed-off-by: Mahesh Punjabi <mahesh.punjabi86@gmail.com>
@stgraber stgraber force-pushed the i390_add_support_for_all-projects_to_incus_image_list branch 2 times, most recently from 55dee44 to 895a2f0 Compare February 10, 2024 23:17
Signed-off-by: Mahesh Punjabi <mahesh.punjabi86@gmail.com>
Signed-off-by: Mahesh Punjabi <mahesh.punjabi86@gmail.com>
@stgraber stgraber force-pushed the i390_add_support_for_all-projects_to_incus_image_list branch from 895a2f0 to 44819e3 Compare February 10, 2024 23:47
Signed-off-by: Mahesh Punjabi <mahesh.punjabi86@gmail.com>
Signed-off-by: Mahesh Punjabi <mahesh.punjabi86@gmail.com>
Signed-off-by: Mahesh Punjabi <mahesh.punjabi86@gmail.com>
Signed-off-by: Mahesh Punjabi <mahesh.punjabi86@gmail.com>
@stgraber stgraber force-pushed the i390_add_support_for_all-projects_to_incus_image_list branch from 44819e3 to c28320b Compare February 11, 2024 00:06
@stgraber
Copy link
Member

stgraber commented Feb 11, 2024

Closes #390

@stgraber stgraber linked an issue Feb 11, 2024 that may be closed by this pull request
@stgraber stgraber merged commit a9c37b4 into lxc:main Feb 11, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Changes to the REST API Documentation Documentation needs updating
Development

Successfully merging this pull request may close these issues.

Add support for all-projects to incus image list and API
2 participants