Skip to content

Allow installing modules from private Git repositories. #6113

Closed

Description

@nipuna-perera

What are you trying to do?

Currently you can only dagger install modules hosted in public Git repositories. While this is great for OSS, it's not ideal for Enterprises that use private Git repositories like Gitlab and Github Enterprise.

We require a way to somehow pass in/use authentication (GH PAT for example) when adding a module hosted in a private git repository.

Discord thread: https://discord.com/channels/707636530424053791/1171809848057401375

Why is this important to you?

  • Companies in highly regulated industries cannot publish modules in the open. Git repositories hosted within our Github Enterprise instance requires authentication in order to access. This is a blocker for using dagger modules.
  • Personal projects that don't want to create public Git repositories aren't currently supported.

How are you currently working around this?

No known workaround so far which makes this a high priority request for us and any others using private Git repositories to host Dagger modules.

Activity

  1. skycaptain commented on Mar 7, 2024

    @skycaptain
    Contributor

    Bringing attention back to this issue now that modules have become the default. (I suppose, as the docs only mention the modules and previous cookbooks and guides have been removed). For us, this is the only obstacle preventing us from using Dagger modules at present. I think this could be a Good First Issue. However, general approval on support this would be highly appreciated before beginning implementation.

  2. Alvise88 commented on Mar 20, 2024

    @Alvise88
    Contributor

    If i want to add a private lib in go.mod the problem arise the same

  3. mehemken commented on Apr 1, 2024

    @mehemken

    Just adding to the Why is this important to you? section.

    I would like to keep my personal projects private.

    No need to summon "highly regulated industry". It is just basic privacy.

  4. Transmitt0r commented on Apr 12, 2024

    @Transmitt0r

    Would be a very nice feature, I'm interested in using this with modules hosted on our internal Bitbucket instance.

  5. grouville commented on Jun 3, 2024

    @grouville
    Member

    This is under active development at this very moment

    It is tightly linked to the implementation of #7218.

    The first part is this PR: #7511, followed by another one for the directory refs, in which we unify the currently different way to reference directories and files on git remotes

    This one has been unblocked recently by Erik's work on the CA certificates that allows passing SSH sockets securely. A draft PR shall be available this week, on which feedback from the community is welcome 😁

  6. changed the title [-]✨ Zenith: Allow installing modules from private Git repositories.[/-] [+]Allow installing modules from private Git repositories.[/+] on Jun 3, 2024
  7. oblogic7 commented on Jul 3, 2024

    @oblogic7

    Any updates or ETA for this functionality? I ran into this when doing a POC for my org.

  8. LiHRaM commented on Jul 4, 2024

    @LiHRaM
  9. grouville commented on Jul 4, 2024

    @grouville
    Member

    Thanks @oblogic7 for asking, and @LiHRaM for the answer 🙏

    A few intermediary steps were necessary too:

    Indeed these are the two main PRs for the implementation: with #7708 to be the first one to be merged. #7608 will be a followup.

    As stated in a comment with Nipuna, the current implementation relies on SSH auth, but the design also needs to anticipate the other forms of auth.

    I've got a rebase / improvement for #7742 + a comment incoming, to discuss all the design choices implied to make sure with the community that every use case is taken into account and that the path to full implementation is clear and all intermediary implementations

  10. grouville commented on Aug 1, 2024

    @grouville
    Member

    Update

    Main PR for SSH support has been reviewed, and all the requested changes have been implemented. A bit more reviews are expected this week (yours is welcome too). This is probably going to be part of next release.

    Your feedback is welcome, especially on the DX of this ref style, which you can see here

    Once done, the http / https + PAT support is going to be my priority

  11. skycaptain commented on Aug 1, 2024

    @skycaptain
    Contributor

    Great progress so far!

    Regarding DX on the ref style:

    1. Gitlab, similar to Bitbucket, also uses the git user for SSH.
    2. Looking at https://github.com/vito/dagger/blob/refs-v2/rfcs/001-refs-v2.md: On GitLab, it's very convenient to use the "Code > Clone with SSH/HTTPS > Copy URL" buttons on a project. It formats the address like this for SSH: [email protected]:dagger-modules/private/test/more/dagger-test-modules-private.git. It would be great if this format is also supported.
  12. grouville commented on Aug 1, 2024

    @grouville
    Member

    Gitlab, similar to Bitbucket, also uses the git user for SSH.

    Oh sorry, the git user is inferred for that example. If this behavior creates confusion, I can add a comment OR change the logic to fail on that ?

    Current PR ref spec
    [proto][user@]repo[.git][subpath][@version]

    With proto:

    • git+ssh://
    • git+http://
    • git+https://

    Empty proto is transformed as git+https://

    For private repos, the [.git] is recommended to declaratively say where the repo separates and where the path inside the repo starts. Which is useful for private GitLab

    cc @aluzzardi what do you think about SCP-like refs: [email protected]:dagger-modules/private/test/more/dagger-test-modules-private.git. I know that @jedevc is against it, as it could become a rabbithole.

    Now, I do agree with you @skycaptain on the fact that these copy buttons are useful, but what I end up doing is copying the URL from the browser and edit it.

    With above ref style, your:

    • [email protected]:dagger-modules/private/test/more/dagger-test-modules-private.git
      would become:
      git+ssh://[email protected]/dagger-modules/private/test/more/dagger-test-modules-private.git
      by adding the proto and replacing the :.

    Would that be a no-go ?

  13. skycaptain commented on Aug 1, 2024

    @skycaptain
    Contributor

    Ah, sorry, got it. You've just omitted the git user for that test. I think that might be fine for a test, even though it's very unlikely in the real world. If the user is not defined, one would rely on the devs to set up their ~/.ssh/config accordingly. On the other hand, git has the same behaviour. So, not an issue, I guess. On a side note: Gitlab allows changing the default git user on self-hosted instances, even though it seems very rare for people to change that.

    Regarding the ref spec: You are right that both cases (using the Copy URL button or copying the URL from the browser's address bar) require manual editing the URL by the developer. Maybe it's just me, but when copying from the browser's address bar, I'm more prone to forgetting to add the .git suffix (which seems kind of mandatory for dagger to detect subpaths) or copying a tree path like https://gitlab.com/dagger-modules/private/test/more/dagger-test-modules-private/-/tree/main/mymodule?ref_type=heads instead of just https://gitlab.com/dagger-modules/private/test/more/dagger-test-modules-private, just because my browser selects the whole URL when clicking the address bar. Additionally, we developers are really lazy 😄: With the Copy URL button, I would type git+ssh://, then hit Cmd+v, and finally hit Enter. When copying from the browser's address bar, I would copy the URL, being careful as some browsers like Chrome add an https:// to the URL and require a second click to select the URL without the scheme, type git+ssh://, hit Cmd+v, move the cursor back, and remove the https:// if I accidentally copied it (looking at you, Chrome), type .git, and hit Enter. That's why I prefer to use the Copy URL button. On the other hand, I guess most module developers will write READMEs that include a copy-paste line. In CI, we use HTTPS anyway.

  14. grouville commented on Aug 2, 2024

    @grouville
    Member

    Thanks @skycaptain,

    Your feedback helped reassessing the DX 🙏.

    Following your comments, with @aluzzardi, we paused a bit after your feedback and tried to think on a first-principle basis about:

    • Go-style refs -- github.com/aluzzardi/daggerverse
    • Git HTTPS (copy button with HTTP protocol on all providers GitHub / GitLab / BitBucket...) -- https://github.com/dagger/dagger.git
    • Git SCP-like (copy button with SSH protocol on all providers) -- [email protected]:dagger/dagger.git

    You're right, the scope of the issue is to come up with the proper ref style, where DX is the most important component. It needs to be intuitive / easy to read and not too verbose for users.

    Context

    1. The Go-ref style was introduced by Google to abstract the VCS AND the protocol from the ref. In which that the ref itself is its canonical representation. However, do we really need to apply these constraints to us ?
    2. Most Git providers such as GitHub / GitLab ... all have a copy button to have an easy access to git https and git scp-like refs, and most developers are used to this DX, and more importantly, they seem to love copy-pasting these refs.
    image

    Lastly, the current effort with the very explicit ref style (the one with git+ssh://) was introduced to be computationally correct, at the expense of the DX. This format helps to have a unified ref for both modules AND dir / file passed as CLI arguments.

    Now, after reflexion, Andrea came up with a series of postulates that could help scoping the ref style:

    1. It is ok for Dagger to store modules only on Git - being VCS agnostic to store modules is not worth the effort
    2. It is acceptable to have a different ref style for modules and for CLI arguments, especially to handle CLI: support passing a remote URL as file argument #6957 (comment). Also, it is ok for CLI arguments to expect a future support to other VCS, so for the CLI input ref-style to anticipate a vision for multiple VCS support
    3. The scope of the issue is the user-input ref for modules, the one being referenced upon dagger install / dagger -m ... by the user, which shall optimize for ease-of-use / familiarity / and clarity ; however, it is ok for its canonical reference or internal reference inside the dagger.json to be more explicit
    4. It is sort of a separate issue and could be scoped as a follow-up, but it is important (or not?) for the same ref with different protos to be resolved internally as the same module
    5. git rewrite rules are not ideal, as they bring the resolving logic client-side, which impacts the ci / local unification

    Given that postulate, these 3 ref styles are all pretty solid schemes to support:

    github.com/aluzzardi/daggerverse
    https://github.com/dagger/dagger.git
    [email protected]:dagger/dagger.git

    HTTPs
    [proto]host/path[.git][subpath][@version]

    with proto:

    • empty (current go-like ref)
    • https:// or http://, which are the proto proposed by default on the copy button of all Git providers
    image

    This introduces a retro-compatible ref-format with an easy mono-repo handling: copy-paste the button from GitHub, add the path and the version, you're good to go. Easy-to-do, easy to remember.

    The risk of a ref for http that supports Go-like style and Git-HTTP style is that we could end up with a lot of variations of those refs as valid:

    E.g

    github.com/aluzzardi/daggerverse
    https://github.com/dagger/dagger
    https://github.com/dagger/dagger/[email protected]
    github.com/dagger/dagger/[email protected]
    github.com/dagger/dagger.git/[email protected]
    

    cc @aluzzardi, I do not remember, when we discussed, did you intend for us to be more strict on the ref format ?

    What I mean is that: when we have the https / http protos specified, we expect a .git as present on the ref style of the Git-HTTP style ? Such as https://github.com/dagger/dagger would be invalid. Or do you mean all variations of above are correct ?

    On the contrary, when thinking about it, I have the feeling that not including the proto and continuing full-on as a go-style ref for HTTP is also acceptable. People can copy the ref and just remove the http / https proto themselves. They're doing it right now, and it's not that painful. At least, it is for sure not as painful to delete than to write git+ssh://.
    WDYT @skycaptain ? @aluzzardi ?

    No strong opinion, I just worry about the amount of variations we would see popping up with a more loose scheme.
    Remaining on go-like format would look like: host/path[.git][subpath][@version]

    SSH refs
    Here, we do full SCP-like format. This is the alternative format proposed as the default SSH ref in the copy buttons of those git providers:
    [user@]host:path[.git][subpath][@version]

    image

    The distinction is indeed the :, which enforces the SSH protocol

    When not set, user could be inferred as git (or not?). We could enforce its presence. Same question as above, do we also expect the .git ? (to be wary of all potential variations this implies)

    E.g

    github.com:dagger/dagger
    github.com:dagger/dagger/[email protected]
    github.com:dagger/dagger.git/[email protected]
    [email protected]:dagger/dagger/[email protected]
    

    In both those examples, users are encouraged to just copy-paste from the provider.

    You're on a monorepo ? Just append the subpath ; Need a version ? Just add @ and a version after.
    Easy to remember, easy to do

    Daggerverse impact

    Also, both formats are pretty similar and their ref formats can totally be copy-pasted and tweaked to a Daggerverse URL

    Let's take for example: https://daggerverse.dev/mod/github.com/levlaz/daggerverse/docusaurus@6c7c28cd95a9636a04768c8de8b658d724cdecb3.

    The current ref is: github.com/levlaz/daggerverse/[email protected], to which, the version is resolved to the actual commit in the URL.

    Let's try to see a few of those variations for all the supported protocols with the new ref scheme:

    1. github.com/levlaz/daggerverse/[email protected]
    2. https://github.com/levlaz/daggerverse.git/[email protected]
    3. [email protected]:levlaz/daggerverse.git/[email protected]

    And that all these examples would continue to lead to the same Daggerverse URL: https://daggerverse.dev/mod/github.com/levlaz/daggerverse/docusaurus

    If i were to see such ref in any dagger.json or any repo, finding the equivalent valid daggerverse representation is quite easy:

    • remove protos
    • transform : into /
    • strip versions

    to be mindful -> remove the .git too ?

    There is also a path for the daggerverse to redirect to the proper modules, even with the SSH ref format?

    cc WDYT @jedevc ?

  15. jedevc commented on Aug 2, 2024

    @jedevc
    Contributor

    Ahh I see the logic for wanting to support scp-style git URLs - I guess I'm happy with it, since users can just do the copy and paste. That's the most important feature (my bad). Also happy to kill the git+ssh idea.

    There's one case missing in the above I think - ssh://[email protected]/dagger/dagger.git/[email protected], or similar. While not copy-pasteable in the GitHub UI, users might attempt to use it and there's really no added cost to us to support it.

    One note from a parsing perspective - having two @s in a ref url is tricky, parsing off the optional version at the end needs to be done carefully.

  16. grouville commented on Nov 7, 2024

    @grouville
    Member

    Closed by #8805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions