Skip to content

refactor: add usecase layer for param and secret operations#8

Merged
mpyw merged 6 commits intomainfrom
refactor/usecase-cleanup
Jan 3, 2026
Merged

refactor: add usecase layer for param and secret operations#8
mpyw merged 6 commits intomainfrom
refactor/usecase-cleanup

Conversation

@mpyw
Copy link
Owner

@mpyw mpyw commented Jan 3, 2026

Summary

  • Add usecase layer for SSM Parameter Store operations (param)
  • Add usecase layer for Secrets Manager operations (secret)
  • Add Store interfaces for testability
  • Add comprehensive tests with 100% coverage for all usecase packages

Supersedes #4 and #5.

Test Coverage

Package Coverage
usecase/param 100%
usecase/secret 100%
usecase/staging 100%

Test plan

  • All tests pass (make test)
  • Lint passes (make lint)
  • 100% coverage on usecase layer

🤖 Generated with Claude Code

mpyw and others added 6 commits January 3, 2026 08:43
* refactor: add usecase layer for staging operations

Add usecase layer that returns structured data instead of formatting output.
This is the foundation for supporting both CLI and future GUI (Wails) interfaces.

New usecases:
- StatusUseCase: returns StatusOutput with entries
- ApplyUseCase: returns ApplyOutput with results and conflicts
- AddUseCase: stages new items with structured input/output
- EditUseCase: stages edits with structured input/output
- DeleteUseCase: stages deletions with structured input/output
- ResetUseCase: unstages or restores with structured output
- DiffUseCase: compares staged vs AWS with structured diff entries

The existing runners are not yet modified to use these usecases.
That integration will be done in a subsequent PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: improve usecase staging layer

- Move DeleteStrategy and VersionFetcher interfaces to staging package
- Rename GetStagedValue to Draft, GetCurrentValue to Baseline
- Fix apply order: check name filter before empty check
- Add comprehensive tests (91.9% coverage)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
- Define StoreReader, StoreWriter, StoreReadWriter interfaces in staging package
- Update usecase layer to use interfaces instead of concrete *Store type
- Add mock store implementation for testing error paths
- Achieve 100% test coverage for usecase/staging package

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add usecase layer for SSM Parameter Store operations that returns
structured data instead of formatting output.

New usecases:
- ShowUseCase: returns ShowOutput with parameter metadata
- ListUseCase: returns ListOutput with entries (optionally with values)
- LogUseCase: returns LogOutput with version history
- DiffUseCase: returns DiffOutput with comparison data
- SetUseCase: creates/updates parameters with tagging support
- DeleteUseCase: deletes parameters

This is Step 3 of the usecase layer architecture refactoring plan.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for all param usecase operations with 100% coverage:
- delete_test.go: DeleteUseCase tests
- diff_test.go: DiffUseCase tests with version/shift support
- list_test.go: ListUseCase tests with filters and pagination
- log_test.go: LogUseCase tests with date filters
- set_test.go: SetUseCase tests with tagging operations
- show_test.go: ShowUseCase tests with version/shift support

Key mock patterns:
- Use fresh slice copies for GetParameterHistory to avoid
  in-place mutation issues with slices.Reverse
- Support sequential GetParameter calls for multi-spec operations
- Proper AWS SDK v2 variadic options signatures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Create structured use cases for Secrets Manager operations:
- show.go: Display secret value with metadata
- list.go: List secrets with filtering and pagination
- log.go: Show version history
- diff.go: Compare secret versions
- create.go: Create new secrets
- update.go: Update existing secrets
- delete.go: Delete secrets with recovery window
- restore.go: Restore deleted secrets

Each usecase provides structured input/output types for clean
separation between CLI and business logic.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for all secret usecase operations with 100% coverage:
- create_test.go: CreateUseCase tests
- delete_test.go: DeleteUseCase tests with force and recovery window
- diff_test.go: DiffUseCase tests with version/shift support
- list_test.go: ListUseCase tests with filters
- log_test.go: LogUseCase tests with date filters and sorting edge cases
- restore_test.go: RestoreUseCase tests
- show_test.go: ShowUseCase tests with version/label/shift support
- update_test.go: UpdateUseCase tests with tagging operations

Key test patterns:
- Sequential mock calls for multi-spec operations
- Sorting edge cases (nil dates, equal dates)
- Date filtering with nil CreatedDate entries
- Value fetch error handling (swallowed in log)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mpyw mpyw merged commit d1159d6 into main Jan 3, 2026
11 checks passed
@mpyw mpyw deleted the refactor/usecase-cleanup branch January 3, 2026 00:59
@mpyw mpyw added the cli CLI functionality label Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant