-
Notifications
You must be signed in to change notification settings - Fork 9
KSM-388: Add custom field write support to resources #65
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # .gitignore # Makefile # go.sum
# Conflicts: # .gitignore # Makefile # go.sum
Updated to SM Go SDK v0.7.0
Update README.md
added resources
updated terraform-plugin-sdk to latest version
bumping KMS GoLang SDK version to v1.3.1
bumping secretsmanager version in examples
Changed test files to properly skip tests when TF_ACC is not set instead of failing. This prevents CI from failing when running unit tests without acceptance test credentials. Files fixed: - data_source_folder_test.go: removed nil pointer dereference - resource_folder_test.go: changed t.Fail() to t.Skip() - resource_pam_machine_test.go: changed t.Fatal() to t.Skip() - resource_pam_database_test.go: changed t.Fatal() to t.Skip()
- Add resource_pam_user_test.go with 4 acceptance tests (create, update, delete, import) - Add resource_pam_directory_test.go with 4 acceptance tests - Enable PAM Database update test (was disabled due to SDK concerns) - Add examples for PAM User resources and data sources - Fix test data formats (checkbox values, database_type lowercase, distinguished_name labels) - All 16 PAM acceptance tests now pass (Database, Directory, Machine, User) Note: Update tests only test fields that work with current SDK (v1.6.4). Fields using ApplyFieldChange() have known SDK limitation where RecordDict changes don't sync to RawJson. Workaround: tests focus on fields using SetStandardFieldValue().
Updated version constraints in PAM resource and data source examples:
- examples/data-sources/pam_{database,machine,user}.tf
- examples/resources/pam_{database,machine,user}.tf
All PAM examples now consistently require provider version >= 1.1.8
which includes the PAM record type support added in KSM-527.
Ensure go mod tidy runs with -compat=1.24.8 to maintain compatibility with the Go version specified in go.mod during releases, regardless of the Go version installed on the release machine.
Implement custom field create, read, and update operations for login resources, allowing users to add arbitrary custom fields to their secrets. This addresses GitHub issue #16 and Jira ticket KSM-388. Features: - Add custom schema field to resource_login accepting list of custom fields - Support text-type custom fields with label, value, required, and privacy_screen - Process custom fields during resource Create operation - Read custom fields during resource Read operation - Update custom fields during resource Update operation - Custom fields stored in Record.Custom array via Go SDK Tests: - TestAccResourceLogin_customFields: Create with 2 custom fields - TestAccResourceLogin_customFields: Update to 3 custom fields with value changes - Validates custom field count, labels, and values persist correctly Schema: - schemaCustomField(): Writable custom field schema (Optional vs Computed) - Fields: type (required), label, value, required, privacy_screen Helper Functions: - getFieldItemsResourceData(): Read custom fields from Record into Terraform state - Custom fields processed same as standard fields using NewFieldFromSchema - ApplyFieldChange() already supports "custom" section References: GitHub issue #16, Jira KSM-388
98ee6a5 to
2293061
Compare
Add custom field write support to all resource types, enabling users to add text-type custom fields to any Keeper record via Terraform. Changes per resource (21 resources extended): - Schema: Added 'custom' field using schemaCustomField() - Create: Process custom fields from Terraform config to Record.Custom - Read: Read custom fields from Record.Custom to Terraform state - Update: Handle custom field changes via ApplyFieldChange() All resources now support the same custom field pattern as resource_login (implemented in commit 042c8a5). Extended resources: - address, bank_account, bank_card, birth_certificate, contact - database_credentials, driver_license, encrypted_notes, file - health_insurance, membership, pam_database, pam_directory - pam_machine, pam_user, passport, photo, server_credentials - software_license, ssh_keys, ssn_card References: GitHub issue #16, Jira KSM-388
…d email types Previously, custom fields only supported "text" type. This commit extends support to include multiline, secret, url, and email types - all of which share the same structure ([]string value) in the Go SDK. Changes: - Updated Create functions across all 22 resources to handle 5 field types - Updated Update functions to properly sync all 5 types to vault - Added convertFieldToMap helper to record_fields.go for Update operations - Added TestAccResourceLogin_customFieldTypes to validate all types - All existing custom field tests continue to pass All 5 types work correctly for Create, Read, Update operations.
2293061 to
8b42042
Compare
…modules-dd7da38a6b Bump golang.org/x/crypto from 0.42.0 to 0.45.0 in the go_modules group across 1 directory
- Make custom field labels required - Add validation to reject duplicate labels in Create/Update - Add warning for duplicate labels in Read/Import - Add comprehensive test coverage for validation logic - Applied across all 22 resource types Validation enforces unique labels at plan time with clear error messages. Import operations warn users about vault records with duplicates. Tests verify Create and Update rejection of duplicate labels.
…o 'connectDatabase'
…er_group, provider_region, alternative_ips fields
Fix gofmt indentation issues in pamDirectory resource and data source files.
baff991 to
57d7f7b
Compare
Collaborator
Author
|
PR closed due to force-push on release-v1.1.8. Recreated as PR #68 with updated base. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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