#listing git tags
1 messages ยท Page 1 of 1 (latest)
do you mean a way to have it run git fetch --tags for you, or do you mean an API to list tags? (for the latter, there's a .Tags API but it's not implemented yet: https://github.com/dagger/dagger/blob/479c3d3b4dd2933711317f87990e8d632e10a76e/core/schema/git.graphqls#L36-L37 + https://github.com/dagger/dagger/blob/479c3d3b4dd2933711317f87990e8d632e10a76e/core/schema/git.go#L111-L113)
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
yeah, was about to suggest that. ๐ I think you just need to set $SSH_AUTH_SOCK? (and mount the socket)
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.
coming from here but am pretty new to go, so trying to wrap my head around it. surely am doing something wrong
https://github.com/dagger/dagger/blob/db72eea05f60d2738f7c26d07b157e8acff0e009/engine/sshsock.go#L70
i guess it is actually failing to clone
I'm surprised you didn't need to set the SSH auth socket for the src := ... (e.g. https://docs.dagger.io/710884/private-repositories/)
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 ""
oh, nice ๐
...
#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
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)
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
i guess you could run git remote set-url origin <ssh url>? ๐
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