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

Bugix/add latest terraform binary #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

philroche
Copy link
Member

fix: Download and install terraform from the hasicorp.com release page instead of using go install

Any version of terraform after version 1.9 will no longer install using
go install due to error:

➜  ~ go install github.com/hashicorp/terraform@latest
go: github.com/hashicorp/terraform@v1.9.2 requires go >= 1.22.4; switching to go1.22.5
go: github.com/hashicorp/terraform@latest (in github.com/hashicorp/terraform@v1.9.2):
        The go.mod file for the module providing named packages contains one or
        more replace directives. It must not contain directives that would cause
        it to be interpreted differently than if it were the main module.

Instead we can install directly from the hashicorp releases page.

The release page provides no current or latest symlink so the best proxy I found was
to use the latest tag in their github releases and download that version from their
release page. This is a zip archive of the terraform binary so we need to download unzip and
ensure the permissions are correct.

The unzip command was used for this so it too has been added as a depenendency.
For completeness it was added to Wolfi and MacOS but it is only used for Linux installs.

The resulting terraform binary is saved in ~/bin/ just like chainctl

grep for the path we wish to be present in $PATH before adding it.

Signed-off-by: philroche <phil.roche@chainguard.dev>
$HOME/bin is used for some of the tools installed. We need to ensure it
is present in $PATH

Signed-off-by: philroche <phil.roche@chainguard.dev>
It is used by a few of the helper functions but as it is not always
installed on a base system we need to add it explicitly

Signed-off-by: philroche <phil.roche@chainguard.dev>
…e instead of using `go install`

Any version of `terraform` after version 1.9 will no longer install using
`go install` due to error:

```
➜  ~ go install github.com/hashicorp/terraform@latest
go: github.com/hashicorp/terraform@v1.9.2 requires go >= 1.22.4; switching to go1.22.5
go: github.com/hashicorp/terraform@latest (in github.com/hashicorp/terraform@v1.9.2):
        The go.mod file for the module providing named packages contains one or
        more replace directives. It must not contain directives that would cause
        it to be interpreted differently than if it were the main module.
```

Instead we can install directly from the hashicorp releases page.

The release page provides no `current` or `latest` symlink so the best proxy I found was
to use the latest tag in their github releases and download that version from their
release page. This is a zip archive of the `terraform` binary so we need to download unzip and
ensure the permissions are correct.

The `unzip` command was used for this so it too has been added as a depenendency.
For completeness it was added to Wolfi and MacOS but it is only used for Linux installs.

The resulting `terraform` binary is saved in `~/bin/` just like `chainctl`

Signed-off-by: philroche <phil.roche@chainguard.dev>
@philroche philroche force-pushed the bugix/add-latest-terraform-binary branch from 858cf8b to 9103072 Compare July 24, 2024 09:15
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.

1 participant