#Private Git repo

1 messages · Page 1 of 1 (latest)

lavish spruce
#

Hello, new dagger user here.

I see the documentation for authenticating with a private git repo is 1) for an old version of dagger and 2) uses the client = dagger.Client form instead of the quickstart's preinitialized dag.

Thus the recommendation of:

    readme, err := client.
        Git("git@private-repository.git", dagger.GitOpts{
            SSHAuthSocket: client.Host().UnixSocket(sshAgentPath),
        }).
        ...

Doesn't work. The dag object doesn't have a Host() method and the dag.Git() function cannot accept the dagger.GitOpts because it is the wrong type. It is asking for a GitOpts from a module local source.

How do I translate to/from the client = dagger.Client form and preinitialized dag form?

#

Ok so I also don't know how to use Discord. I searched the wrong bar. I see more answers now.

lavish spruce
native linden
#

Hi @lavish spruce , we have this prioritized. The latest is in that GitHub issue. If you haven't already, will you please add your +1 and any relevant notes to it?

lavish spruce
#

Thanks @native linden , I've given it a 👍

native linden
#

Thanks!

edgy nimbus
#

That issue is for loading modules from a private repo.

For loading a directory from a private repo inside a function with dag.Git, using ssh you can pass the repo URL via the CLI:

func (m *MyModule) MyPrivateFiles(ctx context.Context, dir *Directory) ([]string, error) {
  return dir.Entries(ctx)
}

Using a git reference in the CLI for a Directory will use dag.Host().UnixSocket() with your SSH_AUTH_TOKEN:

dagger call my-private-files --dir=git@private-repository.git

Alternatively, if you can connect via HTTPS, you'll be able to connect using an auth token in next release (https://github.com/dagger/dagger/pull/6992):

func (m *MyModule) MyPrivateFiles(ctx context.Context, token *Secret) ([]string, error) {
  return (
    dag.Git("https://acme.tld/private-repo.git").
    WithAuthToken(token).
    Head().
    Tree().
    Entries(ctx)
}

If you have a MY_PAT env var, for example:

dagger call my-private-files --token=MY_PAT
fossil star
spare cosmos
#

I'm also very interested in this. Is there something I could help with here?

fossil star
spare cosmos