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

121 Commits

Author SHA1 Message Date
Brandon Mitchell
6f656a37ba
Feat: Improve fallback tag handling
The fallback tag should handle long digest algorithms, and should not output invalid tag characters.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2025-03-19 14:59:21 -04:00
Brandon Mitchell
ce20c40991
Feat: Adding a whoami command
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2025-02-20 15:09:59 -05:00
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
fd60a24198
Version bump including Go
- Support for Go 1.21 is dropped, leaving 1.22 the minimum release
- Go base image to 1.24.0
- ECR helper to latest commit
- gosec to v2.22.1
- dominikh/go-tools for staticcheck to v0.6.0
- olareg/olareg to v0.1.2
- Fixing staticcheck linter warnings

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2025-02-14 10:57:01 -05:00
Brandon Mitchell
7868e550a1
Fix: Platform test for darwin/macos should not add variant
Variant is only added automatically to platform splits with a single field ('linux' or 'darwin').

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-12-06 14:12:19 -05:00
Brandon Mitchell
763599514d
Feat: Include source in referrers response
This simplifies handling external sources.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-12-03 17:12:10 -05:00
Brandon Mitchell
f607b3db32
Feat: Allow plus in ocidir path
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-11-15 15:15:38 -05:00
Brandon Mitchell
3756788d13
Feat: Switch regbot to slog
This also consolidated the trace logging level to a single definition.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-11-11 13:24:54 -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
d6b815f3e0
Fix: Prevent data race when reading blob and seeking
A seek to the current location is used to monitor the progress, making it possible for the callback to panic from a data race.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-08-28 16:52:53 -04:00
Brandon Mitchell
0bd8ddef36
Feat: Limit number of retries for a request
The current retry limits are imposed at the host level. This change prevents a single request from too many retries for various reasons, including flaky connections and logic loops in the code.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-08-27 14:42:17 -04:00
Brandon Mitchell
d53ff8155b
Chore: Update staticcheck and fix linter warnings for Go 1.23
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-08-13 15:01:50 -04:00
Brandon Mitchell
7d17cff26c
Fix: Validate the digest of the ref when provided
This prefers the user provided digest for the manifest over the registry header when it is available.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-08-02 11:44:08 -04:00
Brandon Mitchell
8063956052
Fix platform detection
The `bitIsSet` function was returning the wrong value, forcing nodes to v1.
This also adjusts the automatic appending of the variant to only happen when short values are provided.
This avoids changing `linux/amd64` to `linux/amd64/vx` which would break existing users.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-07-14 13:40:53 -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
f40ed0b8ea
Allow well known architectures as a platform
This is a shortcut permitted in containerd and other projects.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-06-24 11:20:18 -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
thesayyn
710f8d3b71
feat: allow ~ (tilde) in reference paths
Signed-off-by: thesayyn <thesayyn@gmail.com>
2024-06-10 13:47:42 -07:00
Brandon Mitchell
9254e4098a
Handle nil blob reader
Avoid updating the "rdr" value until after err is checked since an interface to a nil value is not nil.
This also hardens the blob reader to prevent panics on a nil value.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-05-20 11:17:02 -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
a67ff344de
feat: image mod layer compression
Note that zstd support needs to be added which will change this and a lot of other code.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-05-01 16:50:53 -04:00
Brandon Mitchell
ce2de4f338
Validate media types in created artifacts
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-03-30 12:05:40 -04:00
Brandon Mitchell
4a113ea9ae
Detect variant on amd64
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-03-09 16:29:20 -05:00
Brandon Mitchell
5a5d5f7c1c
Support args in platform parsing
This allows windows images to be selected.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-03-05 11:27:12 -05:00
Brandon Mitchell
9b47e826a5
Improve descriptor search
Search now prefers better matches rather than first compatible entry.
This also allows hosts on newer variants to select images from older variants.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-03-04 16:14:57 -05:00
Brandon Mitchell
477f4e8333
Remove non-standard platform parsing of OS Version
This is in preparation for improved variant support.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-03-04 16:05:56 -05: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
033e940357
Fix wrapped errors
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-02-27 16:26:17 -05:00
Brandon Mitchell
cc0ae63f8f
Replace t.Error and return with t.Fatal
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-02-27 15:33:52 -05:00
Brandon Mitchell
38b4b10ac9
Handle unretryable failures in http requests
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>
2024-01-03 14:11:34 -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
1f6c8b4446
Align descriptor field order with OCI spec
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-11-10 09:57:43 -05:00
Brandon Mitchell
0a514c3e2d
Updating Ping method
- 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>
2023-11-08 19:41:19 -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
227add5829
Add GetSize method on images
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-10-02 20:38:34 -04:00
Brandon Mitchell
0ad815ee02
Update tests to use t.Parallel where possible
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-10-02 20:09:11 -04: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
6d9822af08
Cleanup links in "deprecated" comments
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-09-30 12:40:03 -04:00
Brandon Mitchell
cf47d837b7
Refactoring the blob package
The main goal was to remove unnecessary interfaces. To avoid breaking
users, type aliases were used on the old interface names.
Comments were updated to better align with the godoc style.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-09-26 20:18:19 -04:00
Brandon Mitchell
934e52602a
Test for implementation of interfaces
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-09-26 16:51:27 -04:00
Brandon Mitchell
b933caa59d
Add gosec security linter
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>
2023-09-25 21:44:24 -04:00
Brandon Mitchell
b38b60aa24
Add ability to filter artifacts in an index
- 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>
2023-09-17 20:00:03 -04:00
Brandon Mitchell
3996b335be
Add the ability to access the OCI index in tag ls
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-08-20 15:59:16 -04:00
Brandon Mitchell
ad0b9650c7
Add manifest and blob get/put limits
- 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>
2023-08-12 17:25:29 -04:00
Brandon Mitchell
38d17949fd
Only check digest on EOF
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-07-21 19:54:48 -04:00
Brandon Mitchell
ca5dd6473a
Fix warning header log message
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-07-12 20:16:44 -04:00
Brandon Mitchell
ae986685d3
Use the distribution-spec regexp for tags
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-07-04 20:51:30 -04:00
Brandon Mitchell
069b060f25
Repo names may have multiple dashes
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-07-01 22:20:40 -04:00
Brandon Mitchell
5f1e4cecac
Adjust OCI types with upstream
- descriptor requires mediatype, size, and digest.
- refers field is no longer needed, replaced by subject.
- docker specific config settings are added for showing docker images.
- annotations should be after the subject field.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-07-01 21:30:18 -04:00
Brandon Mitchell
9a2fc63999
Add artifact support to OCI Index
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-06-25 14:41:55 -04:00