Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git push #7202

Open
sagikazarmark opened this issue Apr 26, 2024 · 5 comments
Open

Git push #7202

sagikazarmark opened this issue Apr 26, 2024 · 5 comments

Comments

@sagikazarmark
Copy link
Contributor

What are you trying to do?

First class or at least decent support for pushing to Git repositories.

Why is this important to you?

Dagger already has first-class support for pulling from Git repositories (even if private repo support isn't trivial).

It's often important to push changes back to a repository. A couple use cases in mind:

  • Regenerate SDKs from API descriptors upon change
  • Update GitOps manifests when a new version is out

Unfortunately, feeding credentials into Git (whether it's SSH or HTTPS) is not trivial.

How are you currently working around this?

There is already an existing example using go-git: https://daggerverse.dev/mod/github.com/matipan/daggerverse/image-updater@7dafaf057c4524654903414fc3a7b5e2374f5695

Ideally, there should be a generic "git push" solution: whether it's built into Dagger or available as a separate module.

@shykes
Copy link
Contributor

shykes commented Apr 27, 2024

In case it's useful, I recently started a new git module. It doesn't support push, but has a clean and simple foundation to add it.

https://daggerverse.dev/mod/github.com/shykes/git

@sagikazarmark
Copy link
Contributor Author

@shykes Sounds good!

What do you think would be the best way to implement authentication?

GitHub supports http+token auth, but SSH is probably still the most common way to authenticate with Git. CI systems (like GHA) probably work better with API tokens.

@shykes
Copy link
Contributor

shykes commented Apr 29, 2024

I would start simple, and add a []SSHKey field to the Repo state, with assorted WithSSHKey and WithSSHKeys to add them. then a Push() function that makes sure to write the ssh keys to the right place in the container, and calls git push. Start with passing the argument as-is. Then, iterate from there.

@sagikazarmark
Copy link
Contributor Author

Would it make sense to add WithSSHKey to the Git object instead (or as well) so they can be used to clone private repos as well?

@shykes
Copy link
Contributor

shykes commented Apr 30, 2024

Would it make sense to add WithSSHKey to the Git object instead (or as well) so they can be used to clone private repos as well?

Yes that makes perfect sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants