-
Notifications
You must be signed in to change notification settings - Fork 42
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
Migration to Terraform provider framework #167
Commits on May 2, 2024
-
Update all Go packages to the latest version
Run the following commands: - `go get -u ./...` - `go mod tidy` - `go mod vendor` With this, we also update Go version to 1.21.
Configuration menu - View commit details
-
Copy full SHA for 69982a8 - Browse repository at this point
Copy the full SHA 69982a8View commit details -
Add provider framework dependencies and update packages
- Move `github.com/hashicorp/terraform-plugin-framework` package from indirect dependency to direct dependency - `go get -u ./...` - `go mod tidy` - `go mod vendor`
Configuration menu - View commit details
-
Copy full SHA for a5f346c - Browse repository at this point
Copy the full SHA a5f346cView commit details -
Configuration menu - View commit details
-
Copy full SHA for fae4cfb - Browse repository at this point
Copy the full SHA fae4cfbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 16353d9 - Browse repository at this point
Copy the full SHA 16353d9View commit details -
Remove provider function scaffolding
Currently, the provider doesn't implement any functions. Therefore, these files are removed.
Configuration menu - View commit details
-
Copy full SHA for beedbb2 - Browse repository at this point
Copy the full SHA beedbb2View commit details -
Implement 1Password Client interface
This client will be used by the provider to create, read, update and delete items using either Connect or 1Password CLI. This client is also capable of fetching vault data.
Configuration menu - View commit details
-
Copy full SHA for 614906e - Browse repository at this point
Copy the full SHA 614906eView commit details -
Changes made compared to `onepassword/connectctx/wrapper.go` - NewClient function is now responsible of creating the Connect client with user agent. - Renaming the struct for clarity and cleanliness.
Configuration menu - View commit details
-
Copy full SHA for 1ffaa67 - Browse repository at this point
Copy the full SHA 1ffaa67View commit details -
Changes made compared to the code in `internal/onepassword/cli` directory: - New function is renamed to NewClient and implements the initializeCLI function - Enable password generation when updating an item (to be consistent with the Connect client).
Configuration menu - View commit details
-
Copy full SHA for b1d648f - Browse repository at this point
Copy the full SHA b1d648fView commit details -
Implement new 1Password client function
This function will return either the Connect or the CLI client.
Configuration menu - View commit details
-
Copy full SHA for 96117be - Browse repository at this point
Copy the full SHA 96117beView commit details -
- Name the struct as OnePasswordProvider - Implement provider schema - Implement provider data model What changed from the previous implementation is that we marked the service account token and connect token as sensitive.
Configuration menu - View commit details
-
Copy full SHA for c813650 - Browse repository at this point
Copy the full SHA c813650View commit details -
Add provider configuration functionality
- Load default values from environment variables - Initialize the 1Password client (either Connect or CLI client based on the configuration)
Configuration menu - View commit details
-
Copy full SHA for 750ee46 - Browse repository at this point
Copy the full SHA 750ee46View commit details -
Configuration menu - View commit details
-
Copy full SHA for 54b104c - Browse repository at this point
Copy the full SHA 54b104cView commit details -
Add framework validator package
This is used to add validators to schemas (e.g. dependencies between attributes). Some of these will be used by the vault data source.
Configuration menu - View commit details
-
Copy full SHA for c912599 - Browse repository at this point
Copy the full SHA c912599View commit details -
Define vault data source schema and model
With the vault data source fully implemented, we add it to the list of data sources the provider supports.
Configuration menu - View commit details
-
Copy full SHA for 47ede0a - Browse repository at this point
Copy the full SHA 47ede0aView commit details -
Add constants for attribute descriptions
Changes made here as part of the migration: - Add a new constant `terraformItemIDDescription` which will be used for both item resource and data source for consistency. - The slices of categories, field purposes, and field types are now based on the constants available in the Connect Go SDK to eliminate hardcoding the string values (these apply to both Connect and CLI clients).
Configuration menu - View commit details
-
Copy full SHA for a96b298 - Browse repository at this point
Copy the full SHA a96b298View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7648c0b - Browse repository at this point
Copy the full SHA 7648c0bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 865371c - Browse repository at this point
Copy the full SHA 865371cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d1f3c9 - Browse repository at this point
Copy the full SHA 7d1f3c9View commit details -
Add additional packages in vendor
These new ones are used by the item resource schema.
Configuration menu - View commit details
-
Copy full SHA for 967dc53 - Browse repository at this point
Copy the full SHA 967dc53View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6fbe23b - Browse repository at this point
Copy the full SHA 6fbe23bView commit details -
Implement custom value modifier
With the new framework, Terraform wants to be more predictable, therefore any computed values will be recomputed whenever something in the resource changes. What this modifier does is that it will use the existing value in the state unless one of the following two scenarios happen: - The value is set to a specific new one in the plan. - The password recipe (which was used to generate it) is changed.
Configuration menu - View commit details
-
Copy full SHA for a6f169e - Browse repository at this point
Copy the full SHA a6f169eView commit details -
This converts an item into a data source model. It’s a rewrite of the same function that exists in the old provider code. A couple of improvements have been added as part of the migration: - No longer throw cause Terraform to trigger a change or an inconsistency error if the tags are the same, but in different order. This is because 1Password sorts the tags alphabetically, which can have a different order than the one tags passed in Terraform have. - With the new framework, Terraform will throw an inconsistency error if the planned value is null (i.e. not set) and the result is empty string). That's why we use the custom `setStringValue` function to set a value on each attribute based on the actual value in 1Password.
Configuration menu - View commit details
-
Copy full SHA for f2f9b01 - Browse repository at this point
Copy the full SHA f2f9b01View commit details -
This converts the Terraform data into a 1Password item. It's a rewrite of the same function that exists in the old provider code. We also implemented the functions associated to it: - parseGeneratorRecipe - currently missing the case in which the attribute is not defined (or Nil) - addRecipe - identical to the one in the old provider code
Configuration menu - View commit details
-
Copy full SHA for d1f801b - Browse repository at this point
Copy the full SHA d1f801bView commit details -
This function extracts the vault and item UUIDs from the terraform ID. This matches the function with the same name from the old provider code.
Configuration menu - View commit details
-
Copy full SHA for 1810a11 - Browse repository at this point
Copy the full SHA 1810a11View commit details -
Implement rest of functions for item resource
Implement configure, create, read, update and delete functions for item resource
Configuration menu - View commit details
-
Copy full SHA for fdfe03b - Browse repository at this point
Copy the full SHA fdfe03bView commit details -
Add test server logic and item generation helpers
These will help with the following: - easily generate the items that we will use for testing. - have a mock server that will act as a Connect server during the tests. Co-authored-by: jillianwilson <jillian.morgan@agilebits.com>
Configuration menu - View commit details
-
Copy full SHA for 4a975a8 - Browse repository at this point
Copy the full SHA 4a975a8View commit details -
Configure the testing provider
Co-authored-by: jillianwilson <jillian.morgan@agilebits.com>
Configuration menu - View commit details
-
Copy full SHA for ef19767 - Browse repository at this point
Copy the full SHA ef19767View commit details -
Add tests for vault data source
Co-authored-by: jillianwilson <jillian.morgan@agilebits.com>
Configuration menu - View commit details
-
Copy full SHA for f45f3c8 - Browse repository at this point
Copy the full SHA f45f3c8View commit details -
Add tests for item data source
Co-authored-by: jillianwilson <jillian.morgan@agilebits.com>
Configuration menu - View commit details
-
Copy full SHA for e71cbc8 - Browse repository at this point
Copy the full SHA e71cbc8View commit details -
Co-authored-by: jillianwilson <jillian.morgan@agilebits.com>
Configuration menu - View commit details
-
Copy full SHA for 2f1c752 - Browse repository at this point
Copy the full SHA 2f1c752View commit details -
This came as part of the scaffolding. We remove it since the 1Password Terraform provider is under the MIT license.
Configuration menu - View commit details
-
Copy full SHA for 743477b - Browse repository at this point
Copy the full SHA 743477bView commit details -
Add other improvements as part of the migration
- Add make command for running acceptance tests. - Update conditional compilation for tools package. Since Go 1.18 the new conditional compilation is `//go:build` instead of `// + build`. - Add terraform-registry-manifest.json file. This file is part of the new framework structure. It's used by the terraform registry to get additional data about the provider being published. For details check this link: https://developer.hashicorp.com/terraform/registry/providers/publishing#terraform-registry-manifest-file - Update goreleaser to use the registry manifest file
Configuration menu - View commit details
-
Copy full SHA for 576e7a5 - Browse repository at this point
Copy the full SHA 576e7a5View commit details -
Update the docs based on the migrated provider and add small improvements to existing examples.
Configuration menu - View commit details
-
Copy full SHA for bb22670 - Browse repository at this point
Copy the full SHA bb22670View commit details -
Update GitHub Action versions used in pipeline
We also do the following adjustments: - Update Go version in the pipeline to 1.21. - Run the test step with TF_ACC=1 to enable acceptance tests (which are the ones we implemented in the migration). - Switch the `paultyng/ghaction-import-gpg@v2.1.0` action to `crazy-max/ghaction-import-gpg@v6` since the previous one is deprecated and it was recommended to use the upstream action that we now use.
Configuration menu - View commit details
-
Copy full SHA for 31cc8e7 - Browse repository at this point
Copy the full SHA 31cc8e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0792838 - Browse repository at this point
Copy the full SHA 0792838View commit details -
Add validator for IDs for OTP field
Field of type OTP require a special field ID. Adding this validator achieves the following: - Ensures that the user will have a functional OTP field. - Terraform will not throw inconsistency errors when the CLI tries to correct the custom ID for OTP field.
Configuration menu - View commit details
-
Copy full SHA for 025df7d - Browse repository at this point
Copy the full SHA 025df7dView commit details