#listing git tags

1 messages ยท Page 1 of 1 (latest)

limber mist
pulsar haven
#

Hi vito! I am hoping to have it fetched as if git fetch was ran, maybe it is feasible to do that via exec and providing the ssh_auth_sock for auth

#

trying that now

limber mist
#

yeah, was about to suggest that. ๐Ÿ™‚ I think you just need to set $SSH_AUTH_SOCK? (and mount the socket)

pulsar haven
#

here's where i am so far

func MountSource(ctx context.Context, client *dagger.Client, container *dagger.Container, m Module, path string) (*dagger.Container, error) {
    url := fmt.Sprintf("git@%s:%s/%s", a.GitHubUrl, a.GitHubOrg, m.GitRepoName)
    src := client.Git(url, dagger.GitOpts{KeepGitDir: true}).Branch(m.Branch).Tree()

    socket := client.Host().UnixSocket(os.Getenv("SSH_AUTH_SOCK"))
    mount := container.WithMountedDirectory("/src", src).
        WithEnvVariable("SSH_AUTH_SOCK", "/ssh_auth_sock").
        WithUnixSocket("/ssh_auth_sock", socket).
        WithWorkdir(path).
        WithExec([]string{"git", "tag", "-l"})

    if _, err := mount.ExitCode(ctx); err != nil {
        return nil, err
    }
    return mount, nil
}

getting this:

...
#2 [internal] load metadata for docker.io/library/docker:stable-dind
error: input:1: container.build.withMountedDirectory.withEnvVariable.withUnixSocket.withWorkdir.withExec.withExec.exitCode NotFound: no ssh handler for id default

Please visit https://dagger.io/help#go for troubleshooting guidance.
#

i guess it is actually failing to clone

limber mist
#

but also not sure why you're getting that error ๐Ÿค”

#

@pulsar haven is $SSH_AUTH_SOCK set for you? wondering if os.Getenv() is returning ""

pulsar haven
#

thanks! clone definitely working now

#

new error ๐Ÿ™‚

limber mist
#

oh, nice ๐Ÿ˜„

pulsar haven
#
...

#21 git://someurl.com/someorg/iacpoc-tf-gcp-lookup-labels.git#develop
#21 0.713 27b2cdcc9c35151c77b06ee10063f5cef8021a54    refs/heads/develop
#21 CACHED

22 dockerd-entrypoint.sh git fetch
#22 1.688 fatal: could not read Password for 'https://xxxxx@someurl.com': No such device or address
error: input:1: container.build.withMountedDirectory.withEnvVariable.withUnixSocket.withWorkdir.withExec.exitCode process "dockerd-entrypoint.sh git fetch" did not complete successfully: exit code: 128
limber mist
#

might need to use a git@ url instead of https://? though I'm not sure why that wouldn't be a problem for the initial clone

#

(oops, that's assuming github, I just mean a SSH URI)

pulsar haven
#

am using git@%s:%s/%s.git", "someurl", "someorg", "iacpoc-tf-gcp-lookup-labels")

#

obfuscated for no reason here

#

but yeah its weird to see https in that error

limber mist
#

i guess you could run git remote set-url origin <ssh url>? ๐Ÿ™ƒ

limber mist
#

for some context, we're somewhat constrained in what APIs we can support here (e.g. a fetch param), because this API passes straight through to Buildkit which only really has what we already expose. it'd be nice if you can just run your own git commands to do the rest, assuming it's not too painful, mostly because this kind of API tends to be a slippery slope when you start adding all sorts of params for different use cases. just my 2c though!

#

perhaps someday all these git++ operations could be turned into shareable code (i.e. Dagger extensions), which just runs git commands wrapped in a more ergonomic API