#How to Use a Private Go Module with dagger
1 messages ยท Page 1 of 1 (latest)
๐ @thin dragon what are you using CUE or the new Dagger SDK's?
I'm using new dagger sdk
for local builds dagger will automatically use your ssh-agent, so fetching libs from private repos should work out of the box.
when you run in CI (i.e github actions) you need to send your GH_ACCESS_TOKEN and GOPRIVATE vars so GH can fetch from there
Are you sure ? Actually, I thought it wasn't the case https://github.com/dagger/dagger/issues/3581. I thought it was only available to the git API
If it is not the case, under which API are you planning to do the go build ? https://pkg.go.dev/dagger.io/dagger#Container.Exec
oh! you're absolutely right. I got confused with the git step indeed. In that case I guess you'd have to mount the SSH_AGENT socket.
Currently trying to implement the fix (what you're talking about, it might be a nice exercise ๐). Your idea of WithMountedSSH looks neat
cc @potent rapids do we have any examples in the meantime that use GOPRIVATE and a token to fetch private go repos?
we don't but I'll create an issue for that
Oh, I'll definitely try this one.
@astral heart
I missed this one. I must use Container.Exec
I also tried to replicate SSH_AGENT socket but as descripted in issue above , I couldn't find it in latest API
For token authentication, it's already disabled in remote: Support for password authentication was removed on August 13, 2021.
Currently I'm looking for alternative solutions like credential helper
Hi, a PR is on the way (hopefully): https://github.com/dagger/dagger/pull/3691
I need to add the tests, and get feedback
You can export the env var, the values are on the pr
_, err = client. Container(). From("golang:1.19"). WithSecretVariable("GH_TOKEN", githubTokenID). Exec(dagger.ContainerExecOpts{ Args: []string{ "bash", "-ec", curl --location --fail --silent --show-error https://github.com/cli/cli/releases/download/v2.19.0/gh_2.19.0_linux_amd64.tar.gz | tar -C . -xz && mv gh_2.19.0_linux_amd64/bin/gh /usr/local/bin/gh, }, }). Exec(dagger.ContainerExecOpts{Args: []string{"bash", "-c", "gh auth setup-git"}}).
I guess with gh as credential helper I wont need to change auth workflow in GHA executions as well