Skip to content

Commit

Permalink
Add Secure Note as a supported item category
Browse files Browse the repository at this point in the history
  • Loading branch information
edif2008 committed Apr 25, 2024
1 parent 156bfd1 commit 96346a9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/data-sources/item.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ 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>`.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/item.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ 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.
Expand Down
1 change: 1 addition & 0 deletions internal/provider/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var (
strings.ToLower(string(op.Login)),
strings.ToLower(string(op.Password)),
strings.ToLower(string(op.Database)),
strings.ToLower(string(op.SecureNote)),
}

fieldPurposes = []string{
Expand Down
11 changes: 11 additions & 0 deletions internal/provider/onepassword_item_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,17 @@ func dataToItem(ctx context.Context, data OnePasswordItemResourceModel) (*op.Ite
Value: data.NoteValue.ValueString(),
},
}
case "secure_note":
item.Category = op.SecureNote
item.Fields = []*op.ItemField{
{
ID: "notesPlain",
Label: "notesPlain",
Type: op.FieldTypeString,
Purpose: op.FieldPurposeNotes,
Value: data.NoteValue.ValueString(),
},
}
}

sections := data.Section
Expand Down

0 comments on commit 96346a9

Please sign in to comment.