KSM-388: Add custom field write support to resources #65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Extends Terraform Provider custom field support to 5 field types (text, multiline, secret, url, email) across all 22 resource types, enabling users to add arbitrary custom fields to secrets stored in Keeper.
Changes
Extended Type Support
Implementation Details
Schema (record_fields.go):
schemaCustomField(): Schema definition supporting type, label, value, required, privacy_screenconvertFieldToMap(): Helper function for Update operations (converts SDK structs to RecordDict maps)Resources (all 22 resource_*.go files):
Record.RecordDict["custom"]Provider (provider.go):
"custom": "custom"to field name mappinggetFieldItemsResourceData()for custom field readsResources Supporting Custom Fields
Standard Records (11):
Complex Nested Records (7):
PAM Records (4):
Other (1):
Tests Added
Representative Tests (4 tests covering all 22 resources):
TestAccResourceLogin_customFields- Covers 11 simple resourcesTestAccResourceBankAccount_customFields- Covers 7 complex nested resourcesTestAccResourcePamUser_customFields- Covers 4 PAM resourcesTestAccResourceAddress_customFields- Covers address resourceType Validation Test:
TestAccResourceLogin_customFieldTypes- Validates all 5 types (text, multiline, secret, url, email)All tests verify:
Supported Field Types
All 5 types share identical SDK structure (
[]stringvalue):Example Usage
Testing
Run all custom field tests:
Test Results:
Technical Details
Custom Field Storage
Custom fields are stored separately from standard fields:
Record.RecordDict["fields"]Record.RecordDict["custom"]CRUD Operations
Create: Uses typed SDK structs (core.Text, core.Multiline, etc.)
Read: Extracts from RecordDict via
getFieldItemsResourceData()Update: Manipulates RecordDict directly
Related Issues