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

feat: Adding support for debugger-based debugging. #1145

Merged
merged 3 commits into from
Jul 28, 2022

Conversation

sandor-juhasz
Copy link
Contributor

Fix for #1144

Adding the -debug flag to enable starting the provider in debug mode according to https://www.terraform.io/plugin/debugging#debugger-based-debugging

Specifying the ProviderAddr was required to let the provider print the proper command to set the TF_REATTACH_PROVIDERS environment variable once theprovider is started in debug mode. If not specified, the output will default to provider which will print a wrong command to the user. With this wrong command the debug session will not be established between the provider and the Terraform applicaiton.

Test Plan

  • Existing unit tests have been run.
  • Manual testing has been performed with the following steps on Windows with VS Code
  1. Launch the Snowflake Provider in VS Code debugger with the -debug argument. The process prints the following
Provider started. To attach Terraform CLI, set the TF_REATTACH_PROVIDERS environment variable with the following:

Command Prompt:	set "TF_REATTACH_PROVIDERS={"registry.terraform.io/Snowflake-Labs/snowflake":{"Protocol":"grpc","ProtocolVersion":5,"Pid":35140,"Test":true,"Addr":{"Network":"tcp","String":"127.0.0.1:54706"}}}"
PowerShell:	$env:TF_REATTACH_PROVIDERS='{"registry.terraform.io/Snowflake-Labs/snowflake":{"Protocol":"grpc","ProtocolVersion":5,"Pid":35140,"Test":true,"Addr":{"Network":"tcp","String":"127.0.0.1:54706"}}}'
  1. In another command line window, execute the SET command printed in the previous step.
  2. Execute any Terraform template exercising the Snowflake Terraform provider.
  3. Verify that Terraform connects to the debug session by checking the outputted messages in the Debug Console in VS Code.
  4. Place breakpoints in the code and check if the execution stops when execution reaches the breakpoint.

@sandor-juhasz sandor-juhasz changed the title feat: Adding support for debugger-based debugging. #1144 feat: Adding support for debugger-based debugging. Jul 19, 2022
@sfc-gh-jalin
Copy link
Contributor

/ok-to-test sha=091936c

@github-actions
Copy link

Integration tests success for 091936c

@sfc-gh-jalin sfc-gh-jalin self-requested a review July 19, 2022 18:54
@sfc-gh-jalin
Copy link
Contributor

sfc-gh-jalin commented Jul 19, 2022

Hi @sandor-juhasz this PR looks good to me but before merging, do you think it would be beneficial to mention/add some details about about running the debugger to the readme ? That way other people will be aware of this new feature and be able to use it

@sandor-juhasz
Copy link
Contributor Author

Hi @sfc-gh-jalin, that's good idea, I have added a couple of lines to the README.md and pushed it into my feature branch. Shall I squash it or clean up the branch in any other way? This is my first contribution and I'm still trying to get the hang of it.

@sfc-gh-jalin
Copy link
Contributor

/ok-to-test sha=63fe852

@github-actions
Copy link

Integration tests success for 63fe852

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.

2 participants