Skip to content

Refactor ConfigureCommandHandler to Use EnvironmentName Instead of Environment<Provisioned> - #179

Merged
josecelano merged 1 commit into
mainfrom
178-refactor-configure-command-handler-to-use-environment-name
Nov 18, 2025
Merged

josecelano merged 1 commit into
mainfrom
178-refactor-configure-command-handler-to-use-environment-name

Conversation

@josecelano

Copy link
Copy Markdown
Member

Overview

Refactors the ConfigureCommandHandler in the Application layer to accept EnvironmentName instead of Environment<Provisioned> as its input parameter. This change aligns the configure command handler with the provision command handler's interface pattern, simplifying the implementation of presentation layer controllers by reducing the number of Application layer dependencies that need to be constructed.

Fixes #178

Changes

Handler Signature Update

  • ✅ Updated ConfigureCommandHandler::execute() to accept &EnvironmentName instead of Environment<Provisioned>
  • ✅ Moved environment loading logic from presentation layer to ConfigureCommandHandler
  • ✅ Moved state verification logic from presentation layer to ConfigureCommandHandler
  • ✅ Handler now loads environment from repository and validates it's in Provisioned state internally

Error Handling Improvements

  • ✅ Added InvalidState error variant to ConfigureCommandHandlerError for state validation failures
  • ✅ Implemented comprehensive error messages with actionable troubleshooting steps
  • ✅ All errors return explicit enum types (not anyhow::Error) for better pattern matching
  • ✅ Updated Traceable trait implementations to handle the new error variant

Test Updates

  • ✅ Updated run_configure_command test helper to use environment name
  • ✅ Simplified test code by removing state verification (now handled by handler)
  • ✅ Fixed E2E config tests to persist provisioned environment before configure command
  • ✅ Maintained backward compatibility with all existing tests

Benefits

  • Improved Separation of Concerns: Presentation layer no longer handles environment loading and state verification
  • Consistency: Aligns with ProvisionCommandHandler interface pattern
  • Reduced Coupling: Presentation layer has fewer Application layer dependencies
  • Better Error Handling: Explicit error types with actionable messages
  • DDD Compliance: Follows Domain-Driven Design principles with proper layer separation

Testing

All pre-commit checks passed:

  • ✅ No unused dependencies (cargo machete)
  • ✅ All linters passed (markdown, yaml, toml, cspell, clippy, rustfmt, shellcheck)
  • ✅ All unit tests passed (1142 tests)
  • ✅ All integration tests passed
  • ✅ E2E provision and destroy tests passed
  • ✅ E2E configuration tests passed
  • ✅ Documentation builds successfully

Architecture Compliance

  • ✅ Follows DDD layer separation (Application layer pattern)
  • ✅ Respects dependency flow rules
  • ✅ Uses appropriate module organization
  • ✅ Command handler handles environment loading and state verification internally
  • ✅ Error handling follows project conventions with explicit enum errors
  • ✅ Repository operations are non-failing (errors are handled gracefully)

Related

- Update ConfigureCommandHandler::execute() signature to accept &EnvironmentName instead of Environment<Provisioned>
- Move environment loading and state verification logic from presentation layer into handler
- Add InvalidState error variant to ConfigureCommandHandlerError with actionable help messages
- Update E2E config tests to persist provisioned environment before configure command
- Simplify run_configure_command test helper by removing state validation logic

This change aligns ConfigureCommandHandler with ProvisionCommandHandler's interface pattern,
reducing presentation layer dependencies and improving separation of concerns per DDD principles.

Refs: #178
@josecelano josecelano changed the title Refactor ConfigureCommandHandler to use EnvironmentName instead of Environment&lt;Provisioned&gt; Refactor ConfigureCommandHandler to Use EnvironmentName Instead of Environment<Provisioned> Nov 18, 2025
@josecelano josecelano self-assigned this Nov 18, 2025
@josecelano

Copy link
Copy Markdown
Member Author

ACK ed56d66

@josecelano
josecelano merged commit 00949dd into main Nov 18, 2025
@josecelano
josecelano deleted the 178-refactor-configure-command-handler-to-use-environment-name branch April 15, 2026 16:38
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.

Refactor ConfigureCommandHandler to Use EnvironmentName Instead of Environment<Provisioned>

1 participant