Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContainerRegistry: Add a struct to represent a registry operation #29

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

euanh
Copy link
Collaborator

@euanh euanh commented Oct 23, 2024

Motivation

RegistryClient.executeRequestThrowing currently takes an HTTPRequest struct parameter and executes it using the underlying HTTPClient. It augments HTTPClient by handling authentication challenges and decodes JSON error responses, but the use of HTTPRequest means that the caller is responsible for details such as generating the full distribution endpoint URL. Giving RegistryClient its own abstract operation type frees the caller from dealing with these internal details.

The struct can also be passed easily anywhere the details of the operation are required, making future improvements easier. For instance, if an operation causes an error, the original operation struct could be attached to the error making all its details available to the error handler.

Modifications

Add a struct which holds all the necessary information about a requested operation on the registry, and refactor RegistryClient to use it.

Result

No functional change.

This refactoring makes the separation of RegistryClient and HTTPClient's responsibilities clearer, and allows us to centralise the generation of registry URLs. In the future it will make further improvements easier, such as changing how authentication is handled and providing more detailed error messages.

Test Plan

Automated tests continue to pass; also tested manually.

@euanh euanh added the semver/none No version bump required. label Oct 23, 2024
@euanh euanh force-pushed the registry-operation-refactor branch from 1c775a3 to 6d2951a Compare October 23, 2024 13:48
Refactor RegistryClient, adding a struct which holds all the necessary
information about a requested operation on the registry.

This makes the separation of RegistryClient and HTTPClient's
responsibilities clearer, and allows us to centralise the generation
of registry URLs.  In the future it will make further improvements
easier, such as changing how authentication is handled and providing
more detailed error messages.
@euanh euanh force-pushed the registry-operation-refactor branch from 6d2951a to ce81ed2 Compare October 23, 2024 13:51
@euanh euanh merged commit 483ad76 into apple:main Oct 23, 2024
19 checks passed
@euanh euanh deleted the registry-operation-refactor branch October 23, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant