Skip to main content
This section implements the Update method. Update is a synchronous operation that modifies an existing resource.

UpdateRequest

The agent sends an UpdateRequest when modifying an existing resource:

Update semantics

Having both prior and desired properties lets your plugin optimize updates. Rather than blindly rewriting everything, you can compare the two and only change what’s different. For our SFTP plugin:
  • Content changes require rewriting the file
  • Permission changes can be applied directly with chmod
Update returns a ProgressResult (like Create). Even though our implementation completes synchronously, we still return OperationStatusSuccess with the updated ResourceProperties.

Test

Add a test to sftp_test.go:

Test pattern

Implementation

Key points

  1. Compare prior and desired: only update what changed
  2. Content change requires rewrite: upload the entire file again
  3. Permission-only change is faster: just call chmod
  4. Return updated properties: read back the file to confirm the final state

Verify

Run the test to confirm Update modifies both content and permissions correctly:
The test creates a file with original content, updates it through the plugin, then verifies the changes using a separate SFTP client:

Summary

Update compares prior and desired state to apply minimal changes:
Next: 08 - Delete - Implement file deletion with NotFound semantics