-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add PackageRegistryManager #3787
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
Conversation
@swift-ci Please smoke test |
client.execute(request, progress: nil) { result in | ||
switch result { | ||
case .success(let response): | ||
if response.statusCode == 200, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc one can configure the request with acceptable response codes to avoid such check, tho you do make other checks here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if it were just the status check or a range of status codes, I would've gone with that. But it's less code overall to do it this way here.
} | ||
} | ||
|
||
private extension String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to Basics?
self.fileSystem = fileSystem | ||
} | ||
|
||
public func extract( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is some code in workspace that also does similar things (for binary artifacts). maybe we can reuse / converge on one implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's ZipArchiver
in TSCUtility, which I based this type on: https://github.com/apple/swift-tools-support-core/blob/f9bbd6b80d67408021576adf6247e17c2e957d92/Sources/TSCUtility/Archiver.swift#L34
(Hence some of the callouts from copy-pasted code, like dispatching to the global queue)
I discuss the rationale for this type in the doc comments, but the main takeaway is that this is probably only useful for the registry. I'd also be interested in getting some more 👀 on this, especially from security folks.
As far as converging on a single implementation, there may be an opportunity to make the delegated system call and directory prefix stripping a configurable property. But at that point, I think you may as well have two separate implementations of the Archiver
protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discuss the rationale for this type in the doc comments, but the main takeaway is that this is probably only useful for the registry. I'd also be interested in getting some more 👀 on this, especially from security folks.
cc @andyp-apple and @robertlacroix
As far as converging on a single implementation, there may be an opportunity to make the delegated system call and directory prefix stripping a configurable property. But at that point, I think you may as well have two separate implementations of the Archiver protocol.
makes sense, we can revisit this later too
Sources/Commands/SwiftTool.swift
Outdated
@@ -571,6 +586,7 @@ public class SwiftTool { | |||
sharedConfigurationDirectory: sharedConfigurationDirectory | |||
), | |||
mirrors: self.getMirrorsConfig(sharedConfigurationDirectory: sharedConfigurationDirectory).mirrors, | |||
registries: try? self.getRegistriesConfig(sharedConfigurationDirectory: sharedConfigurationDirectory).configuration, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try?
intentional? should it throw instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we throw here, package resolution would fail for anyone who doesn't have a .swiftpm/configuration/registries.json
file, even if they only use URL-based dependencies. The check for valid registry configuration is pushed back to be done only when necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in similar situation in SwiftTool we return nil when it okay for it to be missing. so how about changing self.getRegistriesConfig to return optional when configuration/registries.json does not exist, and throw if it exists but cant be loaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing! Fixed by dd323fb.
And I was mistaken — doing try
here shouldn't throw an error if the configuration file is missing. Instead, it should return an empty configuration object.
lgtm, couple of small things |
This comment has been minimized.
This comment has been minimized.
Add RegistryManagerTests
bb59156
to
86d0a19
Compare
This comment has been minimized.
This comment has been minimized.
86d0a19
to
fbf54f0
Compare
This comment has been minimized.
This comment has been minimized.
@swift-ci Please smoke test |
@mattt seems like this is ready to go? do you want to squash and provide the commit message, or should I do best-effort while merging? |
@tomerd Yeah, this is good to go. Thanks for your help on getting this ready. Feel free to squash and merge whenever you see the CI go ✅ . |
A partial tree of #3640 containing additive changes that don't affect how dependencies are downloaded or resolved. This PR itself shouldn't affect the behavior of Swift Package Manager, and is intended to serve as a backstop should we need to rollback any changes related to package resolution.
Motivation:
Improve velocity of registry implementation and reduce risk of merging future changes.
Modifications:
RegistryManager
and associated testsSourceArchiver
used byRegistryManager
Registry
fromRegistryConfiguration
scopeAndName
property toPackageIdentity
identity
toid
inPackageDescription
to match SE-0292Result:
No changes.