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

internal: expose tf related options via init opts #588

Merged
merged 5 commits into from
Aug 12, 2021

Conversation

danishprakash
Copy link
Contributor

Closes #240

@hashicorp-cla
Copy link

hashicorp-cla commented Jul 21, 2021

CLA assistant check
All committers have signed the CLA.

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.

Looks like the tests are failing - can you take a look at the results and make these pass again?

You can also run tests locally via go test ./....

Thanks.

@danishprakash
Copy link
Contributor Author

Sure. It looks like new contributors can't rerun tests on subsequent pushes, can you help out here? Thanks

Copy link
Contributor Author

@danishprakash danishprakash left a comment

Choose a reason for hiding this comment

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

@radeksimko does it make sense to abstract out this validation for paths to a separate package? something like fileutil or maybe rename the existing pathcmp package to path and have such utilities moved there?

@radeksimko radeksimko self-requested a review July 26, 2021 17:23
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.

This looks decent, thank you for the PR. Aside from my inline comments:

Do you mind also adding a note to the CLI option, so that users are aware that we are deprecating it in favour of terraformExecPath LSP config option?

I would add a brief note to the flag help itself here

fs.StringVar(&c.tfExecPath, "tf-exec", "", "path to Terraform binary")

and then also log a warning (just a message prepended with [WARN]) after here
logger.Printf("Terraform exec path set to %q", path)


Down the line, after this is released and clients had some chance to reflect this we can also start sending a warning message but I wouldn't do that yet. I'd just create a separate issue to revisit later.

internal/settings/settings.go Outdated Show resolved Hide resolved
internal/settings/settings.go Outdated Show resolved Hide resolved
internal/settings/settings.go Outdated Show resolved Hide resolved
internal/settings/settings.go Outdated Show resolved Hide resolved
* add note for users about deprecation of cli options
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.

LGTM. I will remove that redundant error check as mentioned in-line and make some minor adjustments of the comment phrasing before merging - I hope you don't mind.

internal/langserver/handlers/initialize.go Outdated Show resolved Hide resolved
internal/langserver/handlers/service.go Outdated Show resolved Hide resolved
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.

Actually on a second look I'm afraid this won't work because all the methods (formatting, didSave, executeCommand) which are supposed to consume the LSP-configured exec path receive execOpts in their own context, but the initialize handler never writes into it. Instead they will just all always fall back to auto-discovered Terraform exec path - that is not desirable.

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.

I'm afraid this is going to be much more involved than expected - we need the exec path pretty early in the lifecycle for walker and module manager, which are both currently created before the initialize handler is ever executed.

I will take this over.

This is to allow "later" configuration of walker, watcher, module manager
and other things which depend on InitializationOptions we receive
as part of the initialize request.
@radeksimko radeksimko added the enhancement New feature or request label Aug 12, 2021
@radeksimko
Copy link
Member

Thanks for the PR 👍🏻 I wish I realized the complexity earlier, I did some refactoring to address the mentioned problem and also added some docs, so this is now ready to be merged.

@danishprakash
Copy link
Contributor Author

Thanks for reviewing this PR, will go through the refactoring that you've done before making other changes.

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose Terraform-related options via native LSP "InitializationOptions"
3 participants