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

Add goversion, goos, and goarch to version command #407

Merged
merged 3 commits into from
Mar 5, 2021

Conversation

cappyzawa
Copy link
Contributor

@cappyzawa cappyzawa commented Feb 16, 2021

fix: #127

# dev version
$ terraform-ls version
0.0.0-dev
$ terraform-ls version -json
{
  "version": "0.0.0-dev"
}

# release version
$ ./dist/terraform-ls_darwin_amd64/terraform-ls version
0.13.0-snapshot.6b81b78
go1.15.2 darwin/amd64

$ ./dist/terraform-ls_darwin_amd64/terraform-ls version -json
{
  "version": "0.13.0-snapshot.6b81b78",
  "go_version": "1.15.2",
  "go_os": "darwin",
  "go_arch": "amd64"
}

@hashicorp-cla
Copy link

hashicorp-cla commented Feb 16, 2021

CLA assistant check
All committers have signed the CLA.

@cappyzawa
Copy link
Contributor Author

CI will pass if #406 is merged 😄

@radeksimko
Copy link
Member

radeksimko commented Feb 16, 2021

Thank you for the PR @cappyzawa

Before we can merge this however we will need to take at least two more steps:

  • Add these new fields to the version -json output
  • Ensure that VS Code extension, which uses -version output is switched to version -json and therefore this change doesn't break it. Relatedly we'd also need to wait until a release of that extension is cut and distributed for at least a week or so. Otherwise we'd just release "incompatible" terraform-ls which the extension can't read version of and installations would be failing.

@cappyzawa
Copy link
Contributor Author

cappyzawa commented Feb 16, 2021

@radeksimko Thank you for checking.

Should I add fields to the version -json output in this PR?

If you can tell me the ideal output of the following two commands, I can implement them 👍

  • terraform-ls version
  • terraform-ls version --json

Currently, those commands are output as follows.

$ terraform-ls version
0.13.0-snapshot.6b81b78
go1.15.2 darwin/amd64

$ terraform-ls version --json
{
  "version": "0.13.0-snapshot.6b81b78\ngo1.15.2 darwin/amd64"
}

@cappyzawa
Copy link
Contributor Author

cappyzawa commented Feb 16, 2021

The previous code did not support the json flag, so I fixed it (c09af64).

Currently, those commands are output as follows.

# dev version
$ terraform-ls version
0.0.0-dev
platform: darwin/amd64
go: go1.15.2
compiler: gc
$ terraform-ls version --json
{
  "version": "0.0.0-dev",
  "go": "go1.15.2",
  "os": "darwin",
  "arch": "amd64",
  "compiler": "gc"
}

# release version
$ ./dist/terraform-ls_darwin_amd64/terraform-ls version
0.13.0-snapshot.c09af64
platform: darwin/amd64
go: go1.15.2
compiler: gc

$ ./dist/terraform-ls_darwin_amd64/terraform-ls version -json
{
  "version": "0.13.0-snapshot.c09af64",
  "go": "go1.15.2",
  "os": "darwin",
  "arch": "amd64",
  "compiler": "gc"
}

The field name in the json is tentative, so I will fix it if you point it out.

@cappyzawa cappyzawa changed the title Add goversion, goos and goarch for build Add goversion, goos, and goarch to version command at build time Feb 16, 2021
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thank you for the update as well, I left you some comments in-line with regards to the format and some other things.

Once these are addressed, I reckon it will be in a mergeable state, but we would still need to update the VS Code extension logic prior to shipping this PR - I can send a PR with a patch there.

.goreleaser.yml Outdated Show resolved Hide resolved
internal/cmd/version_command.go Outdated Show resolved Hide resolved
internal/cmd/version_command.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@radeksimko
Copy link
Member

@cappyzawa FYI: I just opened hashicorp/vscode-terraform#560 to address the extension compatibility problem.

@cappyzawa cappyzawa changed the title Add goversion, goos, and goarch to version command at build time Add goversion, goos, and goarch to version command Feb 16, 2021
@cappyzawa
Copy link
Contributor Author

@radeksimko Thanks for your kind suggestion 👍

I fixed.

Outputs of the version command are described in this PR summary.

@radeksimko
Copy link
Member

We're going to cut and distribute a release of the extension (with the mentioned patch) possibly within the next week, so I'm going to put this PR on hold until then, but you can rebase it in the meantime if you like. All tests should now pass as I merged #406

@radeksimko
Copy link
Member

Just FYI hashicorp/vscode-terraform#560 was released yesterday (on Monday), so I would let that release be distributed to users over the week and consider merging this some time next week, to reduce the risk of breaking someone's installation.

@radeksimko radeksimko merged commit 32aef11 into hashicorp:main Mar 5, 2021
@radeksimko radeksimko added the ci Continuous integration/delivery related label Mar 5, 2021
@cappyzawa cappyzawa deleted the issues/127 branch March 5, 2021 15:43
@ghost
Copy link

ghost commented Apr 4, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ci Continuous integration/delivery related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add build environment details to version output
3 participants