1Password / terraform-provider-onepassword

Use the 1Password Terraform Provider to reference, create, or update items in your 1Password Vaults.
https://developer.1password.com/docs/terraform/
MIT License
324 stars 48 forks source link

Add support to run provider with debuggers #103

Closed williamhpark closed 11 months ago

williamhpark commented 1 year ago

Overview

This PR adds support for debugging tools like Delve and Goland, which should improve the debugging experience for developers contributing to the provider.

Type of change

Enhancement

Related Issue(s)

How To Test

  1. Pull the branch locally: git pull && git checkout wpark/102-debugging-support
  2. Configure a provider override in your ~/.terraformrc file, so that you use a local build of the provider rather than the published version. Refer to the documentation here for more details: https://developer.hashicorp.com/terraform/cli/config/config-file#development-overrides-for-provider-developers. Your .terraformrc file should look like this:
provider_installation {

  dev_overrides {
      "1Password/onepassword" = "<path to terraform-provider-onepassword repo root directory>"
  }

  # For all other providers, install them directly from their origin provider
  # registries as normal. If you omit this, Terraform will _only_ use
  # the dev_overrides block, and so no other providers will be available.
  direct {}
}
  1. Install Delve on your system: https://github.com/go-delve/delve/tree/master/Documentation/installation
  2. With either Delve or another debugging tool (e.g Goland), run a debugging session. Follow the instructions here, referring to the Compiling in debug mode section onward
  3. Navigate to the examples directory in your terminal. Set the TF_REATTACH_PROVIDERS variable: export TF_REATTACH_PROVIDERS=<outputted value from debugging session>
  4. Set breakpoints in your code
  5. Test creating and destroying item resources. Follow the instructions here