1
0
mirror of https://github.com/regclient/regclient.git synced 2025-04-18 22:44:00 +03:00

59 Commits

Author SHA1 Message Date
Brandon Mitchell
95c9152941
Chore: Modernize Go to the 1.22 specs
- Use "any" instead of an empty interface.
- Use range over an integer for for loops.
- Remove shadow variables in loops now that Go no longer reuses the variable.
- Use "slices.Contains", "slices.Delete", "slices.Equal", "slices.Index", "slices.SortFunc".
- Use "cmp.Or", "min", and "max".
- Use "fmt.Appendf" instead of "Sprintf" for generating a byte slice.
- Use "errors.Join" or "fmt.Errorf" with multiple "%w" for multiple errors.

Additionally, use modern regclient features:

- Use "ref.SetTag", "ref.SetDigest", and "ref.AddDigest".
- Call "regclient.ManifestGet" using "WithManifestDesc" instead of setting the digest on the reference.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2025-02-18 14:32:06 -05:00
Brandon Mitchell
c29933e7eb
Fix: Handle repeated digest in copy with external referrers
The imageSeenOrWait would falsely hit on a digest pushed to a separate repository, skipping the copy of a blob when it should not.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-12-09 16:41:20 -05:00
Brandon Mitchell
ead52eb575
Feat: Copy image with external referrers
This supports both external source and target repositories for referrers.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-12-04 17:01:12 -05:00
Brandon Mitchell
1eb1ea4b34
Feat: Refactor logging to use log/slog
This updates the regclient Go library.
Existing users of logrus will continue to work using a logrus handler to slog.
Updates to the various commands will be made in a future commit.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-11-10 17:14:57 -05:00
Brandon Mitchell
89be757fd0
Feat: Consolidate warnings
When a registry returns a warning header on every request, clients should try to consolidate these.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-08-22 16:52:40 -04:00
Brandon Mitchell
b752cdf9c7
Configure priority queue algorithm and reorder image copy steps
- Priority queue algorithm prefers a small entry (non-blob API), and 50/50 split of largest and oldest queued entries.
- Image reorder starts the blob copies sooner to avoid blocking on the tag listing for referrers or digest tags.
- pqueue.AcquireMulti releases queues in reverse order to minimize risk of an acquire blocked by a soon to release queue.
- Include type and size in the request for priority queue.
- Use expected request size to validate response.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-08-13 15:31:29 -04:00
Brandon Mitchell
6e93ed083c
Tar file should use forward slashes
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-07-22 13:32:17 -04:00
Brandon Mitchell
e805426203
Support changing digest algorithm
This adds validation and the ability to modify the digest.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-07-07 11:44:40 -04:00
Brandon Mitchell
5e05f50a3c
Refactor pulling a platform specific manifest
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-06-23 10:23:53 -04:00
Brandon Mitchell
5417b713d0
Feat: Adding zstd support
Breaking: pkg/archive.Compress no longer decompresses the input.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-05-06 16:41:35 -04:00
Brandon Mitchell
415eaf4808
Add regclient.ImageConfig method
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-03-29 15:27:37 -04:00
Brandon Mitchell
cf6c678cf7
Chore: Cleanup unused params
This is now flagged by gopls, but not yet in staticcheck.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-03-13 16:02:30 -04:00
Brandon Mitchell
eea06e2a5c
Refactoring the type package
I feel like I need to explain, this is all to move the descriptor package.
The platform package could not use the predefined errors in types because of a circular dependency from descriptor.
The most appropriate way to reorg this is to move descriptor out of the type package since it was more complex than a self contained type.
When doing that, type aliases were needed to avoid breaking changes to existing users.
Those aliases themselves caused circular dependency loops because of the media types and errors, so those were also pulled out to separate packages.
All of the old values were aliased and deprecated, and to fix the linter, those deprecations were fixed by updating the imports... everywhere.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-03-04 15:43:18 -05:00
Brandon Mitchell
23c2697f29
Improve error handling of a failed copy
This prefers errors other than the context.Canceled that is generated by stopping goroutines.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-02-21 11:05:45 -05:00
Brandon Mitchell
dcf0eabd36
Reducing logs on canceled image copy
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-01-04 19:05:40 -05:00
Brandon Mitchell
4c1e999343
Validate the ref in various APIs
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-11-11 19:23:58 -05:00
Brandon Mitchell
68a6c083d9
Refactor ref package
- Add NewHost to parse hostname or ocidir path.
- Add IsSet method to verify reference is fully defined.
- Add SetDigest and SetTag methods to create a new Ref.
- Update other packages to use new methods.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-11-06 19:05:29 -05:00
Brandon Mitchell
b2a7336453
Reorder Go imports to move local packages last
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-09-30 22:21:10 -04:00
Brandon Mitchell
8aeece90f8
Cleanup godoc comments on regclient package
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-09-26 11:48:51 -04:00
Brandon Mitchell
4b89bdc912
Support compression on import and export
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-08-25 20:10:13 -04:00
Brandon Mitchell
37763330f2
Fail faster when target of copy is down
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-08-20 15:23:59 -04:00
Brandon Mitchell
4d508b0d00
Add option to import a specific image or tag name
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-06-28 11:01:09 -04:00
Brandon Mitchell
d860d33c88
Track tags when deduping manifests in copy
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-06-26 16:54:05 -04:00
Brandon Mitchell
ab46803e37
Rework the loop detection/handling
The level check from before would return before the manifest was copied.
This looks for loops in direct parents, and if encountered, it switches
to copy the referrers and digest tags after the manifest is pushed. The
manifest wait group is being removed to reduce complexity and remove
deadlock issues.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-06-25 10:56:24 -04:00
Brandon Mitchell
2a72bafff4
Fix copy with referrers and digest tags
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-06-18 19:44:40 -04:00
Brandon Mitchell
f6f87eba74
Prevent deadlock on looping referrers
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-06-10 19:05:20 -04:00
Brandon Mitchell
2159f96e0a
Handle symlinks in tar from docker save
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-05-30 15:36:52 -04:00
Brandon Mitchell
c8983c2aa8
Add a fast check option for image copy
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-05-22 20:33:22 -04:00
Brandon Mitchell
d2ca5fa5eb
Add concurrency to image copy
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-05-06 09:01:35 -04:00
Brandon Mitchell
119f30c5e8
Add terminal progress during copy
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-04-15 12:00:49 -04:00
Brandon Mitchell
d72ec02a39
Add support for http warning messages
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-03-26 22:06:13 -04:00
Brandon Mitchell
578ec14390
Add name for image export
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-03-01 19:33:11 -05:00
Brandon Mitchell
4be94a17f1
Add referrers support to regsync
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-02-20 20:04:20 -05:00
Brandon Mitchell
68acd0e9fc
Fallback from head to get when digest is missing
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-02-16 20:47:37 -05:00
Brandon Mitchell
4ee0d719b0
Normalize filenames on tar import
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-02-04 20:58:25 -05:00
Brandon Mitchell
f989bbc0d6 Rename refers to subject
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-09-17 17:07:32 -04:00
Brandon Mitchell
4155d3e87e Update check-base tests
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-08-31 17:13:48 -04:00
Brandon Mitchell
f0ceda1677 Add image check-base
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-08-30 09:37:56 -04:00
Brandon Mitchell
e90d7fcbde Bumping to Go 1.19 and GHA versions
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-08-27 10:19:19 -04:00
Brandon Mitchell
db025b75d0 Refactoring referrers support
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-08-21 20:04:26 -04:00
Brandon Mitchell
be66132b79 Use a registry like reference in docker export
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-07-12 08:53:56 -04:00
Brandon Mitchell
4272e2e59b Add regctl index to create/mutate manifest lists
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-07-02 10:03:28 -04:00
Brandon Mitchell
44dd971327 Separate manifest interfaces and add set methods
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-27 19:50:30 -04:00
Brandon Mitchell
8674aa5c67 Track tags used by refers
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-12 12:05:54 -04:00
Brandon Mitchell
2985dffe3d Bug fixes for referrers
- Include referrers in pretty printers
- Set correct reference when copying
- Treat referrers as child objects before Refer is pushed
- Create artifacts with minimal refer descriptor (exclude annotations)

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-02 20:04:44 -04:00
Brandon Mitchell
0e8ba98e23 Support referrers with image copy
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-01 13:24:22 -04:00
Brandon Mitchell
f2a277099f Fix import to ocidir with manifest list or index
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-05-29 19:32:17 -04:00
Brandon Mitchell
c800decc9f Improve handling of external URLs
- Attempt to pull external blob from registry
- Handle blob pull to external URL
- Copy option to copy external blobs
- Mod option to remove external URLs from descriptors

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-05-07 20:24:06 -04:00
Brandon Mitchell
746866aef0 Set child field on manifest put in image export
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-04-10 19:00:50 -04:00
Brandon Mitchell
29a0d79421 Parse the descriptor data field when available
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-03-07 08:51:54 -05:00