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

Fix item creation with sections #100

Merged
merged 4 commits into from
Oct 17, 2023
Merged

Fix item creation with sections #100

merged 4 commits into from
Oct 17, 2023

Conversation

williamhpark
Copy link
Contributor

@williamhpark williamhpark commented Oct 17, 2023

Overview

Currently, creating items with sections through the Terraform provider does not work.

It seems like the Purpose field for item section fields is being assigned improperly. If a type is specified when creating a resource, this type value is being assigned to the section field's Purpose. This causes an error, since the expected values for Type and Purpose differ. For more details on the expected values for each, refer to the documentation here: https://developer.1password.com/docs/connect/connect-api-reference/#item-field-object.

I also made a small change to the logic for generating a section ID, to make it cleaner.

Type of change

Bug fix

Related Issue(s)

How To Test

  1. Pull the branch locally: git pull && git checkout wpark/96-fix-sections
  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. Navigate to the root of the terraform-provider-onepassword repo and generate a local build: go build
  2. Create an item resource with sections using terraform apply. Follow the instructions here - the example main.tf contains a demo_sections resource that you can use to test this
  • In the vault that your connect server has access rights to, the item should have been successfully created with sections, and the item should match the resource outlined in main.tf. If you used the example provided in the repo, the item should look like this:
image
  1. Check the generated item within Terraform state by running terraform state show, e.g. terraform state show onepassword_item.demo_sections
  • The outputted resource should match the resource outlined in main.tf, and the id for all sections and fields should be populated

@williamhpark williamhpark self-assigned this Oct 17, 2023
@williamhpark williamhpark changed the title Fix item creation with sections Fix item creation with sections, and improve section/field ID logic Oct 17, 2023
@williamhpark williamhpark changed the title Fix item creation with sections, and improve section/field ID logic Fix item creation with sections Oct 17, 2023
@volodymyrZotov
Copy link
Collaborator

✅ The code looks good! Tested and it works as expected!

@volodymyrZotov volodymyrZotov merged commit 2c7bb58 into main Oct 17, 2023
4 checks passed
@volodymyrZotov volodymyrZotov deleted the wpark/96-fix-sections branch October 17, 2023 22:40
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.

1.2.0 use of sections does not work
2 participants