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

Support NETRC environmental var #2426

Merged
merged 4 commits into from Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@ All notable changes to [Earthly](https://github.com/earthly/earthly) will be doc
### Changed

- Updated buildkit to include changes up to [a5263dd0f990a3fe17b67e0002b76bfd1f5b433d](https://github.com/moby/buildkit/commit/a5263dd0f990a3fe17b67e0002b76bfd1f5b433d), which includes a change to speed-up buildkit startup time.
- Added support for a custom `.netrc` file path using the standard `NETRC` environmental variable. [#2426](https://github.com/earthly/earthly/pull/2426)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go under ### Added actually.


### Fixed

Expand Down
8 changes: 6 additions & 2 deletions buildcontext/gitlookup.go
Expand Up @@ -436,8 +436,12 @@ func (gl *GitLookup) detectProtocol(host string) (protocol gitProtocol, err erro
var errNoRCHostEntry = fmt.Errorf("no netrc host entry")

func (gl *GitLookup) lookupNetRCCredential(host string) (login, password string, err error) {
homeDir, _ := fileutil.HomeDir()
n, err := netrc.Parse(filepath.Join(homeDir, ".netrc"))
netrcPath := os.Getenv("NETRC")
if netrcPath == "" {
homeDir, _ := fileutil.HomeDir()
netrcPath = filepath.Join(homeDir, ".netrc")
}
n, err := netrc.Parse(netrcPath)
if err != nil {
return "", "", errors.Wrap(err, "failed to parse .netrc")
}
Expand Down