-
Notifications
You must be signed in to change notification settings - Fork 28
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
make paths compatible with 'go get' #2
Comments
@noffle good stuff!
|
Yeah good stuff! :) I'm concerned about adding git repos:
Does Another idea, how about git-remote-ipfs? :) https://github.com/cryptix/git-remote-ipfs
Can't reproduce with |
Thanks for the comments!
We'll be publishing the repo at a specific version (the git repo will be frozen from time of publish), so all users will get the same git repo with the same HEAD as long as they use that hash.
Agreed, that could hurt the experience. If it becomes a problem we can make the
Really excited for
Yes, definitely. Thank you @lgierth! |
One issue I can see it that many people will go the path of least resistance meaning without Instead of using local nodes, or even using ephemeral nodes people will just use |
@Kubuxu: that's right. However, it's a much better experience than receiving a page of errors. It'd be nice if we could have |
In my opinion the best solution would be to have a way to tell users what is wrong, why and how can they fix it but in lack of better alternative we will have to roll with this. (Just knowing people, an opt-in feature that requires extra step and doesn't give visible improvable won't be used). |
That'd be really nice to have: it'd be great if you could investigate it. |
Update: @lgierth and I looked at the It looks like the |
Best thing I can come up is abusing tokeniser and inserting string in quotes before package definition. It would be removed by gx-go while installing package. It makes
|
might be worthwhile @noffle to take a look here: https://github.com/whyrusleeping/git-ipfs-rehost |
@Kubuxu haha, i like that. |
Couldn't you just skip re-writing import paths and just put appropriate files in vendor, being compatible with So you can still put following in source files:
And then issue Now, if someone installs with go get, everything works; and if someone wants to install locked packages, she can issue |
It is like that in most other repos, not go-ipfs, but it means that using We don't want that, as in many cases dependency update will break some behaviour and user that installed go-ipfs might have different dependencies that we know of and he might experience different issue. |
Then maybe let ipfs daemon serve go-getable packages locally:
The package will be only go-gettable if ipfs daemon is already running, and |
why not just |
I've been thinking about this again with whyrusleeping/gx#100 in mind, and I think it wouldn't be too hard to add a shallow bare git repo at
The index.html page could give you clone instructions :) Bonus points: the bare repo could have an index.html too, which just redirects to |
Aw man, @lgierth -- I dig this! This way the current gx-go setup keeps working (just refer to Qmfoobar/mypkg), and go get importing works for free*!
|
Not quite, the ipfs gateway will need to respond to the go-get query that the |
what does the go-get query look like? Maybe it even follows redirects and we can omit the |
@whyrusleeping sorry, could you give more context? What part of what I wrote are you responding to? @lgierth a redirect would be great; we can dodge building any Go awareness into the gateway. I saw golang/go@932c8dd but haven't dug into it enough yet to see if it's entirely relevant. |
interesting, this sounds like we might just need /ipfs/Qmfoobar/mypkg/index.html with the respective meta tag? |
and i figure this means we could also make |
You can write a meta tag go will read like:
See, for example - https://pault.ag/go/debian (import name is |
Thanks @paultag! Between your example and the go docs I was able to put together a script that prepares the gx-go package in such a way: #!/bin/bash
rm -rf /tmp/gx
mkdir -p /tmp/gx
# 1. do a 'gx publish' to get the hash
OUTPUT=$(gx publish -f)
HASH=$(echo $OUTPUT | cut -d ' ' -f 6)
PACKAGE=$(echo $OUTPUT | cut -d ' ' -f 2)
# 2. 'ipfs get' it into /tmp/gx as the package name
ipfs get $HASH -o /tmp/gx/$PACKAGE 2> /dev/null > /dev/null
# 3. do a shallow bare git clone
git clone file://$(pwd) --bare --depth 1 /tmp/gx/$PACKAGE/${PACKAGE}.git 2> /dev/null
# 4. add the git repo to ipfs to get its hash
GIT_HASH=$(ipfs add -qrw /tmp/gx/$PACKAGE/${PACKAGE}.git | tail -n 1)
# 5. generate index.html that has <meta> tag
cat << EOF > /tmp/gx/$PACKAGE/index.html
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<meta name="go-import" content="gx/ipfs/${GIT_HASH}/${PACKAGE} git https://ipfs.io/ipfs/${GIT_HASH}/${PACKAGE}">
</head>
</html>
EOF
# 6. 'ipfs add -r' the whole thing
ipfs add -rq /tmp/gx/$PACKAGE | tail -n 1 This is 99% there, but with one unfortunate caveat: |
Looking forward to being able to |
lets figure out the gateway changes we need to make for this. cc @lgierth |
@whyrusleeping @lgierth: Did anyone chip away at this? I'd love to subscribe to the gateway bug if there's one |
This enables `go get` to parse go-import meta tags from index.html files stored in IPFS. One tiny step toward whyrusleeping/gx-go#2. For an import like `ipfs.io/ipfs/QmFoo/mypkg`, the gateway would previously redirect to `/ipfs/QmFoo/mypkg/` (note the trailing slash), which the `go get` tool can't deal with. Thankfully, `go get` sets a URL query parameter (`?go-get=1`) which we can use to switch off the redirect in this case. License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
ipfs/kubo#3963 is a tiny step in the right direction, Next blocker: the index.html file can never know its own hash :( @noffle's script above includes the original package hash, but the tag and import will never match: https://github.com/golang/go/blob/32d42fb6ec5421f0c64fe7f7ffec0b9e7956e1ea/src/cmd/go/internal/get/vcs.go#L650-L722 @whyrusleeping did you ever ask whether someone in the go team would consider accepting a patch adding ipfs support? Maybe it'd be enough to stretch the matching rules a little bit. |
This enables `go get` to parse go-import meta tags from index.html files stored in IPFS. One tiny step toward whyrusleeping/gx-go#2. For an import like `ipfs.io/ipfs/QmFoo/mypkg`, the gateway would previously redirect to `/ipfs/QmFoo/mypkg/` (note the trailing slash), which the `go get` tool can't deal with. Thankfully, `go get` sets a URL query parameter (`?go-get=1`) which we can use to switch off the redirect in this case. License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
This enables `go get` to parse go-import meta tags from index.html files stored in IPFS. One tiny step toward whyrusleeping/gx-go#2. For an import like `ipfs.io/ipfs/QmFoo/mypkg`, the gateway would previously redirect to `/ipfs/QmFoo/mypkg/` (note the trailing slash), which the `go get` tool can't deal with. Thankfully, `go get` sets a URL query parameter (`?go-get=1`) which we can use to switch off the redirect in this case. License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
ipfs/kubo#4143 brings with it new origin-ized gateway URLs a la https://somehashinbase32.ipfs.link -- we should re-evaluate this index.html blocker in light of this. |
We just chatted about this on IRC, actually it's not a blocker and pretty easily solved: if the request has |
Here's what we should try:
For /ipfs/QmFoo/mypkg, the tag would look like this: <meta name="go-import" content="dweb.link/ipfs/QmFoo/mypkg git https://dweb.link/ipfs/QmFoo/mypkg.git"> |
Any updates on this? It's been quite a while without go get working, can we implement a short-term fix while longer-term features are landed to make it better? Requiring users to install a custom tool to build software is hard to work around. |
This enables `go get` to parse go-import meta tags from index.html files stored in IPFS. One tiny step toward whyrusleeping/gx-go#2. For an import like `ipfs.io/ipfs/QmFoo/mypkg`, the gateway would previously redirect to `/ipfs/QmFoo/mypkg/` (note the trailing slash), which the `go get` tool can't deal with. Thankfully, `go get` sets a URL query parameter (`?go-get=1`) which we can use to switch off the redirect in this case. License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org> This commit was moved from ipfs/kubo@4fe5b3e
roadmap
multireq
to terminate the connection when receiving a non-HTTP header (GET / HTTP/1.1
)gx-go publish
to use the bare git repo scheme abovewhy?
It'd be a huge win for
gx
if the paths it generated were compatible with vanillago get
: this would keepgx
projects working for everyone outside of the ecosystem, and not break downstream vanilla dependents.how?
go get
hard codes nice-looking path support for special domains (github, bitbucket, googlecode), but any others need to use a slightly more awkward syntax:The suffix (
.git
) denotes the VCS used.public gateway
go get
requires a centralized domain for retrieval: the http://ipfs.io gateway is a simple and reliable candidate for distribution.gx-go path rewriting
We can rewrite paths to take the form
Which is roughly as readable as the current paths, and still puts all
gx
repos inside a consistent location ($GOPATH/src/ipfs.io/ipfs/
) that strongly suggests it's ipfs-related.If we wanted stronger namespacing, we could add gx to the path (so,
ipfs.io/ipfs/Qmfoobar/gx/go-multihash.git
).gx-go publish
To be compatible with both a) git HTTPS cloning, and b)
go get
retrieval, the following steps would need to be taken to publish an existing git-based go repo that will have the above compatibility:From here we should be 100%
go get
compatible:blocking problems
Before cloning,
go get
has a series of fallbacks for resolving an import path. For git, it issuesgit ls-remote
against the import path in this order-insecure
is present)Since
git://
comes first,go get
will issue a newline-terminated string liketo the gateway. This isn't HTTP, so behaviour is undefined. Some web servers will terminate one they see it, others will hang -- keeping the connection open indefinitely. Unfortunately, the ipfs gateway does the latter. As a result, the https fallback isn't reached.
backwards compatibility
These changes shouldn't break old users of
gx-go
-- the deps they have installed form valid go import paths, so they'll keep on working locally. When they republish though they'll be able to share newgo get
-compatible paths.cc @whyrusleeping @jbenet @Kubuxu
The text was updated successfully, but these errors were encountered: