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

Support 'offline mode': do not download terraform binary #124

Merged
merged 5 commits into from Mar 15, 2022

Conversation

GennadySpb
Copy link
Contributor

@GennadySpb GennadySpb commented Mar 14, 2022

Signed-off-by: Gennady Lipenkov xgen@yandex-team.ru

…from PATH

Signed-off-by: Gennady Lipenkov <xgen@yandex-team.ru>
@GennadySpb GennadySpb requested a review from a team as a code owner Mar 14, 2022
@GennadySpb
Copy link
Contributor Author

GennadySpb commented Mar 14, 2022

@bflad Please check this PR)

Copy link
Member

@bflad bflad left a comment

Hi @GennadySpb 👋 Thank you for submitting this. As discussed in #77 (which I think we should give @syndicut an opportunity to adjust/submit first), I think an ideal implementation here would be to unilaterally check for a Terraform binary first, then fall back to downloading the latest version. If folks desire a way to use an exact binary, we can provide a separate flag or environment variable.

src = append(src, &releases.ExactVersion{
Product: product.Terraform,
Version: version.Must(version.NewVersion(defaultTerraformVersion)),
InstallDir: tmpDir,
})
Copy link
Member

@bflad bflad Mar 14, 2022

Choose a reason for hiding this comment

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

Recommend switching this to checkpoint.LatestVersion, instead of keeping the hardcoded Terraform version.

@bflad bflad self-assigned this Mar 15, 2022
…wnloading the latest version; also support set exact version to download.

Signed-off-by: Gennady Lipenkov <xgen@yandex-team.ru>
@GennadySpb
Copy link
Contributor Author

GennadySpb commented Mar 15, 2022

Hi @GennadySpb 👋 Thank you for submitting this. As discussed in #77 (which I think we should give @syndicut an opportunity to adjust/submit first), I think an ideal implementation here would be to unilaterally check for a Terraform binary first, then fall back to downloading the latest version. If folks desire a way to use an exact binary, we can provide a separate flag or environment variable.

So, make refactor to implement described behavior. Also support set exact Terraform version by arg -tf-version to download.

@bflad
Copy link
Member

bflad commented Mar 15, 2022

Thanks for the update, @GennadySpb 👍 We'll see if @syndicut responds in the next week or so and if not, we can move forward with something like this.

Copy link
Member

@bflad bflad left a comment

Some minor things, otherwise looking good to me.

internal/provider/generate.go Outdated Show resolved Hide resolved
internal/provider/generate.go Outdated Show resolved Hide resolved
internal/provider/generate.go Outdated Show resolved Hide resolved
@syndicut
Copy link

syndicut commented Mar 15, 2022

Thanks for the update, @GennadySpb 👍 We'll see if @syndicut responds in the next week or so and if not, we can move forward with something like this.

I don't mind merging @GennadySpb's PR instead of mine

GennadySpb and others added 3 commits Mar 15, 2022
Co-authored-by: Brian Flad <bflad417@gmail.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
@GennadySpb
Copy link
Contributor Author

GennadySpb commented Mar 15, 2022

@bflad accept all your changes ;)

@bflad bflad added this to the v0.7.0 milestone Mar 15, 2022
@bflad bflad added the enhancement New feature or request label Mar 15, 2022
bflad
bflad approved these changes Mar 15, 2022
Copy link
Member

@bflad bflad left a comment

Looks good to me, thank you @GennadySpb 🚀 Verified using terraform-provider-scaffolding:

$ go mod edit -replace=github.com/hashicorp/terraform-plugin-docs=/Users/bflad/src/github.com/hashicorp/terraform-plugin-docs
$ go mod tidy
$ go generate ./...
rendering website for provider "terraform-provider-scaffolding"
exporting schema from Terraform
compiling provider "scaffolding"
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
getting provider schema
rendering missing docs
generating missing resource content
generating template for "scaffolding_resource"
generating missing data source content
generating template for "scaffolding_data_source"
generating missing provider content
generating template for "terraform-provider-scaffolding"
rendering static website
cleaning rendered website dir
rendering templated website to static markdown
rendering "data-sources/data_source.md.tmpl"
rendering "index.md.tmpl"
rendering "resources/resource.md.tmpl"

So nice saving the download time each execution. 😄

@bflad bflad linked an issue Mar 15, 2022 that may be closed by this pull request
@bflad bflad merged commit 3232a22 into hashicorp:main Mar 15, 2022
1 check passed
@GennadySpb GennadySpb deleted the offline-mode branch Mar 15, 2022
@GennadySpb
Copy link
Contributor Author

GennadySpb commented Mar 15, 2022

@bflad what about tests? I see some failed.

@GennadySpb
Copy link
Contributor Author

GennadySpb commented Mar 15, 2022

@bflad what about tests? I see some failed.

Check PR - contains fix :)

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.

3 participants