-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Incorporate feedback from 2nd review of SE-0292 #1319
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
This comment has been minimized.
This comment has been minimized.
"registries": { | ||
"default": { | ||
"registries": { | ||
"[default]": { |
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.
does square brackets have precedence in other such system? in Swift we usually use underbar for making "special" things
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 chose [default]
, because it was visually distinctive. However, the only requirement is for it to not be a valid scope name, so _default
could work just as well. At that point, it's a subjective choice.
As far as precedence, Swift uses square brackets in closures to annotate capture semantics ([weak self]
), whereas underscore-prefixed variables are an unenforced convention. Another option to consider might be _
. I don't feel too strongly either which way.
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 prefer we go with underbar _
or dot .
, tho the latter may be too subtle. @neonichu @abertelrud @yim-lee @weissi @Lukasa opinions?
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.
+1 on _
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 _
is usually associated with private or "not to be used" things in the Apple developer community, so seems like we should avoid that.
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.
Agree with @neonichu , _
means "don't use, the ACL on this decl is more permissive than it should ideally be" in most of Swift.
Happy with [default]
, <default>
, (default)
, .default
, ... Don't think I have a strong preference. We could also go with ""
to mean default but that's probably a bit opaque.
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.
Happy with any of @weissi's options there, I don't object to the _
but I understand the desire not to use it.
thanks for putting together @mattt, some comments inline and a couple of additional points that were brought up in the review and I think need to be addressed:
|
It'd be great to link to that from the proposal. The only blocker there was having a durable link target. Once the server specification is merged in swiftlang/swift-package-manager#3364, we can certainly add a link to it from this document.
From that conversation between me and @mmarston (emphasis added):
Until we support other formats in addition to Zip source archives, I don't think there's anything we need to do for this proposal. The current design is flexible to allow for such changes to be made over time, as needed. As far as the "enterprise / behind a firewall mirroring use case" is concerned, this is discussed in the proposal itself under "Registry configuration subcommands", and in the specification under § 4.4.2. Download locations. |
This comment has been minimized.
This comment has been minimized.
iiu @mmarston feedback correctly, he was looking for a way to query a package content via the API to build mirror capabilities for enterprise / behind a firewall type registries. on the surface such API requirement makes sense for a robust ecosystem that includes such registries. @mmarston did I understand that correctly? if so, can you maybe suggest how this kind of API looks / fits into the current proposed set of APIs? |
This comment has been minimized.
This comment has been minimized.
The point of defining a way for the API to advertise additional content is so that a mirroring implementation can be written now that would automatically handle such additions in the future.
Yes, you understand correctly. One suggestion for how this would fit with the current proposed APIs would be to add it to the This would allow a client to use One suggestion for what this could look like:
Here I've used the field name "contents" but I'd welcome alternative suggestions. I've also shown each entry as a map of file name (a path relative to the package name) to integrity hash. To allow for more extensibility (e.g. if someday we diced to add a
|
I'd really prefer to minimize reliance on Link headers and content-negotiation. That is actually one piece of feedback I have about the current RegistryDraft.md. While relying on Link and Accept headers is standard HTTP it makes the implementation more complicated. A quick way to measure the simplicity of the registry API is to ask how much of it could be handled by a simple web server from a file system folder or from an S3 bucket. Obviously that wouldn't be a full-featured registry server (e.g. how would packages be published). But in my mind it would be extremely desirable if that were sufficient enough for someone to quickly set up a meager registry. I currently see 3 areas in the registry API that fail this measure of simplicity:
|
Something else I found odd about the API specification is that the service is supposed to respond with a different content type than the client requested. As a specific example, for listing package releases the client sends an For comparison, npm has a
|
@mmarston Thanks for sharing your feedback. Responses below:
On the other hand, any decisions we make to anticipate hypothetical use-cases limits what we'll be able to do in the future. I'd much rather an additive change in the future that solves a problem exactly, once we know what problem we're trying to solve. I think there's a good case for enumerating the contents of a package release, if only for subresource integrity guarantees. As with publishing / unpublishing, this feature is an additive change that I'd love to look into for a future iteration, but isn't needed for this first version.
This was something I specifically designed for in writing the proposal. You can create a functioning package registry from a static file server, including one served from an S3 bucket.
Link headers aren't strictly necessary. Rather, they provide a way to progressively enhance the capabilities of the server and client. A bare-bones registry served from an S3 bucket could work with Swift Package Manager, or you could layer on EC2 or Lambda to make it more capable.
If the use of absolute URLs in the + If a `url` is provided for a release, the client SHOULD use that value to locate the corresponding release.
+ Otherwise, the client SHOULD locate the release by appending the version number as a path component to the response URL.
Query parameters, like Link Headers, aren't necessary for a registry to function. Swift Package Manager can resolve all dependencies against a static file server that responds with For
For what it's worth, the proposed behavior is consistent with how the GitHub API works: $ curl -I -H "Accept: application/vnd.github.full+json" https://api.github.com/users/mattt
HTTP/2 200
server: GitHub.com
content-type: application/json; charset=utf-8 I've seen examples of APIs that return the original |
I don't see mirroring support as a hypothetical use-case, not do I see my suggest as limiting what we can do in the future.
I would not go so far as to say that absolute URLs are prohibitive, but I do like your suggested change.
Is the server required to normalize / canonicalize the URL or is that something the client would do?
I'm OK with that. The Accept/Content-Type difference was something I noticed when reviewing the API so I wanted to call it out, but I'm OK with your response. |
To be clear, I think mirroring — that is, the ability to serve package resources from alternative locations — is an important feature, which is why I made sure to mention it in the proposal. What I'm saying is that the addition of subresource integrity checksums isn't necessary for mirroring, and shouldn't be a blocker for this initial proposal. SRI has security and ergonomic considerations that I think would really benefit from a separate discussion. For example:
The current proposal doesn't require this functionality, and we can add it later without inconvenience. Is there any reason we couldn't discuss this as a separate follow-up?
The client sends the URL as it's declared by the user in the package manifest. The server is responsible for determining whether that URL corresponds to any existing package in the registry. |
Swift Package Manager commands like | ||
`swift package resolve` and `swift package update` | ||
fail with an error. | ||
|
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 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.
This UX, the ability to pass --login
and --password
, is what I was looking for, so this looks good to me. I have a few questions about the behavior.
- Does this support using different credentials for different registries served from the same host name (at different paths)? I'm inferring that the answer is yes since the
login
field is added toregistries.json
, which means that the.netrc
could have more than one entry for the samemachine
with differentlogin
and the Swift Package Manager would select the one with the matchinglogin
. - Is the user allowed to omit
--password
when passing--login
? (For example, to specify which login to use if the user already has credentials in their user-level.netrc
). - What credentials will the Swift Package Manager use if the registry redirects to a different host? For example, the a private registry may require credentials and then it may redirect the client to a pre-signed S3 URL. From a security perspective the client shouldn't include the credentials when following a redirect to a different host. Will the client attempt to look up the host of the redirect location in a
.netrc
file?
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.
- Does this support using different credentials for different registries served from the same host name (at different paths)?
Yes. A different login / password combination can be specified to add a separate entry in the .netrc
file.
- Is the user allowed to omit
--password
when passing--login
Yes.
- What credentials will the Swift Package Manager use if the registry redirects to a different host?
I'll defer to @tomerd about this specific implementation detail, but my expectation as a user and registry operator would be for any provided credentials (like in a pre-signed S3 URL) to be respected. If that request fails with a 401, I think there's a good case for Swift Package Manager to retry with any available .netrc
credentials.
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.
this all makes sense to me
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.
This approach seems reasonable, provided that SwiftPM's default .gitignore file ignores the project .netrc file.
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.
@Lukasa I just submitted a PR with that change here: swiftlang/swift-package-manager#3511
@mattt is this good to merge? |
@tomerd Yep! Feel free to merge this in at your convenience. |
This PR makes the following changes based on feedback from the 2nd review of SE-0292:
[default]