- 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>
While the descriptor requires a size and media type, the referrer API does not.
This makes regclient more tolerant of non-conformant implementations.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
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>
Breaking: config.Host.Throttle() has been removed. Use scheme.Throttler instead.
Ideally the config should only have static config values.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
A registry server that is just a redirect to a real server that requires auth will now work.
Previously, auth was only sent to the first server, now it is only sent to the server that performed the auth.
The auth package itself was also refactored a bit, removing unneeded interfaces and reducing exported fields.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
- 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>
Breaking: This removes an undocumented API for deleting images from Hub.
Users that depend on that functionality should consider a Docker Hub alternative like hub-tool.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
Breaking: Update scheme to use pqueue instead of throttle.
This is the first step to redesign the network requests for more efficiency.
Library users are unlikely to encounter issues with the scheme change since
both throttle and pqueue are internal packages, so it shouldn't be possible
to call their methods directly or specify their types in variables.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
Some registries do not include the docker digest headers.
This should support referrers listing by tag on those registries.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
This was used for test implementations that were better handled with t.TempDir or olareg backed by memory.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
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>
The blob put method depends on the input being an io.Seeker for retries.
If that is not the case, abort and return the previous error.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
- Adds a struct to the return so headers can be inspected.
- Puts Ping into the scheme interface.
- Adds an ocidir implementation to verify directory is accessible.
- Fixes some http/auth handling.
- Warns on `regctl registry config` and `login` of Ping failure.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
- 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>
Most of this is error handling. Many of the file IO warnings are
intentionally ignored since these tools are designed to run locally.
Signed-off-by: Brandon Mitchell <git@bmitch.net>
- Move descriptor filter/sort into descriptor funcs
- Reuse those methods for referrers get/list
- Use those methods in artifact get when an index is seen
Signed-off-by: Brandon Mitchell <git@bmitch.net>
- manifest delete should not fail when referrer file is missing
- artifact put of referrer should not add a manifest reference in ocidir
- reproducible image creation scripts should prune stale referrers
Signed-off-by: Brandon Mitchell <git@bmitch.net>
- This adds a 4MB manifest put limit (per the OCI spec).
- It also adds an 8MB manifest get limit to prevent DOS attacks.
- Blob reads also stop when the expected length is reached.
- HTTP retry backoff checks were added to read/close methods.
Signed-off-by: Brandon Mitchell <git@bmitch.net>