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

CLI: allow passing sub-directories of a git repo #6944

Open
shykes opened this issue Mar 26, 2024 · 7 comments
Open

CLI: allow passing sub-directories of a git repo #6944

shykes opened this issue Mar 26, 2024 · 7 comments
Assignees

Comments

@shykes
Copy link
Contributor

shykes commented Mar 26, 2024

Problem

When passing an argument of type Directory, the CLI accepts a git remote url (eg. https://github.com/dagger/dagger) which is awesome; but it does not support passing a sub-directory of that git repo (eg. https://github.com/dagger/dagger/docs) which is not awesome.

Solution

Support passing a sub-directory of a git remote as CLI argument to Dagger CLI.

@shykes shykes added the area/cli All about go code on dagger CLI label Mar 26, 2024
@jedevc
Copy link
Member

jedevc commented Mar 27, 2024

This can be done today using something like the following syntax:

dagger -m github.com/vikram-dagger/daggerverse/fileutils call tree --dir=https://github.com/dagger/dagger#main:cmd/dagger

This is the same syntax as found in dockerfiles - see https://docs.docker.com/build/building/context/#url-fragments.


Supporting generic slashes is interesting, but I'm not actually sure how possible this is given how nesting works:

  • github.com/foo/bar/baz/qux is an org foo with project bar with baz/qux as the path
  • gitlab.com/foo/bar/baz/qux could be:
    • an org foo with project bar with baz/qux as the path
    • an org foo with sub-org bar with project baz with qux as the path
    • an org foo with sub-org bar with sub-org baz with project qux

We've discussed this before in relation to module refs - cc @vito. We could just steal what go does today, and use special meta tags in pages (maybe it's worth just biting that bullet?)

@shykes
Copy link
Contributor Author

shykes commented Mar 27, 2024

This works fine for me. We should just document it.

@shykes
Copy link
Contributor Author

shykes commented Mar 27, 2024

Supporting generic slashes is interesting, but I'm not actually sure how possible this is given how nesting works:

  • github.com/foo/bar/baz/qux is an org foo with project bar with baz/qux as the path

  • gitlab.com/foo/bar/baz/qux could be:

    • an org foo with project bar with baz/qux as the path
    • an org foo with sub-org bar with project baz with qux as the path
    • an org foo with sub-org bar with sub-org baz with project qux

We've discussed this before in relation to module refs - cc @vito. We could just steal what go does today, and use special meta tags in pages (maybe it's worth just biting that bullet?)

Don't we have to solve this problem anyway for dagger -m <MOD>?

I do think it's a little weird for users, that we have 2 completely different ways to describe the same thing (a directory inside a remote git repo) depending on which flag it's being passed to.

@vito
Copy link
Contributor

vito commented Mar 27, 2024

@shykes Yep, that's what the v2 refs proposal was all about (#6187); it was meant to be a unified ref syntax for any Directory, which could be used for both module refs and arbitrary git + subpath refs. But then we got stuck in discussions around whether we want short refs for the Daggerverse and the proposal died.

Combined with #6895 where a contributor is trying to decouple our module refs from GitHub, it feels like it's time to revive that proposal (in spirit, not necessarily in its last form).

@jedevc
Copy link
Member

jedevc commented Mar 28, 2024

Potential proposal - could we "borrow" the go method of working out where the split is, and then also add our own version in as well (essentially s/go/dagger) for anyone implementing it from scratch?

That would help at least unblock #6895, even if we don't fully get to the full power of refs v2 described in #6187. Personally, I don't love the git syntax we pull from buildkit, I'd happily deprecate it and replace it with go-style refs - it's incredibly non obvious how to use it, I always forget the order of the fragment.

@pjmagee
Copy link
Contributor

pjmagee commented May 25, 2024

How does terraform do it?

module "example_module" {
  source = "git::https://github.com/username/repo.git//path/to/subdirectory?ref=branch_or_tag"
}

@samalba samalba removed the area/cli All about go code on dagger CLI label May 31, 2024
@helderco
Copy link
Contributor

helderco commented Jul 5, 2024

@grouville, can you own this as well?

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

6 participants