-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for Netrc for Downloader #2833
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
@neonichu depends on swiftlang/swift-driver#185. |
@swift-ci please test |
Please test with following PR: @swift-ci Please test macOS platform |
@neonichu is there anything I can do to help get this in the queue? I've got a product release in October which might be dependent on it. |
Please test with following PR: @swift-ci Please test |
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.
LGTM except for one comment. Thank you very much for the contribution, @sstadelman
Sources/Commands/SwiftTool.swift
Outdated
usage: "Absolute path to netrc file for downloading binary target artifacts"), | ||
to: { $0.netrcFilePath = $1.path }) | ||
} | ||
#endif |
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 we should have the option always be present and emit an error if it is being used on non-macOS. It doesn't really matter right now since binaries aren't supported on non-macOS, but I think silently ignored options can be confusing.
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.
Added check to post-processing block
https://github.com/apple/swift-package-manager/pull/2833/files#diff-b1d92ba41a0ed8ddabdf8c2604a41504R572-R584
Please test with following PR: @swift-ci Please smoke test |
@swift-ci please smoke test |
Sorry for the conflicts, but I needed to unblock the build in #2876 separately from this. |
@neonichu do you need me to clean up these conflicts? |
Yes, please clean up the conflicts, I'll be able to trigger CI then. |
@MaxDesiatov resolved conflicts |
@swift-ci please smoke test |
@MaxDesiatov I see it passing on self-hosted linux. I guess there's an integration issue elsewhere. |
Probably transient failures, let's try again. |
@swift-ci please smoke test |
Sorry @sstadelman, I'm afraid that merging the swift-argument-parser PR has made this conflict yet again :/ |
Np I’ll get it Thursday evening PT.
…Sent from my iPhone
On Aug 26, 2020, at 4:08 PM, Boris Bügling ***@***.***> wrote:
Sorry @sstadelman, I'm afraid that merging the swift-argument-parser PR has made this conflict yet again :/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
1b98c58
to
136b515
Compare
@neonichu gtg |
@swift-ci please smoke test |
|
@neonichu sorry for a noob question, but I’m stuck getting my Linux environment up and running as configured above, since there seems to be a dependency in swift-driver on 5.3 features which are not available in Linux distribution. This has got me temporarily blocked. Is there any guidance you can share for the spm Linux environment setup, so I can get this thing free again? |
Did you try using 5.3 nightly images?
|
@MaxDesiatov good to go! for posterity, here's the linux docker setup:
|
@swift-ci please smoke test |
@sstadelman thank you, all passes now. @neonichu would you be able to have yet another look and merge if everything's good to go? |
Thanks @sstadelman, this is great. |
Thanks again @neonichu and @MaxDesiatov, really appreciated your help and attention on this feature! 🍻 |
Implemented handling for netrc files. Matches connection settings for binary artifact host, and returns Basic authentication header to be appended to internal
URLRequest
of theDownloader
. Will resolve Supporting basic auth for non-git binary dependency hosts.Netrc
parser based on Carthage implementation and tests, and migrated to regex for flexibility.Features supported
machine
,login
,password
key valuesaccount
andmacdef
entries (relevant only to ftp remotes)login
,password
,account
key valuesdefault
connection settings.default
connection setting, and thatdefault
connection setting is last entryNSHomeDirectory()/.netrc
by defaultWorkspace
supports customnetrcFilePath
parameterSequence Flow (including SPM)
In SPM, a netrc file absolute path is resolved during (3)
getActiveWorkspace()
call ofrun()
procedure, from optional command argument (1) orNSHomeDirectory()/.netrc
(4). Resolved absolute path is passed to initializedWorkspace
(5).If binary artifacts should be updated, then the (7)
download(...)
operation attempts to load the netrc machine definitions from a file at the resolvednetrcFilePath
(8). The optional resultingNetrc
instance is passed to the createdFoundationDownloader
for each artifact (11). The downloader attempts to match a credential in the list of theNetrc
instance'sMachine
definitions for the artifact host (13). If matched, the base64-encoded<user>:<password>
pair is set to theAuthorization
header for the respectiveURLRequest
.Notes
Downloader
protocol, which is lightweight by design. Though netrc is a common technique, it is not necessarily a universal solution--perhaps in the future we should also support application tokens, etc., which might similarly pollute the protocol. So, this implementation introduces theAuthorizationProviding
interface, under which additional authentication techniques could in the future be added to theWorkspace
, and injected to the binary update process inDownloader
implementations.Downloader
is extended as follows:FoundationDownloader
. OtherDownloaders
should implement handling according to their requirements.swift-driver
andswift-tools-support-core
packages to raise minimum to 10.13 also. Discussed in thread.