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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for +v2 modules #27

Merged
merged 1 commit into from
May 26, 2020
Merged

Add support for +v2 modules #27

merged 1 commit into from
May 26, 2020

Conversation

wallyqs
Copy link
Contributor

@wallyqs wallyqs commented May 8, 2020

This adds support to Go packages that have versions above v2. Similar to go get the /v2 major version has to be declared when making the package build request:

Usage:

# Explicit +v2 version
curl -sf 'http://localhost:3000/nats-io/nats-server@v2.1.6' | PREFIX=. sh

# Resolved version gets v2 from master
curl -sf 'http://localhost:3000/nats-io/nats-server' | PREFIX=. sh

# Explicit v1 version
curl -sf 'http://localhost:3000/nats-io/nats-server@v1.4.1' | PREFIX=. sh

# v2 nested modules too 馃帀 
curl -sf 'http://localhost:3000/caddyserver/caddy/cmd/caddy' | PREFIX=. sh

If the major version is not specified in the path, similar to go get and go modules, it will fallback to the v1 version of the package (even if the actual latest version is higher).

curl --output - 'http://127.0.0.1:3000/binary/github.com/nats-io/nats-server?os=darwin&arch=amd64&version=v2.1.6' > my-nats-v1
./my-nats-v1 
[98946] 2020/05/07 16:54:40.726190 [INF] Starting nats-server version 1.4.1

Fixes #10

Signed-off-by: Waldemar Quevedo wally@synadia.com

@wallyqs wallyqs mentioned this pull request May 8, 2020
@tj
Copy link
Owner

tj commented May 12, 2020

Feel like I'm going crazy hahah it's still not working for me:

curl -sf http://localhost:3000/nats-io/nats-server/v2 | PREFIX=. sh

  ==> Downloading github.com/nats-io/nats-server/v2@master
  ==> Resolved version master to v2.1.6
  ==> Downloading binary for darwin amd64
  ==> Installing v2 to .
  ==> Installation complete

   位 test: ./nats-server --version
nats-server version 1.4.1

maybe just an ldflags issue setting the version? I tried curl -sf http://localhost:3000/nats-io/nats-server | PREFIX=. sh as well

@wallyqs
Copy link
Contributor Author

wallyqs commented May 12, 2020

The issue is that the binary name is becoming v2... in this case...

curl -sf 'http://localhost:3000/nats-io/nats-server/v2' | PREFIX=. sh

  ==> Downloading github.com/nats-io/nats-server/v2@master
  ==> Resolved version master to v2.1.6
  ==> Downloading binary for darwin amd64
  ==> Installing v2 to .
  ==> Installation complete
./v2
[15776] 2020/05/12 14:48:56.714517 [INF] Starting nats-server version 2.1.6
[15776] 2020/05/12 14:48:56.714687 [INF] Git commit [not set]
[15776] 2020/05/12 14:48:56.715021 [INF] Listening for client connections on 0.0.0.0:4222
[15776] 2020/05/12 14:48:56.715032 [INF] Server id is NCVRTCKFBORWDJ3IWTRGRMKV3ZFANVJZH5Z5EW34EQ34HAXV7TEP2QOG
[15776] 2020/05/12 14:48:56.715038 [INF] Server is ready
^C[15776] 2020/05/12 14:48:58.492238 [INF] Initiating Shutdown...
[15776] 2020/05/12 14:48:58.492495 [INF] Server Exiting..

@wallyqs wallyqs force-pushed the go-v2 branch 2 times, most recently from e3af106 to 9613d11 Compare May 13, 2020 00:03
@wallyqs
Copy link
Contributor Author

wallyqs commented May 13, 2020

Pushed a few commits to fix the issue with the resulting binary name being v2. There are still a few corner cases but when the version is explicit like this it should work now (only on repos when main is at the root)

curl -sf 'http://localhost:3000/nats-io/nats-server@v2.1.6' | PREFIX=. sh

@wallyqs wallyqs force-pushed the go-v2 branch 4 times, most recently from 69c6139 to a1d3176 Compare May 13, 2020 18:53
@wallyqs wallyqs changed the title Add support for +v2 modules Add support for +v2 modules with main at the root May 13, 2020
@wallyqs
Copy link
Contributor Author

wallyqs commented May 13, 2020

@tj found out how to use the resolved version, so now all of these should work:

# Explicit +v2 version
curl -sf 'http://localhost:3000/nats-io/nats-server@v2.1.6' | PREFIX=. sh

# Resolved version gets v2 from master
curl -sf 'http://localhost:3000/nats-io/nats-server' | PREFIX=. sh

# Explicit v1 version
curl -sf 'http://localhost:3000/nats-io/nats-server@v1.4.1' | PREFIX=. sh

Still not working are the nested modules that have v2 since have to figure out where to insert the version between the nested module and the module name like caddyserver/caddy/${v2}/cmd@v2.0.0. For now, changed the scope of the PR to get modules that have main at the root first (non-nested).

@tj
Copy link
Owner

tj commented May 15, 2020

I imagine few people will use gobinaries unless they found the one-liner in a Readme, so maybe it's ok to assume the author should insert the /v2/? Kinda ugly, or we could maybe assume /<owner>/<repo> for the moment since it's locked into GH anyway

@wallyqs
Copy link
Contributor Author

wallyqs commented May 15, 2020

assuming first <owner>/<repo> for the moment sounds good, will make an update

@wallyqs
Copy link
Contributor Author

wallyqs commented May 15, 2020

Actually still haven't been able to figure out how to build Go mod enabled repos with v2 that use nested repositories like caddy... will continue to leave the scope of this PR to support repos that have main at the root for now....

Signed-off-by: Waldemar Quevedo <wally@synadia.com>
Signed-off-by: Waldemar Quevedo <waldemar.quevedo@gmail.com>
@wallyqs wallyqs changed the title Add support for +v2 modules with main at the root Add support for +v2 modules May 15, 2020
@wallyqs
Copy link
Contributor Author

wallyqs commented May 15, 2020

Wait I got it working! 馃帀 Ok Go v2 modules should be supported now. Happy Friday 馃槂

curl -sf 'http://localhost:3000/caddyserver/caddy/cmd/caddy' | PREFIX=. sh
./caddy version
v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=

@tj
Copy link
Owner

tj commented May 19, 2020

wahoooo 馃帀 I'll try and check it out soon!

@tj
Copy link
Owner

tj commented May 25, 2020

Forgot to try it this weekend, I'll try to get to it tonight and deploy!

@tj
Copy link
Owner

tj commented May 26, 2020

sweet looks good, I'll get it deployed. Thanks man!

We could probably refactor a bit later with https://github.com/tj/go-semver to parse the version since I already have that dep pulled in, but not a big deal either way

@tj tj merged commit 6f511f2 into tj:master May 26, 2020
@tj
Copy link
Owner

tj commented May 26, 2020

deployed!

@wallyqs wallyqs deleted the go-v2 branch May 26, 2020 16:43
@wallyqs
Copy link
Contributor Author

wallyqs commented May 26, 2020

Thanks @tj !!

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.

Support for v2+ of a package
2 participants