1
0
mirror of https://github.com/containers/image.git synced 2025-04-18 19:44:05 +03:00

476 Commits

Author SHA1 Message Date
Miloslav Trmač
51d3a1c0ea Replace Set.AddSlice with Set.AddSeq, use it in more places
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-03-12 20:17:18 +01:00
Miloslav Trmač
bc6b35d0c9 Replace Set.Values with a non-allocating Set.All
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-03-12 20:16:03 +01:00
Adam Eijdenberg
57e8568849 feat: add DestinationTimestamp to copy options
Useful for reproducible oci-archive output.

Signed-off-by: Adam Eijdenberg <adam@continusec.com>
2025-02-28 06:09:09 +00:00
Miloslav Trmač
482669d41e Only create the text describing options if we are going to use it
Microoptimize the success case.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-02-20 16:09:07 +01:00
Miloslav Trmač
b941c6bf41 Add private.ImageDestination.NoteOriginalOCIConfig
For now, this only adds the API, nothing actually benefits from
it yet.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-11-28 19:34:59 +01:00
Miloslav Trmač
6ba898f74f HACK: Only return an image ID from ReportResolvedReference for c/storage
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-11-04 17:29:21 +01:00
Miloslav Trmač
125f862851 Return a precise reference to the created image when writing to containers-storage
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-11-04 17:23:04 +01:00
Miloslav Trmač
91d22b295c Introduce private.ImageDestination.CommitWithOptions
This only adds an API method, it does not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-11-04 17:22:49 +01:00
Miloslav Trmač
acaf72abf4 Improve context for errors in PrepareStagedLayer
- Diferentiate partial pull errors from other read errors
- Indicate that this is PrepareStagedLayer that is failing

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-10-25 22:39:15 +02:00
Giuseppe Scrivano
9851561552
image: define error for partial pulls not available
define a new error type so that the caller can determine whether it is
safe to ignore the error and retrieve the resource fully.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-10-08 12:21:54 +02:00
Colin Walters
b18499a3c1 copy: Don't print "skipped: 0.0b = 0.00%"
I think this is just visually noisy. If we didn't do a partial
fetch then let's just not say anything about it.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-09-20 09:03:24 -04:00
Colin Walters
3df133e402 copy: Add unit tests for progress output
Prep for more work.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-09-20 08:56:57 -04:00
Miloslav Trmač
8be5549c41 Remove an error return value from platform.WantedPlatforms
It can't fail.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-09-05 20:06:20 +02:00
Miloslav Trmač
14d63ee7c8 Fix an index in an error message
Make it 1-based, like in the other error message.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-09-05 20:06:14 +02:00
Kir Kolyshkin
bcabe37ce5 copy: Image: add/use safeClose
Consolidate the [duplicated] code that handles and wraps the errors from
Close to a function, and call it twice.

Keep the code which deliberately converts an error from Close to a
string (rather than wrapping it) as we don't want those errors to be
unwrappable (those are not "primary" errors).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-19 13:32:07 -07:00
Miloslav Trmač
3d38daee42 Detect zstd:chunked format in source blobs
... instead of only treating it as zstd.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-06 22:13:57 +02:00
Miloslav Trmač
243b49d8ab Extend private.ReusedBlob to allow zstd:chunked reuses
- Add a CompressionAnnotations field
- Allow turning a known-zstd blob into a zstd:chunked one if we
  know the right annotations

This just adds the fields, nothing sets them yet, should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-06 22:13:30 +02:00
Miloslav Trmač
76af27cd12 Record the specific variant, and TOC annotations, for blobs we compress
Introduce distinct uploadedCompressorBaseVariantName and
uploadedCompressorSpecificVariantName fields; that way we now never
call RecordDigestCompressorData with inconsistent zstd / zstd:chunked in one field,
so we can always record data when we see, or create, a zstd:chunked layer,
removing the current hack.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-06 22:13:24 +02:00
Miloslav Trmač
f9d27e8c6d Add digest -> specific variant, annotation data to BIC
The cache implementations are recording both the base and specific compression variant;
CandidateLocations2 all call CandidateTemplateWithCompression to choose the
appropriate variants to return based on CandidateLocations2Options.

This way, neither the BIC implementations nor the transports are not responsible for
converting zstd:chunked entries to zstd entries if the user wants the latter.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-06 22:13:08 +02:00
Miloslav Trmač
babdac8191 Always record only the base variant information about consumed source blobs
... because we don't trust the TOC data, if any.

This allows us to remove the zstd:chunked hack; we, at least,
now record those blobs as zstd.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-05 20:47:47 +02:00
Miloslav Trmač
d09a403fd6 Introduce blobinfocache.DigestCompressorData
We will want to record more than a single alghoritm name. For now,
just introduce the structure and modify users, we'll add the new fields
later.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-05 20:47:31 +02:00
Kir Kolyshkin
e2e81f25c2 Simplify codespellrc, fix remaining typos
Current .codespellrc contains too many exclusions, and as a result it
misses some legitimate typos.

A few previous commits silenced or fixed some of the codespell warnings
in preparation for this one, which minimizes exclusions, and fixes the
actual remaining typos.

The fixes here are the result of codespell -w.

./copy/sign_test.go:119: overidden ==> overridden
./copy/encryption.go:51: pratice ==> practice
./copy/multiple_test.go:80: crated ==> created
./copy/progress_bars.go:124: progres ==> progress

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-02 13:37:53 -07:00
Kir Kolyshkin
271ebf7b79 copy: fix a typo in log message
Found by codespell 2.3.0:

	Error: ./copy/single.go:217: resuing ==> reusing, resuming, rescuing

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-02 13:37:05 -07:00
Kir Kolyshkin
adfc928b13 copy: fix a comment
This fixes a comment in the test code ("expection", "out", and
punctuation) to the best of my knowledge.

Fixes: c84a3fad ("copy/multiple_test: multiple copy requests of same compression")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-02 13:28:20 -07:00
Miloslav Trmač
f49cb6278b HACK: Don't compress with zstd:chunked when encrypting
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-30 18:56:54 +02:00
Miloslav Trmač
acdd0641d3 Record the (TOC digest, uncompressed digest) data when we compress layers
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-30 18:56:46 +02:00
Miloslav Trmač
c7b334263c Clarify a comment
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-23 21:01:42 +02:00
Miloslav Trmač
34c67fd601 Don't silently accept unset compressor fields
They are set on all code paths creating bpCompressionStepData.
Just to be sure, check and fail instead of just removing the check.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-23 20:59:46 +02:00
Miloslav Trmač
22b11d1b25 Narrow down the scope of a variable
Otherwise "err" refers to a variable outside of this closure,
not even to the one used by the immediate caller.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-09 22:32:10 +02:00
Miloslav Trmač
871cdd3369 Eliminate a single-use variable
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-09 22:32:10 +02:00
Miloslav Trmač
1c586a820b Eliminate a numLayers variable
The compiler is smart enough that referencing
a local variable is not any faster than len(srcInfos).

If anything, keeping the extra variable might add to register pressure
because the compiler might not understand that the srcInfos change due to
LayerInfosForCopy does not change the number of layers.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-09 22:32:10 +02:00
Giuseppe Scrivano
b47707f7e1
docker: support for requesting chunks without end offset
if the specified length for the range is set to -1, then request all
the data possible by using the "Range: <unit>=<range-start>-" syntax
for the HTTP range.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-05-14 10:37:08 +02:00
Miloslav Trmač
95cd137d4c Don't use the "decrypted digest" when decrypting layers
Should not actually change behavior, the value is never set.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-05-14 01:01:18 +02:00
Miloslav Trmač
cebe64776a Quote various strings coming from untrusted sources
Typically, use %q instead of %s (or instead of "%s"), to expose
various control characters and the like without interpreting them.

This is not really comprehensive; the codebase makes no _general_
guarantee that any returned string values are free of control
characters or other malicious/misleading metadata. Not even
in returned "error" values (which can legitimately contain newlines,
if nothing else).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-05-09 19:22:23 +02:00
Miloslav Trmač
04deef6fe6 Call .Validate() before digest.Hex() / digest.Encoded()
... to prevent panics if the value does not contain a :, or other unexpected
values (e.g. a path traversal).

Don't bother on paths where we computed the digest ourselves, or it is already trusted
for other reasons.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-05-09 15:59:32 +02:00
Daniel J Walsh
387b45a2c5
Merge pull request #2379 from mtrmac/redundant
Avoid a redundant function call
2024-04-23 17:26:19 -04:00
Miloslav Trmač
921d382b1b Avoid a redundant function call
This primarily ensures that we log and use the same value.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-04-22 20:42:55 +02:00
Miloslav Trmač
c936932f2a Use "maps" and "slices" from the standard library
... except where we need maps.Keys().

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-04-22 20:24:31 +02:00
availhang
0bf62be2fc chore: fix function names
Signed-off-by: availhang <mayangang@outlook.com>
2024-03-22 14:49:42 +08:00
Miloslav Trmač
b77c92a031 Detect zstd:chunked from the incoming manifest entry
This should not matter much in practice - CompressionAlgorithm
is only used for updating MIME types, and for ListEdit.*CompressionAlgorithms,
where zstd and zstd:chunked are treated the same - but it's easier to
make the logic accurate than to commit to the fields _only_
carrying BaseVariantName-values.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-28 16:43:21 +01:00
Miloslav Trmač
d3b7298c7e Also match BaseVariantName against the users' required compression algorithm
e.g. when the user asks for zstd, also accept zstd:chunked.

This does not currently make a difference because we can't detect
zstd:chunked in blobPipelineDetectCompressionStep, and the
BlobInfoCache does not record zstd:chunked; but let's get the logic
more correct.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-28 16:42:07 +01:00
Sascha Grunert
dfb4559d1c
Add validation error to digesting reader
The reason is hidden if `expectedDigest.Validate()` errors. This patch
will add the error message to the stack to provide more details.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-02-27 10:58:16 +01:00
Miloslav Trmač
6d895d0f97 Provide data to correctly report throughput on partial pulls
Per https://github.com/containers/podman/issues/20634#issuecomment-1960164114 .

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-22 21:26:39 +01:00
Nalin Dahyabhai
22e3c112c5 Support setting ArtifactType, preserve it in lists
Add fields to manifest.ListUpdate for setting the ArtifactType field in
an entry being added to a list.  When copying a list or descriptor,
preserve the value from the original descriptor for an entry.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-20 17:46:04 -05:00
Miloslav Trmač
1b0e6be4b5 Replace ReusedBlob.TOCDigest with MatchedByTOCDigest
The caller must already have provided options.TOCDigest, so
we don't really need to return a value; the UI only needs
a boolean.

Also, document, again, that the non-TOC digest is a mandatory field.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-13 19:41:13 +01:00
Miloslav Trmač
981360c0bd Make the index option in PutBlobPartialOptions mandatory
... because it is always available, and this allows us to remove
a condition.

Also rename it to LayerIndex, and make the Cache option first,
for consistency with other private.*Options types.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-13 19:40:54 +01:00
Miloslav Trmač
5df539180d Introduce private.PutBlobPartialOptions
This will allow us to name the more obscure parameters,
and to change their names/semantics without having to update
the 4 trivial implementations.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-13 19:40:44 +01:00
Miloslav Trmač
ca9c3e551d Remove an unnecessary variable
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-13 19:40:37 +01:00
Giuseppe Scrivano
6da4441ac6 storage, dest: clarify when TOCDigest is used
This update introduces an enhancement in the blob handling mechanism,
specifically by separating the TOC digest from the
uncompressed/compressed digest.

Follow-up for: #1080.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-13 19:40:28 +01:00
Giuseppe Scrivano
11630be8c6 dest: propagate layer index to PutBlobPartial
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-13 19:40:17 +01:00