From 1b731f3bd51efef94a198288c4bdf0821f9151cb Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 18 Nov 2022 11:31:42 -0800 Subject: [PATCH 1/3] Support NETRC environmental var --- buildcontext/gitlookup.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/buildcontext/gitlookup.go b/buildcontext/gitlookup.go index b5f545033e..5c3ee85a28 100644 --- a/buildcontext/gitlookup.go +++ b/buildcontext/gitlookup.go @@ -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") } From 09a85e3b1da074b3c61eb0f87d16d5427ee5a949 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 18 Nov 2022 12:27:59 -0800 Subject: [PATCH 2/3] Updated CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b772b35df8..1bfb612854 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) ### Fixed From 9a1568a5265064d6c31ac6b529c9607f57117189 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 18 Nov 2022 12:30:08 -0800 Subject: [PATCH 3/3] Moved CHANGELOG comment --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bfb612854..d01a20d34b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,13 @@ All notable changes to [Earthly](https://github.com/earthly/earthly) will be doc ## Unreleased +### Added + +- Added support for a custom `.netrc` file path using the standard `NETRC` environmental variable. [#2426](https://github.com/earthly/earthly/pull/2426) + ### 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) ### Fixed