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

Mini conduit in Git #428

Merged
merged 28 commits into from
Jan 5, 2021
Merged

Mini conduit in Git #428

merged 28 commits into from
Jan 5, 2021

Conversation

dinosaure
Copy link
Member

/cc @hannesm, /cc @ulugbekna

@dinosaure
Copy link
Member Author

Ok, this PR reached a state where I'm able to provide a simple unikernel to fetch a Git repository without Irmin. The idea is to fill as long as CLI arguments the Mimic.ctx to be able to start a connection. Currently, such scenario works:

$ ./minigit --ssh-seed my-seed -r [email protected]:dinosaure/art
$ ./minigit -r https://github.com/dinosaure/art
$ ./minigit -r git://github.com/dinosaure/art

However, a call with an SSH endpoint without an SSH seed does not work. http://github.com/dinosaure/art does not work too due to a redirection to HTTPS. So, it highlights some issues:

  1. be able to recognize the type of the connection (if it's SSH or not)
  2. do the redirection to HTTPS when it's required by the peer

@dinosaure
Copy link
Member Author

I think we reach a good state where I handle any cases, see the README.md.

  • clean the PR
  • add some tests & compile the unikernel (UNIX target)

@dinosaure
Copy link
Member Author

At this stage, the PR is cleaned and tests are added to check the behavior of mimic. Some improvements come to my mind about mimic but I think it's enough for a proper release. Ready to merge, I hope that my PR still is orthogonal to #420

@dinosaure
Copy link
Member Author

I locally merge this PR and #420 and all seems fine. Go to merge.

@dinosaure dinosaure merged commit e26c20b into master Jan 5, 2021
@ulugbekna
Copy link
Contributor

It was an interesting read, and all looks good to me! Two things to note:

  1. I'm not sure I understand what a new parameter verify in fetch is. It could use a slightly more descriptive name maybe and an explanation in the docs what verification it provides
  2. There is no docs for mimic, so we should either at least refer to conduit's docs or write some better docs (I could take care of that some time later perhaps)

@dinosaure
Copy link
Member Author

I'm not sure I understand what a new parameter verify in fetch is. It could use a slightly more descriptive name maybe and an explanation in the docs what verification it provides

This new argument is not very useful but in some contexts, it should be interesting to "verify" the status of the flow. And in that case, for example, verify that the Mimic.flow is an SSH connection when the Endpoint.t has the SSH scheme. It's like a user-defined post-verification of what Mimic.resolve returns.

Initially, this argument is used to prove that we use an SSH connection when we use git@domain:user/repository.git and such function can be only defined by the end-user (who knows about the SSH implementation). By this way, we are able to return an error when mimic is able to start an SSH connection even if we use git://domain/user/repository.git (so, when the user gives to us a Git endpoint and an SSH key).

However, such situation can be avoided by an other way. Instead to use ?verify to ensure the correspondence between Smart.Endpoint.t and Mimic.flow, we can enforce the initialization of the SSH connection with an other parameter/Mimic.value which exists only by an introspection of the Smart.Endpoint.t.

In this code:

let with_smart_git_endpoint edn ctx =
match Smart_git.Endpoint.of_string edn with
| Ok { Smart_git.Endpoint.scheme = `SSH user; _ } -> with_user user ctx
| _ -> ctx

We can fill the Mimic.ctx with a value val is_ssh : bool Mimic.value and redefine these functions:

let with_resolv ctx =
let k (stack, ipaddr, port) ssh_authenticator ssh_user ssh_key git_path
git_capabilities =
Lwt.return_some
{
stack;
ipaddr;
port;
authenticator = ssh_authenticator;
user = ssh_user;
key = ssh_key;
path = git_path;
capabilities = git_capabilities;
}
in
let ctx =
Mimic.(
fold ssh_endpoint
Fun.
[
req TCP.tcp_endpoint; opt ssh_authenticator; req ssh_user;
req ssh_key; req Git.git_path; dft Git.git_capabilities `Rd;
]
~k ctx)
in
let k stack ipaddr port = k (stack, ipaddr, port) in
let ctx =
Mimic.(
fold ssh_endpoint
Fun.
[
req TCP.tcp_stack; req TCP.tcp_ipaddr; dft TCP.tcp_port 22;
opt ssh_authenticator; req ssh_user; req ssh_key;
req Git.git_path; dft Git.git_capabilities `Rd;
]
~k ctx)
in
ctx

with a req is_ssh. I will propose a PR but I'm a bit lazy 👍.

There is no docs for mimic, so we should either at least refer to conduit's docs or write some better docs (I could take care of that some time later perhaps)

We should retake the Conduit's documentation indeed. I'm a bit frustrated to rewrite N times the same documentation. It's not mandatory. mimic is used only by ocaml-git (and paf) and git-mirage comes with enough to hide mimic under the forest. If you want to do that, I will be happy. Otherwise, it's fine.

dinosaure added a commit to dinosaure/opam-repository that referenced this pull request Jan 9, 2021
… git-unix (3.0.0)

CHANGES:

- Rewrite of `ocaml-git` (@dinosaure, mirage/ocaml-git#395)
- Delete useless constraints on digestif's signature (@dinosaure, mirage/ocaml-git#399)
- Add support of CoHTTP with UNIX and MirageOS (@ulugbekna, mirage/ocaml-git#400)
- Add progress reporting on fetch command (@ulugbekna, mirage/ocaml-git#405)
- Lint dependencies on packages (`git-cohttp-unix` and `git-cohttp-mirage`)
  and update to the last version of CoHTTP (@hannesm, mirage/ocaml-git#407)
- Fix internal `Cstruct_append` implementation (@dinosaure, mirage/ocaml-git#401)
- Implement shallow commit (@dinosaure, mirage/ocaml-git#402)
- Update to `conduit.3.0.0` (@dinosaure, mirage/ocaml-git#408) (deleted by the integration of `mimic`)
- Delete use of `ocurl` (@dinosaure, mirage/ocaml-git#410)
- Delete the useless **old** `git-mirage` package (@hannesm, mirage/ocaml-git#411)
- Fix about unresolved endpoint with `conduit.3.0.0` (@dinosaure, mirage/ocaml-git#412)
- Refactors fetch command (@ulugbekna, mirage/ocaml-git#404)
- Fix ephemerons about temporary devices (@dinosaure, mirage/ocaml-git#413)
- Implementation of `ogit-fetch` as an example (@ulugbekna, mirage/ocaml-git#406)
- Rename `nss` to `git-nss` (@dinosaure, mirage/ocaml-git#415)
- Refactors `git-nss` (@ulugbekna, mirage/ocaml-git#416)
- Update README.md (@ulugbekna, mirage/ocaml-git#417)
- Replace deprecated `Fmt` functions (@ulugbekna, mirage/ocaml-git#421)
- Delete physical equality (@ulugbekna, mirage/ocaml-git#422)
- Rename `prelude` argument by `uses_git_transport` (@ulugbekna, mirage/ocaml-git#423)
- Refactors Smart decoder (@ulugbekna, mirage/ocaml-git#424)
- Constraint to use `fmt.0.8.7` (@dinosaure, mirage/ocaml-git#425)
- Small refactors in `git-nss` (@dinosaure, mirage/ocaml-git#427)
- Delete `conduit.3.0.0` and replace it by `mimic` (@dinosaure, mirage/ocaml-git#428)
- Delete the useless `verify` function on `fetch` and `push` (@dinosaure, mirage/ocaml-git#429)
- Delete `pin-depends` on `awa` (@dinosaure, mirage/ocaml-git#431)
dinosaure added a commit to dinosaure/opam-repository that referenced this pull request Jan 9, 2021
…t-unix and git-mirage (3.0.0)

CHANGES:

- Rewrite of `ocaml-git` (@dinosaure, mirage/ocaml-git#395)
- Delete useless constraints on digestif's signature (@dinosaure, mirage/ocaml-git#399)
- Add support of CoHTTP with UNIX and MirageOS (@ulugbekna, mirage/ocaml-git#400)
- Add progress reporting on fetch command (@ulugbekna, mirage/ocaml-git#405)
- Lint dependencies on packages (`git-cohttp-unix` and `git-cohttp-mirage`)
  and update to the last version of CoHTTP (@hannesm, mirage/ocaml-git#407)
- Fix internal `Cstruct_append` implementation (@dinosaure, mirage/ocaml-git#401)
- Implement shallow commit (@dinosaure, mirage/ocaml-git#402)
- Update to `conduit.3.0.0` (@dinosaure, mirage/ocaml-git#408) (deleted by the integration of `mimic`)
- Delete use of `ocurl` (@dinosaure, mirage/ocaml-git#410)
- Delete the useless **old** `git-mirage` package (@hannesm, mirage/ocaml-git#411)
- Fix about unresolved endpoint with `conduit.3.0.0` (@dinosaure, mirage/ocaml-git#412)
- Refactors fetch command (@ulugbekna, mirage/ocaml-git#404)
- Fix ephemerons about temporary devices (@dinosaure, mirage/ocaml-git#413)
- Implementation of `ogit-fetch` as an example (@ulugbekna, mirage/ocaml-git#406)
- Rename `nss` to `git-nss` (@dinosaure, mirage/ocaml-git#415)
- Refactors `git-nss` (@ulugbekna, mirage/ocaml-git#416)
- Update README.md (@ulugbekna, mirage/ocaml-git#417)
- Replace deprecated `Fmt` functions (@ulugbekna, mirage/ocaml-git#421)
- Delete physical equality (@ulugbekna, mirage/ocaml-git#422)
- Rename `prelude` argument by `uses_git_transport` (@ulugbekna, mirage/ocaml-git#423)
- Refactors Smart decoder (@ulugbekna, mirage/ocaml-git#424)
- Constraint to use `fmt.0.8.7` (@dinosaure, mirage/ocaml-git#425)
- Small refactors in `git-nss` (@dinosaure, mirage/ocaml-git#427)
- Delete `conduit.3.0.0` and replace it by `mimic` (@dinosaure, mirage/ocaml-git#428)
- Delete the useless `verify` function on `fetch` and `push` (@dinosaure, mirage/ocaml-git#429)
- Delete `pin-depends` on `awa` (@dinosaure, mirage/ocaml-git#431)
dinosaure added a commit to dinosaure/opam-repository that referenced this pull request Jan 9, 2021
…t-unix and git-mirage (3.0.0)

CHANGES:

- Rewrite of `ocaml-git` (@dinosaure, mirage/ocaml-git#395)
- Delete useless constraints on digestif's signature (@dinosaure, mirage/ocaml-git#399)
- Add support of CoHTTP with UNIX and MirageOS (@ulugbekna, mirage/ocaml-git#400)
- Add progress reporting on fetch command (@ulugbekna, mirage/ocaml-git#405)
- Lint dependencies on packages (`git-cohttp-unix` and `git-cohttp-mirage`)
  and update to the last version of CoHTTP (@hannesm, mirage/ocaml-git#407)
- Fix internal `Cstruct_append` implementation (@dinosaure, mirage/ocaml-git#401)
- Implement shallow commit (@dinosaure, mirage/ocaml-git#402)
- Update to `conduit.3.0.0` (@dinosaure, mirage/ocaml-git#408) (deleted by the integration of `mimic`)
- Delete use of `ocurl` (@dinosaure, mirage/ocaml-git#410)
- Delete the useless **old** `git-mirage` package (@hannesm, mirage/ocaml-git#411)
- Fix about unresolved endpoint with `conduit.3.0.0` (@dinosaure, mirage/ocaml-git#412)
- Refactors fetch command (@ulugbekna, mirage/ocaml-git#404)
- Fix ephemerons about temporary devices (@dinosaure, mirage/ocaml-git#413)
- Implementation of `ogit-fetch` as an example (@ulugbekna, mirage/ocaml-git#406)
- Rename `nss` to `git-nss` (@dinosaure, mirage/ocaml-git#415)
- Refactors `git-nss` (@ulugbekna, mirage/ocaml-git#416)
- Update README.md (@ulugbekna, mirage/ocaml-git#417)
- Replace deprecated `Fmt` functions (@ulugbekna, mirage/ocaml-git#421)
- Delete physical equality (@ulugbekna, mirage/ocaml-git#422)
- Rename `prelude` argument by `uses_git_transport` (@ulugbekna, mirage/ocaml-git#423)
- Refactors Smart decoder (@ulugbekna, mirage/ocaml-git#424)
- Constraint to use `fmt.0.8.7` (@dinosaure, mirage/ocaml-git#425)
- Small refactors in `git-nss` (@dinosaure, mirage/ocaml-git#427)
- Delete `conduit.3.0.0` and replace it by `mimic` (@dinosaure, mirage/ocaml-git#428)
- Delete the useless `verify` function on `fetch` and `push` (@dinosaure, mirage/ocaml-git#429)
- Delete `pin-depends` on `awa` (@dinosaure, mirage/ocaml-git#431)
@dinosaure dinosaure deleted the mimic branch March 15, 2021 14:40
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

Successfully merging this pull request may close these issues.

2 participants