cmd: Add optional json format to inspect command output#131
cmd: Add optional json format to inspect command output#131
Conversation
|
@detsch Specifically, the "bundle" field should contain an array of "services" (or "indexes") and each element of the array is either image index of manifest. If it is an image index then it should contains an array of image manifest. |
I suggest to stick to the terms of the OCI image spec, https://github.com/opencontainers/image-spec/blob/main/image-index.md#oci-image-index-specification and the terms of the compose app spec https://github.com/compose-spec/compose-spec/blob/main/03-compose-file.md. So, according to those specs, the app bundle consists of "services" at the top level. And then, each service refers to either an image index or manifest. If it is an image index, then it in turn consists of N image manifests. |
d38f08f to
a17f2b4
Compare
|
@mike-sul Updated format bellow. Maybe "type" field is now redundant, WDYT? |
Yes, the "type" field is redundant now since a filed name indicate the type. |
|
I would probably change the "bundle" format, specifically its "services" field to make it follow the compose app spec (each service contains an image field): |
a17f2b4 to
926e2a1
Compare
|
@mike-sul updated format accordingly. I'm getting the name from the service URL, is that what you expected? |
| }, | ||
| } | ||
| currApp.Bundle.Services = append(currApp.Bundle.Services, serviceInfo) | ||
| currApp.Bundle.Digest = node.Descriptor.Digest.String() |
There was a problem hiding this comment.
This is not correct. The app bundle digest and size are set at line #112 and # 113.
No, It should be the service name as it is defined in a compose project You can see it by running I've added tiny extension to simplify getting app service name while traversing an app tree. |
| Services: []ServiceContentInfo{}, | ||
| } | ||
| } | ||
| } else if depth == 2 && node.Type == compose.BlobTypeImageIndex { |
There was a problem hiding this comment.
It can be depth == 2 && node.Type == compose.BlobTypeImageManifest too. In some cases the "image" in docker-compose.yml can refer to an image manifest not to an image index (e.g. a single-arch image or app).
There was a problem hiding this comment.
I published an app to the detsch-x86-64 factory that contains two services, one refers to a multi-arch image (image index), and the second one to a single-arch image (an image manifest). This app can be useful to test this change. (app URI hub.foundries.io/detsch-x86-64/test-app@sha256:9beae67316af7cb47ee8296f23535394da7f75ad7528b6cd71bbed42d1081120).
composectl inspect hub.foundries.io/detsch-x86-64/test-app@sha256:9beae67316af7cb47ee8296f23535394da7f75ad7528b6cd71bbed42d1081120
Inspecting App hub.foundries.io/detsch-x86-64/test-app@sha256:9beae67316af7cb47ee8296f23535394da7f75ad7528b6cd71bbed42d1081120...ok
app manifest: hub.foundries.io/detsch-x86-64/test-app@sha256:9beae67316af7cb47ee8296f23535394da7f75ad7528b6cd71bbed42d1081120, 802
|
|—> app index: sha256:410df6eb8f035b5769334fc99aa362dbe605962cca58b184b04c0e6dc8134e11, 185
|
|—> app bundle: sha256:5b4ab4cec212c7808ab3713975130edb40ead7d86030713d7910f9659af253d5, 564
|
|—>index: ghcr.io/foundriesio/busybox@sha256:3635a377d690475f783a1782b193cc4b8b499d24d1209ac19d36087aad49c0cd, 683
manifest: sha256:359e81f9b2a9be2b4ae628a146e0fab4d5b8ac8a386f4e8181f099d0f354dfc4, amd64, 527
config: sha256:c1f39daffdeffeb97987901406e2ecef0fb2c2ca236fdfaf570d088426294d91, 372
layer: sha256:b916bb0fdf4067e26231af3da50785486049d50ccc5f100c272fada8ca55340d, 2220190
manifest: sha256:2e6f1c34ac3ecce639b71f8e3d8827fdd8ecd5f663053f064d2e0f7db092e0a8, arm64, 527
config: sha256:b6bdb81e03b7525b1c21cea8d4b44ccb6bbcd2250a2868debce24fc9709c62db, 390
layer: sha256:2b918d3330127be806a78a0ee5ecb71f72a78efac357fe45b39c463a63bd4606, 1916214
|
|—>manifest: ghcr.io/foundriesio/busybox@sha256:0124622a5e535aa839c9f2d58ae95be4202bbeb2bb32917f4feaef28ab9cff44, 527
config: sha256:87ff76f62d367950186bde563642e39208c0e2b4afc833b4b3b01b8fef60ae9e, 372
layer: sha256:a10d77880eaf7e9f53f332b86ff61f9c2b9dfe41900762958e19614687a7cb05, 2220020
composectl show compose hub.foundries.io/detsch-x86-64/test-app@sha256:9beae67316af7cb47ee8296f23535394da7f75ad7528b6cd71bbed42d1081120
name: test-app
services:
busybox:
command:
- sh
- -c
- while true; do sleep 50; done
environment:
WORKER_NAME: --name=
image: ghcr.io/foundriesio/busybox@sha256:3635a377d690475f783a1782b193cc4b8b499d24d1209ac19d36087aad49c0cd
labels:
io.compose-spec.config-hash: ee53097e9d60c7510d9ff2d000fcfed5b67bc3dc0bf8de9fc4ca55a67c4c8c5d
networks:
default: null
srvs-01:
command:
- sh
- -c
- while true; do sleep 50; done
image: ghcr.io/foundriesio/busybox@sha256:0124622a5e535aa839c9f2d58ae95be4202bbeb2bb32917f4feaef28ab9cff44
labels:
io.compose-spec.config-hash: 8dac7cc6150bb57cefb4c5f68e0e1647905b0f0fc2344274231c657eb578d825
networks:
default: null
ports:
- mode: ingress
target: 80
published: "8080"
protocol: tcp
volumes:
- type: bind
source: /work/go/src/github.com/foundriesio/composeapp/config1.toml
target: /etc/config.toml
bind:
create_host_path: true
networks:
default:
name: test-app_default
There was a problem hiding this comment.
I added this change 551b04d, it looks like it works correctly now.
Feel free to restructure commits (change order and/or squash them) and then push the final version.
Signed-off-by: Mike Sul <mike.sul@foundries.io>
Signed-off-by: Andre Detsch <andre.detsch@foundries.io>
551b04d to
a7200c3
Compare
@mike-sul here is an example output. My priority was to get something out to unblock the new tests, I'm sure you will have suggestions for improvements in the json format. "indexes" is particularly not a good name IMO.
Also, we may want to move part of the new code to
pkg/compose/app.go