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

Get latest HashiCorp releases #696

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YuviGold
Copy link
Contributor

@YuviGold YuviGold commented May 29, 2022

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
  • No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • 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:

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

@YuviGold
Copy link
Contributor Author

YuviGold commented Jun 1, 2022

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

log.Printf("Found: %s", v)
}
version = v
} else if strings.Contains(tool.URLTemplate, "https://releases.hashicorp.com") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could work, but I wonder if there's a cleaner way to express it? For instance, when we also may want to download the latest version of kubectl, which has a text file showing the latest version in text?

Copy link
Contributor Author

@YuviGold YuviGold Aug 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @alexellis , I raised several implementation suggestions on #560 but I didn't get a response regarding an overall solution. Please let me know if you'd like me to resolve that.
Instead, on this PR I'm only suggesting to resolve HashiCorp versions that has a unique pattern which doesn't require refactoring.

@YuviGold YuviGold force-pushed the get-latest-hashicorp-releases branch from d49a095 to 0104fa3 Compare August 15, 2022 09:18
@jsiebens
Copy link
Contributor

jsiebens commented Sep 8, 2022

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

@YuviGold
Copy link
Contributor Author

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
...

Related to alexellis#560

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.

Signed-off-by: Yuval Goldberg <yuvigoldi@gmail.com>
@YuviGold
Copy link
Contributor Author

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

@Jasstkn
Copy link
Contributor

Jasstkn commented Feb 2, 2023

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

@mrwormhole
Copy link
Contributor

mrwormhole commented Apr 15, 2023

#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

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.

None yet

5 participants