#Private Go Modules
1 messages ยท Page 1 of 1 (latest)
We share the goal of not having a wrapper so please keep these type of questions coming!
We recently had a similar request and shipped a solution in this PR https://github.com/dagger/dagger/pull/9323
More details here: https://github.com/dagger/dagger/pull/9323#issuecomment-2733029147 and here: https://docs.dagger.io/api/packages/
Would this approach work for you?
Dagger Functions are just regular code, written in your usual programming language. One of the key advantages of this approach is that it opens up access to your language's existing ecosystem of packages or modules. You can easily import these packages/modules in your Dagger module via your language's package manager.
Hey Lev I'll check out those docs and get back to you. If that solves our problem that great ๐
Hey Lev. If I understand correctly this feature enables a dagger module written in go to use private go modules. This is great actually and haven't come across this problem yet, but glad that it's been solved before we ran into it ๐
What I was referring to however is building a normal go project using dagger. We have created our own go builder dagger module and plan on using it to build our go projects. In order for the container which is running go mod download to be able to access private dependencies, we are passing the host's SSH socket to the container. We put a --ssh flag on our module of type *dagger.Secret and then mount that socket on the container.
func withGithubSSH(ctr *dagger.Container, sshSocket *dagger.Socket) *dagger.Container {
const ghHost = "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl"
return ctr.WithExec([]string{"mkdir", "-p", "/root/.ssh"}).
WithExec([]string{"sh", "-c", fmt.Sprintf("echo %s >> /root/.ssh/known_hosts", ghHost)}).
WithExec([]string{"git", "config", "--global", "url.git@github.com:<our-org>/.insteadOf", "https://github.com/<our-org>/"}).
WithExec([]string{"go", "env", "-w", "GOPRIVATE=github.com/<our-org>"}).
WithUnixSocket("/sock/ssh", sshSocket).
WithEnvVariable("SSH_AUTH_SOCK", "/sock/ssh")
}
Oops, sorry I misunderstood your original request!
We were wondering if there was a way to accept this as a default as it would need to be typed out by the developer each time.
AFAIK there is no solution at the moment but please correct me if I am wrong @west lintel @clever granite
This almost feels like "default secret" territory
that's correct. That's related to https://github.com/dagger/dagger/issues/6112
cc @proper current FYI here is one more category of issue that leads to wrappers ๐
cheers guys... yes this would be very valuable to us!