Skip to content

Add context cancellation support and export special path constants fo…#140

Open
peteski22 wants to merge 1 commit into
hashicorp:mainfrom
peteski22:file-sink-update
Open

Add context cancellation support and export special path constants fo…#140
peteski22 wants to merge 1 commit into
hashicorp:mainfrom
peteski22:file-sink-update

Conversation

@peteski22

Copy link
Copy Markdown

Summary

Add context cancellation support and export FileSink-specific path constants to improve integration capabilities and enable graceful shutdown handling.

Changes

Context Support:

  • Added context cancellation checks in FileSink.Process() at two strategic points: before processing and after acquiring the mutex lock
  • Enables proper timeout handling and graceful shutdowns for consuming applications

Exported Constants:

  • Exported special file path constants as FileStdout, FileStderr, and FileDevNull with proper Go documentation
  • Allows consuming applications to use these FileSink-specific paths consistently without hardcoding strings

Testing:

  • Added comprehensive tests for context cancellation behavior
  • Enhanced existing tests to verify actual file operations and proper error handling

Backward Compatibility

  • All changes are fully backward compatible. The context parameter was already present in the Process() method signature but unused. No existing functionality is modified.

PCI review checklist

[x] I have documented a clear reason for, and description of, the change I am making.
[x] If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
[x] If applicable, I've documented the impact of any changes to security controls.

Reason: Enable proper context cancellation for FileSink operations and provide standardized constants for special file paths. This improves integration with applications requiring graceful shutdown capabilities (like Vault) while maintaining existing security posture.

Revert Plan: N/A - Changes are purely additive and backward compatible. Simple PR revert is sufficient.

Security Impact: No changes to security controls. The exported constants maintain the same file path restrictions, and context cancellation adds fail-safe behavior that prevents operations on cancelled contexts.

@peteski22 peteski22 requested a review from a team as a code owner September 4, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant