Commit Graph

16 Commits

Author SHA1 Message Date
openshift-merge-bot[bot] 93fa77f3c7 Merge pull request #1919 from nalind/index-resolve-images
manifest add: check for local images last
2024-04-02 18:44:48 +00:00
Nalin Dahyabhai c58341d561 manifest add: check for local images last
When adding a reference to a manifest list or image index, if we are
guessing that it's a reference to an image in a registry, check if we
can read something from that location instead of assuming it's correct,
and if we can't, check for a local image.  This will let use use local
image IDs to refer to items that we want to add to a list or index.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-29 17:15:56 -04:00
Nalin Dahyabhai 966738be5b manifests: preserve Annotations and URLs when adding from indexes
When adding items from one index into another, preserve the annotations
and URLs which are set in the descriptors in the source index.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-25 09:48:52 -04:00
Nalin Dahyabhai 8f70d181e7 libimage.ManifestList: add AddArtifact()
* Add a libimage.ManifestList.AddArtifact() method.
* Add IndexAnnotations and Subject to libimage.ManifestListAnnotateOptions,
  for setting annotations on the index itself, and the index's subject,
  respectively.
* In libimage/manifests.list.AddArtifact(), if the subject has an
  artifactType in its manifest, add its value to the subject descriptor.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-13 12:09:28 -05:00
Nalin Dahyabhai c270f76f4c ibimage/manifests.list.Add(): don't read platform info for artifacts
If an instance being added to a list has a non-empty ArtifactType value
or a config.MediaType value that isn't one of the known kinds of image
configuration blobs, don't try to parse the configuration blob to figure
out the image's OS/Architecture/Variant information.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-05 09:36:48 -05:00
openshift-merge-bot[bot] 98b7332bfd Merge pull request #1789 from alexandear/refactor-map-init
Refactor map init with short declaration syntax
2024-01-08 14:42:32 +00:00
Oleksandr Redko 0e202b45a1 Refactor map init with short declaration syntax
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-06 19:28:43 +02:00
Oleksandr Redko a1db72dfa0 Simplify tests by testing.TempDir instead of os.MkdirTemp
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 22:54:51 +02:00
Oleksandr Redko ba4c7c98bb chore: remove outdated build constraints
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-03 22:56:00 +02:00
Paul Holzinger 92c98a7323 libimage: add !remote tag
To prevent the podman remote client from using libimage which causes a
lot of bloat due the c/image and c/storage dependencies add the
`!remote` tag.

This will cause a hard compile time failure if the remote client ends up
pulling in libimage.

Fixes #1702

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-23 15:14:43 +02:00
Aditya R 975a5798cc manifest_list: inspect add fields from both OCIv1 and docker format
ManifestInspect should contain all known formats for a valid manifest
list as of now only supported formats are `OCIv1` and `Docker` so
inspect should support fields from `OCIv1` format as well. Following
commit adds a new field to inspect i.e `Annotations` from `OCIv1`.

Example output from podman
```console
podman manifest inspect test
{
    "schemaVersion": 2,
    "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
    "manifests": [
        {
            "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
            "size": 528,
            "digest": "sha256:9b2a28eb47540823042a2ba401386845089bb7b62a9637d55816132c4c3c36eb",
            "platform": {
                "architecture": "amd64",
                "os": "linux"
            },
            "annotations": {
                "annotationTest1": "annotationTest2"
            }
        }
    ]
}
```

Closes: https://github.com/containers/podman/issues/15069

Signed-off-by: Aditya R <arajan@redhat.com>
2022-07-29 17:04:33 +05:30
Sascha Grunert 426d69c00f Switch to golang native error wrapping
`github.com/pkg/errors` is deprecated since quite some time so we now
use the native error wrapping for more idiomatic golang.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-12 10:54:07 +02:00
Kir Kolyshkin b951b72412 Gofumpt the code
gofumpt is a stricter version of gofmt, basically making the code more
readable, and fixing the gocritic's octalLiterar warnings like this one:

	pkg/util/util_supported.go:26:17: octalLiteral: use new octal literal style, 0o722 (gocritic)
		return (perm & 0722) == 0700
			       ^

Generated by gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 16:50:11 -07:00
Aditya Rajan 29da01d939 remove-image: Add optional LookupManifest to RemoveImagesOptions.
Following flag allows user to configure RemoveImages in a manner so that
remove func becomes exclusive to removing manifests when needed and not
removing underlying referenced images.

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-09-02 14:21:51 +05:30
flouthoc bfb9606066 runtime: Add ReturnManifestIfPresent to LookupImageOptions
If matching images resolves to a manifest list, return manifest list
instead of resolving to image instance, if manifest list is not found
try resolving image.

Signed-off-by: Aditya Rajan <flouthoc.git@gmail.com>
2021-08-30 14:16:32 +05:30
Valentin Rothberg 92095e0dbe libimage: fix manifest list lookup
Commit 724e7c92b5 fixed an issue when pushing images from of a
platform different than the current machine.  That required to disable
the platform matching logic when looking up the image before pushing it.
It also required some restructuring of the code such that manifest lists
are resolved and their instances looked up.

The restructuring in turn introduced a regression when looking up bare
manifest lists.  To fix the regression and keep the code simple,
introduce an internal field in the LookupImageOptions that indicates
whether we're looking up a bare manifest list or not.

Now we have clearer separation of concerns between looking up images or
manfifests and whether the looked up image needs to match the current
platform or not.

Add some unit tests exercising the manifest-list code to make sure we're
not regressing again.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-18 14:53:37 +02:00