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

feat: Add gomod git auth #509

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
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 Jan 21, 2025
e0bf6b8
Fix gomod auth implementation
pmengelbert Jan 23, 2025
8e857f7
Add llb generation test for gomod generator
pmengelbert Jan 23, 2025
41b4daf
Add Git Auth test for gomods
pmengelbert Jan 27, 2025
302fd36
Add implementation for mounting auth sockets
pmengelbert Jan 27, 2025
e578c67
Add ssh_username for gomod sources
pmengelbert Jan 27, 2025
e4f7d25
Prevent secrets from leaking in gomod auth code
pmengelbert Jan 29, 2025
edaa453
Remove dead and placeholder code
pmengelbert Jan 29, 2025
31e5622
Add ssh test for gomod git auth
pmengelbert Jan 29, 2025
8db8fc3
Address PR feedback nits
pmengelbert Jan 29, 2025
1be29c1
Address linter suggestions
pmengelbert Jan 30, 2025
d378e3c
Run `go generate`
pmengelbert Jan 31, 2025
55ae16b
Pass git auth to gomod generator automatically
pmengelbert Jan 31, 2025
c68ba78
Add gomod autopropagation test.
pmengelbert Jan 31, 2025
556d44e
Add tests for git auth autopropagation
pmengelbert Feb 3, 2025
379e9f9
Run go generate
pmengelbert Feb 3, 2025
4622ef3
Address linter complaints
pmengelbert Feb 3, 2025
828a9e3
Improve naming
pmengelbert Feb 13, 2025
7b69699
Improve map initialization
pmengelbert Feb 13, 2025
d565702
Pass pathname to function
pmengelbert Feb 13, 2025
0a360e0
Use git credential helper for gomod git auth
pmengelbert Feb 21, 2025
11db2d3
Remove dead code
pmengelbert Feb 21, 2025
bc6792b
Address linter complaints
pmengelbert Feb 21, 2025
bf87d92
Remove commented dead code
pmengelbert Feb 21, 2025
8c241e7
Update unit tests to reflect new implementation
pmengelbert Feb 24, 2025
79a387a
Avoid marshaling/unmarshaling to yaml
pmengelbert Feb 24, 2025
baffd2e
Add gomod auth docs
pmengelbert Feb 24, 2025
16ce9e4
Restore functioning of ssh auth
pmengelbert Feb 24, 2025
f806911
Address PR feedback
pmengelbert Feb 26, 2025
f5f6fc2
Remove `frontend` arg
pmengelbert Mar 4, 2025
27e29e8
Rearrange integration test helpers
pmengelbert Mar 4, 2025
7af838c
Set up rootless detection, ip acquisition, host adding
pmengelbert Mar 5, 2025
1d5a012
Improve test organization
pmengelbert Mar 6, 2025
6a69fee
Check rootless setups for proper env vars
pmengelbert Mar 6, 2025
93c97e4
Get gomod auth working in integration tests
pmengelbert Mar 7, 2025
0af18a0
Create git repo on the fly
pmengelbert Mar 10, 2025
09a22d8
Remove git submodule
pmengelbert Mar 10, 2025
d0c60fe
Add platform to images used
pmengelbert Mar 10, 2025
cac505f
Add context on docs to comments
pmengelbert Mar 10, 2025
816731c
Add helpful comment
pmengelbert Mar 10, 2025
3271ce1
Use `assert` library instead of `require`
pmengelbert Mar 10, 2025
51cdbaf
Fix errors after rebase
pmengelbert Mar 10, 2025
5b1caf0
Address linter complaints
pmengelbert Mar 10, 2025
dd8f670
Update integration test builder images to use go 1.23
pmengelbert Mar 10, 2025
0489b55
Don't panic if host is not valid
pmengelbert Mar 10, 2025
a86107f
Substitute the build args in the gomod generator hostnames
pmengelbert Mar 10, 2025
49fb675
Add comment to ssh auth for gomods
pmengelbert Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve naming
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
pmengelbert committed Mar 11, 2025
commit 828a9e32d982c70424a1ef22f0383ca3ebe3c476
13 changes: 6 additions & 7 deletions generator_gomod.go
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
Copy link
Member

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?

Copy link
Contributor Author

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 consts.

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)
Copy link
Member

Choose a reason for hiding this comment

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

paths is already ordered by the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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,