arkade icon indicating copy to clipboard operation
arkade copied to clipboard

Get latest HashiCorp releases

Open YuviGold opened this issue 3 years ago • 6 comments

Related to #560

Description

In case a tool has a URLTemplate including https://releases.hashicorp.com , it will fetch its latest release via the https://api.releases.hashicorp.com/v1/releases API querying for artifact with an "oss" license class.

At the moment, terraform, vagrant, vault, waypoint, and packer are being supported.

This PR follows #560 request to have minimal changes to the tools.go module.

Motivation and Context

  • [ ] I have raised an issue to propose this change, which has been given a label of design/approved by a maintainer (required)

How Has This Been Tested?

Running the unit tests and e2e, and installing manually

➜  arkade git:(get-latest-hashicorp-releases) make build
go build
➜  arkade git:(get-latest-hashicorp-releases) ./arkade get --stash=false terraform vagrant packer waypoint
Downloading: terraform
2022/05/29 17:56:19 Looking up version for terraform on HashiCorp
2022/05/29 17:56:19 Found: 1.2.1
Downloading: https://releases.hashicorp.com/terraform/1.2.1/terraform_1.2.1_linux_amd64.zip
18.96 MiB / 18.96 MiB [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00%
/tmp/terraform_1.2.1_linux_amd64.zip written.
2022/05/29 17:56:20 Looking up version for terraform on HashiCorp
2022/05/29 17:56:21 Found: 1.2.1
Name: terraform_1.2.1_linux_amd64.zip, size: 198816182022/05/29 17:56:22 Extracted: /tmp/terraform

Wrote: /tmp/terraform (62.87MB)

Downloading: vagrant
2022/05/29 17:56:22 Looking up version for vagrant on HashiCorp
2022/05/29 17:56:22 Found: 2.2.19
Downloading: https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_linux_amd64.zip
14.37 MiB / 14.37 MiB [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00%
/tmp/vagrant_2.2.19_linux_amd64.zip written.
2022/05/29 17:56:23 Looking up version for vagrant on HashiCorp
2022/05/29 17:56:23 Found: 2.2.19
Name: vagrant_2.2.19_linux_amd64.zip, size: 150642482022/05/29 17:56:23 Extracted: /tmp/vagrant

Wrote: /tmp/vagrant (15.35MB)

Downloading: packer
2022/05/29 17:56:23 Looking up version for packer on HashiCorp
2022/05/29 17:56:24 Found: 1.8.1
Downloading: https://releases.hashicorp.com/packer/1.8.1/packer_1.8.1_linux_amd64.zip
31.51 MiB / 31.51 MiB [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00%
/tmp/packer_1.8.1_linux_amd64.zip written.
2022/05/29 17:56:25 Looking up version for packer on HashiCorp
2022/05/29 17:56:25 Found: 1.8.1
Name: packer_1.8.1_linux_amd64.zip, size: 330370262022/05/29 17:56:26 Extracted: /tmp/packer

Wrote: /tmp/packer (158.4MB)

Downloading: waypoint
Downloading: https://releases.hashicorp.com/waypoint/0.6.1/waypoint_0.6.1_linux_amd64.zip
68.63 MiB / 68.63 MiB [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00%
/tmp/waypoint_0.6.1_linux_amd64.zip written.
Name: waypoint_0.6.1_linux_amd64.zip, size: 719675172022/05/29 17:56:28 Extracted: /tmp/waypoint

Wrote: /tmp/waypoint (134.7MB)

Run the following to copy to install the tool:

chmod +x /tmp/terraform /tmp/vagrant /tmp/packer /tmp/waypoint 
sudo install -m 755 /tmp/terraform /usr/local/bin/terraform
sudo install -m 755 /tmp/vagrant /usr/local/bin/vagrant
sudo install -m 755 /tmp/packer /usr/local/bin/packer
sudo install -m 755 /tmp/waypoint /usr/local/bin/waypoint

🐳 arkade needs your support, learn more: https://my.arkade.dev

Are you a GitHub Sponsor yet (Yes/No?)

  • [ ] Yes
  • [x] No

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Documentation

  • [ ] I have updated the list of tools in README.md if (required) with ./arkade get -o markdown
  • [ ] I have updated the list of apps in README.md if (required) with ./arkade install --help

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I've read the CONTRIBUTION guide
  • [x] I have signed-off my commits with git commit -s
  • [ ] I have added tests to cover my changes.
  • [x] All new and existing tests passed.
  • [ ] I have tested this on arm, or have added code to prevent deployment

YuviGold avatar May 29 '22 14:05 YuviGold

This PR resolves https://github.com/alexellis/arkade/pull/687 and future bumps of Hashicorp tools (except for Waypoint that isn't yet available on https://checkpoint-api.hashicorp.com/ )

YuviGold avatar Jun 01 '22 20:06 YuviGold

fyi: there is a new releases api available: https://api.releases.hashicorp.com/

jsiebens avatar Sep 08 '22 12:09 jsiebens

fyi: there is a new releases api available: https://api.releases.hashicorp.com/

@jsiebens Thanks! I updated the PR. Now with support for vault and waypoint as well! :)

usage example

regular (hardcoded version 2.2.19):

➜  arkade git:(get-latest-hashicorp-releases) ✗ arkade get --stash=false vagrant    
Downloading: vagrant
Downloading: https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_linux_amd64.zip
14.37 MiB / 14.37 MiB [--------------------------------------------------------------------------------------------------------] 100.00%
/tmp/vagrant_2.2.19_linux_amd64.zip written.
Name: vagrant_2.2.19_linux_amd64.zip, size: 150642482022/09/11 15:50:42 Extracted: /tmp/vagrant
...

new code (takes latest release 2.3.0):

➜  arkade git:(get-latest-hashicorp-releases) ✗ ./bin/arkade get --stash=false vagrant  
Downloading: vagrant
2022/09/11 15:50:30 Looking up version for vagrant on HashiCorp
2022/09/11 15:50:31 Found: 2.3.0
Downloading: https://releases.hashicorp.com/vagrant/2.3.0/vagrant_2.3.0_linux_amd64.zip
36.29 MiB / 36.29 MiB [--------------------------------------------------------------------------------------------------------] 100.00%
/tmp/vagrant_2.3.0_linux_amd64.zip written.
2022/09/11 15:50:38 Looking up version for vagrant on HashiCorp
2022/09/11 15:50:38 Found: 2.3.0
Name: vagrant_2.3.0_linux_amd64.zip, size: 380500642022/09/11 15:50:38 Extracted: /tmp/vagrant
...

YuviGold avatar Sep 11 '22 12:09 YuviGold

WDYT? @alexellis @Shikachuu

Currently, all of arkade's HashiCorp tools are outdated.

➜  ~ tools=(terraform vagrant vault waypoint packer); for tool in ${tools[@]}; do echo "${tool} - current_arkade: $(arkade get --stash=false "${tool}" 2&>1 | grep "/${tool}_" | cut -d_ -f2 | sort -u) new_arkade: $(./bin/arkade get --stash=false "${tool}" 2&>1 | grep "/${tool}_" | cut -d_ -f2 | sort -u) latest: $(curl -s "https://api.releases.hashicorp.com/v1/releases/${tool}?license_class=oss" | jq -r '.[0].version')"; done

terraform - current_arkade: 1.1.9 new_arkade: 1.3.0 latest: 1.3.0
vagrant - current_arkade: 2.2.19 new_arkade: 2.3.0 latest: 2.3.0
vault - current_arkade: 1.11.2 new_arkade: 1.11.3 latest: 1.11.3
waypoint - current_arkade: 0.8.1 new_arkade: 0.10.0 latest: 0.10.0
packer - current_arkade: 1.8.0 new_arkade: 1.8.3 latest: 1.8.3

YuviGold avatar Sep 21 '22 14:09 YuviGold

I would like to have this one. It will be useful to have the newer versions available via arkade. For now I have an error for packer, terraform and probably other Hashicorp tools too :(

arkade get packer
Downloading: packer
Downloading: https://releases.hashicorp.com/packer/1.8.0/packer_1.8.0_darwin_.zip
Error: incorrect status for downloading tool: 404

FYI @alexellis

Jasstkn avatar Feb 02 '23 14:02 Jasstkn

#767 also need consul but they are not using github releases :(, they are using hashicorp releases, maybe it is better to use hashicorp releases domain for every one of their products rather than any github releases? I didn't know they were shifting towards their domain releases, would be good to get info from hashicorp about this

mrwormhole avatar Apr 15 '23 11:04 mrwormhole