Commit Graph

189 Commits

Author SHA1 Message Date
Kir Kolyshkin
b74989dfbc integration: add unix tag to non-windows tests
These tests can't be compiled on Windows, so add unix build tag.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-14 12:29:02 +02:00
Kir Kolyshkin
25481e1a88 integration: add _test suffix to files
Some files in integration did not have _test, resulting in lots of
complains when running golangci-lint with --tests=false.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-14 12:29:02 +02:00
luozexuan
b6b6415286 chore: fix some function names in comment
Signed-off-by: luozexuan <fetchcode@139.com>
2025-03-30 16:19:50 +08:00
Colin Walters
5b30cfe29c
Merge branch 'main' into layer-info-extended 2025-03-21 17:56:01 -04:00
Miloslav Trmač
7983f20adb Remove obsolete build tag syntax
per (go fix ./...).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-03-21 21:00:49 +01:00
Miloslav Trmač
1f49b2c0c0 Use slices.Backward
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-03-21 21:00:31 +01:00
Colin Walters
a31470d7a4 proxy: Add GetLayerInfoPiped
I was experimenting with images with lots of layers (> 200) and
this invocation was incorrectly adding the entire response
into what was intended as the metadata plane.

`GetManifest` and `GetConfig` (even those are relatively small)
still always return their data over a pipe, same as blobs.

Add a new `GetLayerInfoPiped` that does the same so we
can easily get this information for images with a lot of layers.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-21 15:05:59 -04:00
Miloslav Trmač
9166a97bbb Use a range expression
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-09-03 19:26:40 +02:00
Miloslav Trmač
cd71084908 Refer to registry.k8s.io instead of k8s.gcr.io
... per https://kubernetes.io/blog/2023/02/06/k8s-gcr-io-freeze-announcement/ .

We are seeing intermittent failures (sufficient to reliably cause a test suite failure)
pulling from k8s.gcr.io, let's see if using the newer one improves things.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-06-17 20:02:15 +02:00
Miloslav Trmač
513a4f1ab3 Update for changed c/image error texts
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-05-14 00:27:18 +02:00
writegr
50159e219c chore: fix function names
Signed-off-by: writegr <wellweek@outlook.com>
2024-04-18 18:09:30 +02:00
Miloslav Trmač
a75ed81668 Use strings.CutSuffix
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-04-05 17:15:16 +02:00
Miloslav Trmač
9821af6f11 Freeze the fedora-minimal image reference at Fedora 38
... because the tests are assuming a v2s2 image, but
as of Fedora 39, the image uses the OCI format.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-04-03 18:13:23 +02:00
Miloslav Trmač
8f2a7c65ff Also change the MIME type in manifest when decompressing a layer
... for purposes of comparison

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-08 00:16:13 +01:00
Miloslav Trmač
812a02af41 Replace decompress-dirs.sh with Go code
We will need to make it more sophisticated than
it is practical to do in Go.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-08 00:16:06 +01:00
Miloslav Trmač
09f282e468 Split decompressDir from runDecompressDirs
... so that we have a new function which only decompresses
one image at a time.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-02-08 00:16:00 +01:00
Colin Walters
f7dc084799 proxy: Change the imgid to uint64
In PR review for a different issue, the question of what happens
if we hit overflow for the imageid serial was hit.  This feels
pretty unlikely; if I did the math right, it'd require opening
an average of 136 images per second to overflow it in a year.
Nevertheless, in practice what we're sending on the wire is just a JSON
number, and if we extend this to the "max safe JSON number" of 2^53,
it'd take 285,616,414 images per second to overflow in a year, going
from implausible to probably impossible.

With a bit more work of course, we could make this a sparse mapping
and reuse freed numbers, but eh.

Signed-off-by: Colin Walters <walters@verbum.org>
2023-07-13 00:24:55 +02:00
James Hewitt
3097b7a4e9
Verify signatures from a trust store
Add the ability to use an on-disk trust store to verify signatures. Also allow the user to trust any known fingerprint instead of having to specify one.

Signed-off-by: James Hewitt <james.hewitt@uk.ibm.com>
2023-04-01 11:51:57 +01:00
Miloslav Trmač
2a6a944c13 Use io.WriteString
... mostly so that I get practice and remember this exists in the future.

(This saves one allocation & copy when the target implements
io.StringWriter. And that makes absolutely no relevant difference
on this path.)

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-27 18:15:47 +01:00
Miloslav Trmač
4beb3f0af9 Fix some warnings
golangci-lint linter: unparam

This primarily fixes TestProxy to test the correct image

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-23 16:08:45 +01:00
Miloslav Trmač
2ef9cf6902 Replace gopkg.in/check.v1 by github.com/stretchr/testify/suite/
gopkg.in/check.v1 hasn't had any commit since Nov 2020.
That's not a immediate issue for a test-only dependency, but
because it hides access to the standard library *testing.T,
eventually it will become limiting.

Also, using the same framework for unit and integration tests
seems practical.

This is mostly a batch copy&paste job, with a fairly high risk
of unexpected breakage.

Also, I didn't take much time at all to carefully choose between
assert.* and require.*; we can tune that as failures show up.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-17 02:35:51 +01:00
Miloslav Trmač
2a7b132790 Simplify a condition
golangci-lint linter: ifshort

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 17:49:01 +01:00
Miloslav Trmač
e7ab33e65f Rename a variable to avoid an underscore
golangci-lint linter: golint

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 17:48:59 +01:00
Miloslav Trmač
e90c381a02 Add missing comment punctuation
golangci-lint linter: godot

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 17:48:16 +01:00
Miloslav Trmač
70c06b4ac0 Fix, or remove, comments using lint syntax
golangci-lint linter: gocritic

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 17:48:16 +01:00
Miloslav Trmač
9137ac5697 Simplify an increment
golangci-lint linter: gocritic

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 17:48:16 +01:00
Miloslav Trmač
efc6e837c6 Reformat import statements
golangci-lint linter: gci

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 17:48:16 +01:00
Miloslav Trmač
a8b9e4e385 Use %w when wrapping errors
golangci-lint linter: errorlint

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 17:48:16 +01:00
Miloslav Trmač
afa031e846 Use net/netip.Addr instead of net.IP
This is not really shorter, but more a matter of principle...

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-02 22:27:35 +01:00
Miloslav Trmač
891ba3d4a6 s/interface{}/any/g
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-02 22:27:35 +01:00
tomsweeneyredhat
80e3fd1095 Touch up conscious language issues
Touch up a few issues with language in the project to
make it more inclusive.

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2023-01-21 17:13:25 -05:00
Miloslav Trmač
fe5c4091ee Close a HTTP response body
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-27 08:00:52 +02:00
Colin Walters
08b27fc50e proxy: Add OpenImageOptional
In some code I'm writing I want to be able to cleanly test if an
image exists, as distinguished from other errors like authentication
problems, network flakes etc.

As best I can tell, the containers/image abstraction doesn't
offer a clean way to do this.

For now, I chose the route of adding the ugly string error matching
here for the two cases I care about (docker v2s2 registry and oci
directories), so my Rust code can operate in terms of clean
`Option<Image>`.

Signed-off-by: Colin Walters <walters@verbum.org>
2022-10-12 21:11:55 -04:00
Miloslav Trmač
9724da1ff2 Remove a special case for failing to list tags in (skopeo sync)
- It's unclear why it exists in the first place
- Looking at callers of imagesToCopyFromRepo, the only caller of this:
  either the input is a single repo, in which case the failure to
  list tags clearly results in a no-op and a "No images to sync" fatal
  failure ...
- ... or the input is YAML, and in that case the caller is already
  skipping the repo on a failure.

Either way, it's unclear why we would have a special "Registry disallows
tag retrieval" error special case instead of the generic text.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-12 22:56:52 +02:00
Miloslav Trmač
955a59c864 Update tests for changed error texts
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-12 22:56:46 +02:00
Miloslav Trmač
f3aee25c7c Fold a long line.
Should not change (test) behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-12 22:10:01 +02:00
Miloslav Trmač
1983173b60 Remove single-use "wanted" variables
They were useful before assertSkopeoSucceeds/assertSkopeoFails,
when they were used multiple times. Now, they don't
make the code any shorter.

Should not change (test) behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-12 22:09:48 +02:00
Miloslav Trmač
ba23a9162f Stop using docker/docker/pkg/homedir in tests
c/storage/pkg/homedir, which we need anyway for other purposes,
should work just as well.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-08-23 22:30:12 +02:00
Miloslav Trmač
fa2b15ff76 Reformat with Go 1.19's gofmt
This is just the minimal update; I didn't review all
existing comments for using all the new syntax.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-08-10 21:19:51 +02:00
Miloslav Trmač
b000ada3f3 Update for the renames of sigstore to lookaside
I left systemtest unmodified, to have _something_ that
exercises the compatibility path.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-07-12 13:47:35 +02:00
Miloslav Trmač
61593fccc6 Revert "Change a repo used for sync tests"
This reverts commit bbdabebd17.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-07-01 17:35:08 +02:00
Miloslav Trmač
ba6af16e53 Use bytes.ReplaceAll instead of bytes.Replace(..., -1)
... for a trivial improvement in readability.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-06-29 19:40:02 +02:00
Miloslav Trmač
38f4b9d032 Enable schema1 support on the test registries
We expect schema1 images to work.  Also, docker/distribution
doesn't provide useful errors for rejected schema1 images
( https://github.com/distribution/distribution/issues/2925 ),
which makes it impractical for Skopeo to automatically convert
schema1 to schema2.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-06-16 20:27:05 +02:00
Miloslav Trmač
1b5fb465be Update for docker/distribution CLI change
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-06-16 20:27:05 +02:00
Miloslav Trmač
bbdabebd17 Change a repo used for sync tests
The k8s.gcr.io/coredns/coredns repo now contains an OCI
artifact, which we can't copy; so, use a different
repo to test syncing.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-06-11 03:15:14 +02:00
Miloslav Trmač
d9d3ceca45 Use filepath.WalkDir instead of filepath.Walk
... to optimize away some lstat(2) calls.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-04-13 20:14:04 +02:00
Miloslav Trmač
23a4605742 Extract four copies of the same loop into a function
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-04-13 20:14:04 +02:00
Miloslav Trmač
4811c07d71 Update users of deprecated io/ioutil
Mostly just name changes that should not change behavior, apart
from ioutil.ReadDir -> os.ReadDir avoiding per-item lstat(2) in
one case.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-04-13 20:13:52 +02:00
James Hewitt
4ef35a385a
Add option to specify the identity for signing
This enables pushing to registries where the push and pull uris may be
different, for example where pushed images are mirrored to a read only
replica for distribution.

Closes #1588

Signed-off-by: James Hewitt <james.hewitt@uk.ibm.com>
2022-03-30 22:02:43 +01:00
Miloslav Trmač
2019b79c7f Use check.C.MkDir() instead of manual ioutil.TempDir() calls
This saves us at least 2 lines (error check, and cleanup) on every
instance, or in some cases adds cleanup that we forgot.

This is inspired by, but not directly related to, Go 1.15's addition of
Testing.T.TempDir.

NOTE: This might significantly increase the tests' disk space requirements;
AFAICS the temporary directories are only cleaned up when a whole "suite
finishes running.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-03-16 16:05:08 +01:00