cnabio / cnab-to-oci

Tool to convert CNAB bundle.json to OCI index
Apache License 2.0
54 stars 41 forks source link

Add option to push missing images #76

Closed eunomie closed 5 years ago

eunomie commented 5 years ago

Allow push command and remotes.Fixup to be able to push missing images from the local docker daemon image store.

A --push-images flag is added to the push command. This flag will act during the fixup phase. If an image is not found, instead of just printing a message saying you need to push the image before, the image will be pushed if available in the local docker daemon image store.

The fixup command doesn't change, there's no option to "fixup and push" if you want to do that, use push.

radu-matei commented 5 years ago

Ok, so I have this workflow:

{
    "description": "A short description of your bundle",
    "invocationImages": [
        {
            "image": "noaccesstothisregistry/push-test-cnab:742d5c8bd222737511ebc213cf7d99c40b32ef60",
            "imageType": "docker"
        }
    ],
    "keywords": [
        "push-test",
        "cnab",
        "tutorial"
    ],
    "maintainers": [
        {
            "email": "john.doe@example.com",
            "name": "John Doe",
            "url": "https://example.com"
        },
        {
            "email": "jane.doe@example.com",
            "name": "Jane Doe",
            "url": "https://example.com"
        }
    ],
    "name": "push-test",
    "schemaVersion": "v1.0.0-WD",
    "version": "0.1.0"
}
 docker image ls
REPOSITORY                              TAG                                        IMAGE ID            CREATED              SIZE
noaccesstothisregistry/push-test-cnab   742d5c8bd222737511ebc213cf7d99c40b32ef60   3aeba8c4e1e8        About a minute ago   11.1MB
alpine                                  latest                                     961769676411        7 weeks ago          5.58MB
registry                                latest                                     f32a97de94e1        7 months ago         25.8MB
$ cnab-to-oci push ignore/push-test/bundle.json --push-images --auto-update-bundle -t localhost:5000/from-daemon:v1 --log-level debug
$ cnab-to-oci pull localhost:5000/from-daemon:v1 --log-level debug
cnab-to-oci push pulled.json --push-images -t localhost:5000/pulled-and-pushed:v1 --log-level debug
DEBU[0000] Fixing up bundle localhost:5000/pulled-and-pushed:v1
DEBU[0000] Updating entry in relocation map for "noaccesstothisregistry/push-test-cnab:742d5c8bd222737511ebc213cf7d99c40b32ef60"
Starting to copy image noaccesstothisregistry/push-test-cnab:742d5c8bd222737511ebc213cf7d99c40b32ef60...
Failed to copy image noaccesstothisregistry/push-test-cnab:742d5c8bd222737511ebc213cf7d99c40b32ef60: Error response from daemon: No such image: sha256:43b67c7bbc1dadd39e61ba9b0711c71035b0d0401d9a90a24cca34edfdb1659e
Error: Error response from daemon: No such image: sha256:43b67c7bbc1dadd39e61ba9b0711c71035b0d0401d9a90a24cca34edfdb1659e

Even if it is the same image, because we're trying to access it by SHA, that is not available locally - how is the SHA propagated locally after a push? Could we ensure the image is available in such scenarios?

eunomie commented 5 years ago

Typos are fixed. We can now configure output (discarded by default). Dependencies are updated.

eunomie commented 5 years ago

I was also able to perform a full push - pull - push cycle as in https://github.com/docker/cnab-to-oci/pull/76#issuecomment-542354769 without issue.

silvin-lubecki commented 5 years ago

^ @radu-matei I let you merge 😄

radu-matei commented 5 years ago

I just tried again the same workflow from https://github.com/docker/cnab-to-oci/pull/76#issuecomment-542354769 and now it works - most likely it was because of https://github.com/docker/cnab-to-oci/pull/76#discussion_r335126652.