-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: Add gomod git auth #509
Open
pmengelbert
wants to merge
47
commits into
Azure:main
Choose a base branch
from
pmengelbert:pmengelbert/troubleshoot_git_auth/2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
4a8a911
Add gomod git auth
pmengelbert e0bf6b8
Fix gomod auth implementation
pmengelbert 8e857f7
Add llb generation test for gomod generator
pmengelbert 41b4daf
Add Git Auth test for gomods
pmengelbert 302fd36
Add implementation for mounting auth sockets
pmengelbert e578c67
Add ssh_username for gomod sources
pmengelbert e4f7d25
Prevent secrets from leaking in gomod auth code
pmengelbert edaa453
Remove dead and placeholder code
pmengelbert 31e5622
Add ssh test for gomod git auth
pmengelbert 8db8fc3
Address PR feedback nits
pmengelbert 1be29c1
Address linter suggestions
pmengelbert d378e3c
Run `go generate`
pmengelbert 55ae16b
Pass git auth to gomod generator automatically
pmengelbert c68ba78
Add gomod autopropagation test.
pmengelbert 556d44e
Add tests for git auth autopropagation
pmengelbert 379e9f9
Run go generate
pmengelbert 4622ef3
Address linter complaints
pmengelbert 828a9e3
Improve naming
pmengelbert 7b69699
Improve map initialization
pmengelbert d565702
Pass pathname to function
pmengelbert 0a360e0
Use git credential helper for gomod git auth
pmengelbert 11db2d3
Remove dead code
pmengelbert bc6792b
Address linter complaints
pmengelbert bf87d92
Remove commented dead code
pmengelbert 8c241e7
Update unit tests to reflect new implementation
pmengelbert 79a387a
Avoid marshaling/unmarshaling to yaml
pmengelbert baffd2e
Add gomod auth docs
pmengelbert 16ce9e4
Restore functioning of ssh auth
pmengelbert f806911
Address PR feedback
pmengelbert f5f6fc2
Remove `frontend` arg
pmengelbert 27e29e8
Rearrange integration test helpers
pmengelbert 7af838c
Set up rootless detection, ip acquisition, host adding
pmengelbert 1d5a012
Improve test organization
pmengelbert 6a69fee
Check rootless setups for proper env vars
pmengelbert 93c97e4
Get gomod auth working in integration tests
pmengelbert 0af18a0
Create git repo on the fly
pmengelbert 09a22d8
Remove git submodule
pmengelbert d0c60fe
Add platform to images used
pmengelbert cac505f
Add context on docs to comments
pmengelbert 816731c
Add helpful comment
pmengelbert 3271ce1
Use `assert` library instead of `require`
pmengelbert 51cdbaf
Fix errors after rebase
pmengelbert 5b1caf0
Address linter complaints
pmengelbert dd8f670
Update integration test builder images to use go 1.23
pmengelbert 0489b55
Don't panic if host is not valid
pmengelbert a86107f
Substitute the build args in the gomod generator hostnames
pmengelbert 49fb675
Add comment to ssh auth for gomods
pmengelbert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improve naming
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
commit 828a9e32d982c70424a1ef22f0383ca3ebe3c476
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package dalec | |
|
||
import ( | ||
"bytes" | ||
_ "embed" | ||
"fmt" | ||
"path/filepath" | ||
"sort" | ||
|
@@ -14,7 +13,6 @@ import ( | |
const ( | ||
gomodCacheDir = "/go/pkg/mod" | ||
gitConfigMountpoint = "/dev/shm/git" | ||
scriptRelativePath = "/go_mod_download.sh" | ||
) | ||
|
||
func (s *Source) isGomod() bool { | ||
|
@@ -39,9 +37,10 @@ func (s *Spec) HasGomods() bool { | |
func withGomod(g *SourceGenerator, srcSt, worker llb.State, opts ...llb.ConstraintsOpt) func(llb.State) llb.State { | ||
return func(in llb.State) llb.State { | ||
const ( | ||
fourKB = 4096 | ||
workDir = "/work/src" | ||
scriptMountPoint = "/tmp/mnt" | ||
fourKB = 4096 | ||
workDir = "/work/src" | ||
scriptMountpoint = "/tmp/dalec/internal/gomod" | ||
gomodDownloadWrapperBasename = "go_mod_download.sh" | ||
) | ||
|
||
joinedWorkDir := filepath.Join(workDir, g.Subpath) | ||
|
@@ -54,14 +53,14 @@ func withGomod(g *SourceGenerator, srcSt, worker llb.State, opts ...llb.Constrai | |
|
||
sort.Strings(paths) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
script := g.gitconfigGeneratorScript() | ||
scriptPath := filepath.Join(scriptMountPoint, scriptRelativePath) | ||
scriptPath := filepath.Join(scriptMountpoint, gomodDownloadWrapperBasename) | ||
|
||
for _, path := range paths { | ||
in = worker.Run( | ||
ShArgs(scriptPath), | ||
llb.AddEnv("GOPATH", "/go"), | ||
g.withGomodSecretsAndSockets(), | ||
llb.AddMount(scriptMountPoint, script), | ||
llb.AddMount(scriptMountpoint, script), | ||
llb.AddMount(gitConfigMountpoint, llb.Scratch(), llb.Tmpfs(llb.TmpfsSize(fourKB))), // to house the gitconfig, which has secrets | ||
llb.Dir(filepath.Join(joinedWorkDir, path)), | ||
srcMount, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Doesn't look like this is used anywhere?
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.
Removed this and other unused
const
s.