hashicorp / go-getter

Package for downloading things from a string URL using a variety of protocols.
Mozilla Public License 2.0
1.65k stars 232 forks source link

GitHub releases and redirects #468

Open sbaildon opened 10 months ago

sbaildon commented 10 months ago

Expectation: go-getter successfully downloads and extracts .gz files from GitHub releases

$ go-getter "https://github.com/arp242/goatcounter/releases/download/v2.4.1/goatcounter-v2.4.1-linux-arm64.gz?checksum=sha256:3d5cf211df640d385c1a47e7885428d2313d772501f0e9cbea06748d3cf
c36c5" goatcounter
2023/11/14 12:17:05 Error downloading: gzip-compressed files can only unarchive to a single file

The resource isn't located on github.com, instead there's a redirect happening which we can find with wget

$ wget 'https://github.com/arp242/goatcounter/releases/download/v2.4.1/goatcounter-v2.4.1-linux-arm64.gz'
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com...

and then go-getter on the redirect

$ go-getter "https://objects.githubusercontent.com/...." goatcounter
2023/11/14 12:15:12 success!
skoenig commented 4 months ago

Same issue here with go-getter release 1.7.4:

$ go-getter https://github.com/k3d-io/k3d/releases/download/v5.6.3/k3d-linux-amd64?checksum=file:https://github.com/k3d-io/k3d/releases/download/v5.6.3/checksums.txt k3d
2024/06/01 21:26:18 Error downloading: invalid checksum: no checksum found in: https://github.com/k3d-io/k3d/releases/download/v5.6.3/checksums.txt

https://github.com/k3d-io/k3d/releases/download/v5.6.3/checksums.txt is the correct URL for the checksum file of this project, but is redirected to some other location (https://objects.githubusercontent.com/) and go-getter can't handle that. On the the other hand, actually downloading the binary is working just fine, despinte also being at a 302ed location:

$ go-getter https://github.com/k3d-io/k3d/releases/download/v5.6.3/k3d-linux-amd64 k3d
2024/06/01 21:28:59 success!