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

Lookup terraform binary in system path before attempting to install it #77

Closed

Conversation

syndicut
Copy link

When using terraform-plugin-docs in ci process it is slow and sometimes impossible to download terraform binary every time.
So I propose to first lookup terraform binary in system path and use it and fallback to downloading it.

@hashicorp-cla
Copy link

hashicorp-cla commented Aug 11, 2021

CLA assistant check
All committers have signed the CLA.

@syndicut
Copy link
Author

@paultyng Can you have a look at this?

@paultyng
Copy link
Contributor

@syndicut I no longer work at HashiCorp

@syndicut
Copy link
Author

syndicut commented Aug 25, 2021

@syndicut I no longer work at HashiCorp

ok, sorry for bothering
can you suggest any maintainer/co-maintainer at HashiCorp?

@OJFord
Copy link
Contributor

OJFord commented Nov 12, 2021

@bflad
Copy link
Member

bflad commented Mar 14, 2022

Hi @syndicut 👋 Thank you for raising this and apologies for the delayed review. Using an existing Terraform CLI binary is certainly a welcome enhancement.

We recently needed to switch from the removed github.com/hashicorp/terraform-exec/tfinstall to github.com/hashicorp/hc-install. To that end, could you rebase and update this pull request (or create a new one) that uses hc-install instead? When adding the local installer, we should also update the code to fallback to installing the latest Terraform CLI version, rather than remaining hardcoded to 1.0.5.

Something like this should do the trick:

sources := []src.Source{
	&fs.AnyVersion{
		Product: &product.Terraform,
	},
	&checkpoint.LatestVersion{
		InstallDir: tmpDir,
		Product:    product.Terraform,
	},
}

installer := install.NewInstaller()
tfBin, err := installer.Ensure(context.Background(), sources)

if err != nil {
	return nil, err
}

Please reach out if you have any questions.

@bflad bflad self-assigned this Mar 14, 2022
@bflad bflad added the enhancement New feature or request label Mar 14, 2022
@bflad bflad added this to the v0.7.0 milestone Mar 14, 2022
@bflad
Copy link
Member

bflad commented Mar 15, 2022

Closing, with permission, in preference of #124 👍

@bflad bflad closed this Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants