-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Update command-line interface for .netrc file handling #3763
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
Refactor getNetrcConfig method
@swift-ci Please smoke test |
Isn't netrc optional the behavior we want? I don't think we should force every user to having to provide a netrc file. |
i think the semantics we want is:
@neonichu @abertelrud @mattt does that match tour expectations? |
Don't emit error if .netrc file isn't found in default location
@neonichu @tomerd Yes, that's what I was going for, but e824ef7 had the incorrect logic. 😓 The version in 85fa08a should be correct: To your third point: Yes — authentication errors should be emitted by the HTTP client responsible for downloading the binary artifact / source archive. Swift Package Manager can't know if credentials are needed or the provided ones are invalid until they connect to the remote server. |
This comment has been minimized.
This comment has been minimized.
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.
couple of questions but semantics seems right me. @neonichu @abertelrud wdyt?
@swift-ci Please smoke 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
Remove deprecation annotation for netrcOptional property
Emit warnings when specifying deprecated --netrc and --netrc-optional flags Update command tests for new netrc options Fix tests to assert throwing errors
@tomerd Following up on your thread with @natecook1000, I found a reasonable solution with the following properties:
So the new command-line interface is: USAGE: swift package <options> <subcommand>
OPTIONS:
...
--enable-netrc/--disable-netrc
Load credentials from a .netrc file (default: true)
--netrc-file <netrc-file>
Specify the .netrc file path. I also found a bug in the existing unit tests, where |
@swift-ci Please smoke 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.
this is great
This PR updates how
.netrc
file handling behavior is configured inswift-package
command and its subcommands.Motivation:
When resolving dependencies through a registry (SE-0292), users will often need to authenticate with the configured server. Because
.netrc
files are the prescribed way to store and manage credentials, it makes sense for them to be read by default, rather than being opt-in behavior.Modifications:
--netrc
totrue
, such that users instead opt-out with--no-netrc
--netrc-optional
flag, such that passing it is a no-op--netrc
flag and--netrc-file-path
optionResult:
Before:
After: