Skip to content

Latest commit

 

History

History
138 lines (84 loc) · 4.52 KB

CONTRIBUTING.md

File metadata and controls

138 lines (84 loc) · 4.52 KB

Contributing

Thanks for your interest in contributing to the 1Password Terraform provider project! 🙌 We appreciate your time and effort. Here are some guidelines to help you get started.

Building

Run the following command to build the 1Password Terraform provider:

go build .

This will create the terraform-provider-onepassword binary.

Testing the Provider

To run the Go tests and check test coverage run the following command:

go test -v ./... -cover

Installing the provider locally

Refer to the following sections of the Terraform's "Custom Framework Providers" tutorial to install this provider locally:

Using the provider locally

You must specify the onepassword provider in your Terraform configuration:

terraform {
  required_providers {
    onepassword = {
      source  = "1Password/onepassword"
      version = "~> 2.0.0"
    }
  }
}

provider "onepassword" {
  service_account_token = "<1Password service account token>"
}

After copying a newly built version of the provider to the plugins directory, you need to run terraform init again. Otherwise, Terraform returns an error.

Debugging

To start debugging:

  1. Start a debugging session.
  2. Export TF_REATTACH_PROVIDERS.
  3. Run Terraform normally.

Start a debugging session

You can start a debugging session in several ways:

  1. Build the provider without optimizations.
  2. Start a debugging session.

Note: Before continuing, make sure you add the dev_overrides block to your ~/.terraformrc file (using "1Password/onepassword" as the source). For instructions, refer to the Installing the provider locally.

Build the provider without optimizations

Run the following command to build the provider without enabling optimizations:

go build -gcflags="all=-N -l" .

Start a debugging session

Run the following command to start a Delve debugging session:

dlv debug . -- --debug

Or use your IDE debugger. You can configure editors like GoLand to start a debugging session by passing the --debug flag as a program argument.

Export TF_REATTACH_PROVIDERS

If a debugging session was starts correctly, the provider prints the following output to stdout:

Provider started, to attach Terraform set the TF_REATTACH_PROVIDERS env var:

    TF_REATTACH_PROVIDERS='{"1Password/onepassword":{"Protocol":"grpc","Pid":3382870,"Test":true,"Addr":{"Network":"unix","String":"/tmp/plugin713096927"}}}'

Copy the line starting with TF_REATTACH_PROVIDERS from your provider's output. You can either export this variable or prefix every Terraform command with it.

Run Terraform

After starting a debugging session and exporting the TF_REATTACH_PROVIDERS variable, run Terraform as usual. Any breakpoints you have set will halt execution and show you the current variable values.

Generating documentation

Documentation is generated for the provider using terraform-plugin-docs. This plugin uses the schema Description field in conjunction with the contents of the /templates and /examples folders to generate the /docs content.

To regenerate the /docs Markdown run:

go generate

Sign your commits

To get your PR merged, we require you to sign your commits.

Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing

Sign commits gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing