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

34 Commits

Author SHA1 Message Date
Brandon Mitchell
260bef6f38
Fix: Validate registry names
The previous fix only validated registry names in the auths section of the docker config.
This also validates names listed in the credential helper or returned from the credential store.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2025-02-19 11:12:23 -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
40d15e8160
Fix: Ignore unsupported entries in docker config
The docker config may contain auth entries that are not registries.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2025-01-09 10:00:17 -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
17434c3c7b
Feat: Add default host config
In regctl, this exposes a flag to set the default credential helper.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-09-06 17:00:46 -04:00
Brandon Mitchell
05adb86db3
Chore: Move throttle from config to reghttp
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>
2024-08-27 16:11:42 -04:00
Brandon Mitchell
701464ffcf
Refactor: Move logging into transport and rework backoff
- Logging in transport allows better debugging of each request, including redirects
- Backoff redesign better handles failed requests and slows down all requests
- Default rate limit is now removed

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-08-17 11:36:58 -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
0ff350a85d
Refactor: Remove multiple API support
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>
2024-08-13 15:31:29 -04:00
Brandon Mitchell
ca18029b93
Feat: Add a priority queue for network requests
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>
2024-08-13 15:31:29 -04:00
Matthew Monaco
a5e9903da3 Add WithDockerCredsFile() RegClient Opt
Make it easier to pull creds from a docker config.json outside of the
standard location, without needing environmental variables. For example,
a mounted K8s Secret of type `kubernetes.io/dockerconfigjson`.

Signed-off-by: Matthew Monaco <matt@monaco.cx>
2024-07-19 23:07:31 -06: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
5a8addb948
Use t.Setenv in tests
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-01-02 11:37:34 -05:00
Petu Eusebiu
8f20d256cf fix(race): fixed throttle locks in OCIDir and Host config
Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
2023-11-15 18:34:15 +02:00
Brandon Mitchell
c914506022
Update Go docs for blob APIs and the config
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-10-15 16:22:53 -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
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
69df0c352d
Support client certs for mTLS registry auth
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-05-31 15:49:25 -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
7ee1551468
Fix support for docker credsStore
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2023-04-04 20:53:06 -04:00
Brandon Mitchell
9c03c112ae
Limit current requests and requests per second
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-10-27 22:00:12 -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
fb95846acf DOCKER_CONFIG points to a directory, not a file
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-12 10:44:46 -04:00
Brandon Mitchell
c164d0d53b Normalize host definition and fix cred helper
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-09 20:32:53 -04:00
Brandon Mitchell
a114e87e95 Fix handling of Docker Hub with credential helper
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-07 18:49:52 -04:00
Brandon Mitchell
e9d8f2466f Fix handling of tokens with credential helpers
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-04 14:48:50 -04:00
Brandon Mitchell
4c0be1f6fb Support for cred helper in regsync and regbot
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-05-30 15:45:18 -04:00
Brandon Mitchell
91699f45e8 Do not error when docker config.json is missing
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-05-30 09:00:09 -04:00
Brandon Mitchell
026e727a9f Add support for parsing docker config directly
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-05-29 19:08:01 -04:00
Brandon Mitchell
1bdd14a0a6 Adding repoAuth for gcr.io
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-02-27 11:23:57 -05:00
Brandon Mitchell
dfe4356675 Config linting
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-02-04 15:23:02 -05:00
Brandon Mitchell
ad3781d9df Refactoring config outside of regclient dir
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2021-12-29 14:51:00 -05:00