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

Migration to Terraform provider framework #167

Merged
merged 36 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
69982a8
Update all Go packages to the latest version
edif2008 May 2, 2024
a5f346c
Add provider framework dependencies and update packages
edif2008 May 2, 2024
fae4cfb
Add scaffolding files for the provider framework
edif2008 May 2, 2024
16353d9
Migrate main.go to use the provider framework code
edif2008 May 2, 2024
beedbb2
Remove provider function scaffolding
edif2008 May 2, 2024
614906e
Implement 1Password Client interface
edif2008 May 2, 2024
1ffaa67
Add Connect client
edif2008 May 2, 2024
b1d648f
Add CLI client
edif2008 May 2, 2024
96117be
Implement new 1Password client function
edif2008 May 2, 2024
c813650
Define OnePassword provider
edif2008 May 2, 2024
750ee46
Add provider configuration functionality
edif2008 May 2, 2024
54b104c
Add vault data source scaffolding
edif2008 May 2, 2024
c912599
Add framework validator package
edif2008 May 2, 2024
47ede0a
Define vault data source schema and model
edif2008 May 2, 2024
a96b298
Add constants for attribute descriptions
edif2008 May 2, 2024
7648c0b
Rename scaffolding files
edif2008 May 2, 2024
865371c
Define OnePasswordItem data source schema and data model
edif2008 May 2, 2024
7d1f3c9
Implement configure and read functionalities for item data source
edif2008 May 2, 2024
967dc53
Add additional packages in vendor
edif2008 May 2, 2024
6fbe23b
Define OnePasswordItem resource schema and data model
edif2008 May 2, 2024
a6f169e
Implement custom value modifier
edif2008 May 2, 2024
f2f9b01
Implement itemToData function
edif2008 May 2, 2024
d1f801b
Implement dataToItem function
edif2008 May 2, 2024
1810a11
Add vaultAndItemUUID function
edif2008 May 2, 2024
fdfe03b
Implement rest of functions for item resource
edif2008 May 2, 2024
4a975a8
Add test server logic and item generation helpers
edif2008 May 2, 2024
ef19767
Configure the testing provider
edif2008 May 2, 2024
f45f3c8
Add tests for vault data source
edif2008 May 2, 2024
e71cbc8
Add tests for item data source
edif2008 May 2, 2024
2f1c752
Add tests for item resource
edif2008 May 2, 2024
743477b
Remove copyright
edif2008 May 2, 2024
576e7a5
Add other improvements as part of the migration
edif2008 May 2, 2024
bb22670
Update and improve docs
edif2008 May 2, 2024
31cc8e7
Update GitHub Action versions used in pipeline
edif2008 May 2, 2024
0792838
Add notes field and Secure Note category
edif2008 May 2, 2024
025df7d
Add validator for IDs for OTP field
edif2008 May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: ^1.21

- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./... -cover
env:
TF_ACC: "1"
timeout-minutes: 10
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ^1.19

- name: Install Terraform
uses: hashicorp/setup-terraform@v2
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false

- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Generate docs
run: go generate
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- id: is_release_branch_without_pr
name: Find matching PR
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -42,7 +42,7 @@ jobs:
name: Create Release Pull Request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Parse release version
id: get_version
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,25 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ^1.19
-
name: Import GPG key
id: import_gpg
# TODO: move this to HashiCorp namespace or find alternative that is just simple gpg commands
# see https://github.com/hashicorp/terraform-provider-scaffolding/issues/22
uses: paultyng/[email protected]
env:
uses: crazy-max/ghaction-import-gpg@v6
with:
# These secrets will need to be configured for the repository:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v5
with:
version: 1.19.1
args: release --clean
Expand Down
6 changes: 6 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
Expand All @@ -48,6 +51,9 @@ signs:
- "--detach-sign"
- "${artifact}"
release:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
# If you want to manually examine the release before its live, uncomment this line:
draft: true
changelog:
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export MAIN_BRANCH ?= main

.DEFAULT_GOAL := help
.PHONY: test build clean test/coverage release/prepare release/tag .check_bump_type .check_git_clean help
.PHONY: test testacc build clean test/coverage release/prepare release/tag .check_bump_type .check_git_clean help

GIT_BRANCH := $(shell git symbolic-ref --short HEAD)
WORKTREE_CLEAN := $(shell git status --porcelain 1>/dev/null 2>&1; echo $$?)
Expand All @@ -17,6 +17,9 @@ test: ## Run test suite
test/coverage: ## Run test suite with coverage report
go test -v ./... -cover

testacc: ## Run acceptance tests
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m

build: clean ## Build project
go build -o ./dist/terraform-provider-onepassword .

Expand Down
30 changes: 15 additions & 15 deletions docs/data-sources/item.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "onepassword_item Data Source - terraform-provider-onepassword"
page_title: "onepassword_item Data Source - onepassword"
subcategory: ""
description: |-
Use this data source to get details of an item by its vault uuid and either the title or the uuid of the item.
Expand All @@ -14,7 +14,7 @@ Use this data source to get details of an item by its vault uuid and either the

```terraform
data "onepassword_item" "example" {
vault = var.demo_vault
vault = data.onepassword_vault.example.uuid
uuid = onepassword_item.demo_sections.uuid
}
```
Expand All @@ -34,34 +34,34 @@ data "onepassword_item" "example" {

### Read-Only

- `category` (String) The category of the item. One of ["login" "password" "database"]
- `category` (String) The category of the item. One of ["login" "password" "database" "secure_note"]
- `database` (String) (Only applies to the database category) The name of the database.
- `hostname` (String) (Only applies to the database category) The address where the database can be found
- `id` (String) The Terraform resource identifier for this item in the format `vaults/<vault_id>/items/<item_id>`
- `id` (String) The Terraform resource identifier for this item in the format `vaults/<vault_id>/items/<item_id>`.
- `password` (String, Sensitive) Password for this item.
- `port` (String) (Only applies to the database category) The port the database is listening on.
- `section` (List of Object) A list of custom sections in an item (see [below for nested schema](#nestedatt--section))
- `section` (Block List) A list of custom sections in an item (see [below for nested schema](#nestedblock--section))
- `tags` (List of String) An array of strings of the tags assigned to the item.
- `type` (String) (Only applies to the database category) The type of database. One of ["db2" "filemaker" "msaccess" "mssql" "mysql" "oracle" "postgresql" "sqlite" "other"]
- `url` (String) The primary URL for the item.
- `username` (String) Username for this item.

<a id="nestedatt--section"></a>
<a id="nestedblock--section"></a>
### Nested Schema for `section`

Read-Only:

- `field` (List of Object) (see [below for nested schema](#nestedobjatt--section--field))
- `id` (String)
- `label` (String)
- `field` (Block List) (see [below for nested schema](#nestedblock--section--field))
- `id` (String) A unique identifier for the section.
- `label` (String) The label for the section.

<a id="nestedobjatt--section--field"></a>
<a id="nestedblock--section--field"></a>
### Nested Schema for `section.field`

Read-Only:

- `id` (String)
- `label` (String)
- `purpose` (String)
- `type` (String)
- `value` (String)
- `id` (String) A unique identifier for the field.
- `label` (String) The label for the field.
- `purpose` (String) Purpose indicates this is a special field: a username, password, or notes field.
- `type` (String) The type of value stored in the field.
- `value` (String, Sensitive) The value of the field.
8 changes: 7 additions & 1 deletion docs/data-sources/vault.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "onepassword_vault Data Source - terraform-provider-onepassword"
page_title: "onepassword_vault Data Source - onepassword"
subcategory: ""
description: |-
Use this data source to get details of a vault by either its name or uuid.
Expand All @@ -10,7 +10,13 @@ description: |-

Use this data source to get details of a vault by either its name or uuid.

## Example Usage

```terraform
data "onepassword_vault" "example" {
name = var.demo_vault
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ Environment variables are a more secure way to set configuration options because

- `account` (String) A valid account's sign-in address or ID to use biometrics unlock. Can also be sourced from `OP_ACCOUNT` environment variable. Provider will use the 1Password CLI if set.
- `op_cli_path` (String) The path to the 1Password CLI binary. Can also be sourced from `OP_CLI_PATH` environment variable. Defaults to `op`.
- `service_account_token` (String) A valid 1Password service account token. Can also be sourced from `OP_SERVICE_ACCOUNT_TOKEN` environment variable. Provider will use the 1Password CLI if set.
- `token` (String) A valid token for your 1Password Connect server. Can also be sourced from `OP_CONNECT_TOKEN` environment variable. Provider will use 1Password Connect server if set.
- `service_account_token` (String, Sensitive) A valid 1Password service account token. Can also be sourced from `OP_SERVICE_ACCOUNT_TOKEN` environment variable. Provider will use the 1Password CLI if set.
- `token` (String, Sensitive) A valid token for your 1Password Connect server. Can also be sourced from `OP_CONNECT_TOKEN` environment variable. Provider will use 1Password Connect server if set.
- `url` (String) The HTTP(S) URL where your 1Password Connect server can be found. Can also be sourced `OP_CONNECT_HOST` environment variable. Provider will use 1Password Connect server if set.

## Item fields
Expand Down
15 changes: 8 additions & 7 deletions docs/resources/item.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "onepassword_item Resource - terraform-provider-onepassword"
page_title: "onepassword_item Resource - onepassword"
subcategory: ""
description: |-
A 1Password item.
A 1Password Item.
---

# onepassword_item (Resource)

A 1Password item.
A 1Password Item.

## Example Usage

Expand Down Expand Up @@ -66,11 +66,12 @@ resource "onepassword_item" "demo_db" {

### Optional

- `category` (String) The category of the item. One of ["login" "password" "database"]
- `category` (String) The category of the item. One of ["login" "password" "database" "secure_note"]
- `database` (String) (Only applies to the database category) The name of the database.
- `hostname` (String) (Only applies to the database category) The address where the database can be found
- `note_value` (String, Sensitive) Secure Note value.
- `password` (String, Sensitive) Password for this item.
- `password_recipe` (Block List, Max: 1) Password for this item. (see [below for nested schema](#nestedblock--password_recipe))
- `password_recipe` (Block List) The recipe used to generate a new value for a password. (see [below for nested schema](#nestedblock--password_recipe))
- `port` (String) (Only applies to the database category) The port the database is listening on.
- `section` (Block List) A list of custom sections in an item (see [below for nested schema](#nestedblock--section))
- `tags` (List of String) An array of strings of the tags assigned to the item.
Expand Down Expand Up @@ -120,9 +121,9 @@ Required:
Optional:

- `id` (String) A unique identifier for the field.
- `password_recipe` (Block List, Max: 1) Password for this item. (see [below for nested schema](#nestedblock--section--field--password_recipe))
- `password_recipe` (Block List) The recipe used to generate a new value for a password. (see [below for nested schema](#nestedblock--section--field--password_recipe))
- `purpose` (String) Purpose indicates this is a special field: a username, password, or notes field. One of ["USERNAME" "PASSWORD" "NOTES"]
- `type` (String) The type of value stored in the field. One of ["STRING" "EMAIL" "CONCEALED" "URL" "OTP" "DATE" "MONTH_YEAR" "MENU"]
- `type` (String) The type of value stored in the field. One of ["STRING" "CONCEALED" "EMAIL" "URL" "OTP" "DATE" "MONTH_YEAR" "MENU"]
- `value` (String, Sensitive) The value of the field.

<a id="nestedblock--section--field--password_recipe"></a>
Expand Down
2 changes: 1 addition & 1 deletion examples/data-sources/onepassword_item/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
data "onepassword_item" "example" {
vault = var.demo_vault
vault = data.onepassword_vault.example.uuid
uuid = onepassword_item.demo_sections.uuid
}
3 changes: 3 additions & 0 deletions examples/data-sources/onepassword_vault/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "onepassword_vault" "example" {
name = var.demo_vault
}
2 changes: 1 addition & 1 deletion examples/variable.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
variable "demo_vault" {
description = "The UUID of a Vault that has been added to your 1Password Connect API"
description = "The name of the Vault that the provider will use to read or write items."
}
Loading
Loading