pub struct ProvisionCommandHandler { /* private fields */ }Expand description
ProvisionCommandHandler orchestrates the complete infrastructure provisioning workflow
The ProvisionCommandHandler orchestrates the complete infrastructure provisioning workflow.
This command handler handles all steps required to provision infrastructure:
- Render
OpenTofutemplates - Initialize
OpenTofu - Validate configuration syntax and consistency
- Plan infrastructure
- Apply infrastructure
- Get instance information
- Render
Ansibletemplates (with runtime IP address) - Wait for SSH connectivity
- Wait for cloud-init completion
§State Management
The command handler integrates with the type-state pattern for environment lifecycle:
- Accepts
Environment<Created>as input - Transitions to
Environment<Provisioning>at start - Returns
Environment<Provisioned>on success - Transitions to
Environment<ProvisionFailed>on error
State is persisted after each transition using the injected repository. Persistence failures are logged but don’t fail the command handler (state remains valid in memory).
Implementations§
Source§impl ProvisionCommandHandler
impl ProvisionCommandHandler
Sourcepub fn new(
clock: Arc<dyn Clock>,
repository: Arc<dyn EnvironmentRepository>,
) -> Self
pub fn new( clock: Arc<dyn Clock>, repository: Arc<dyn EnvironmentRepository>, ) -> Self
Create a new ProvisionCommandHandler
Sourcepub async fn execute(
&self,
env_name: &EnvironmentName,
listener: Option<&dyn CommandProgressListener>,
) -> Result<Environment<Provisioned>, ProvisionCommandHandlerError>
pub async fn execute( &self, env_name: &EnvironmentName, listener: Option<&dyn CommandProgressListener>, ) -> Result<Environment<Provisioned>, ProvisionCommandHandlerError>
Execute the complete provisioning workflow
§Arguments
env_name- The name of the environment to provisionlistener- Optional progress listener for reporting step-level progress. When provided, the handler reports progress at each of the 9 provisioning steps. WhenNone, the handler executes silently (backward compatible).
§Returns
Returns the provisioned environment
§Errors
Returns an error if any step in the provisioning workflow fails:
- Environment not found or not in
Createdstate - Template rendering fails
OpenTofuinitialization, planning, or apply fails- Unable to retrieve instance information
- SSH connectivity cannot be established
- Cloud-init does not complete successfully
On error, the environment transitions to ProvisionFailed state and is persisted.
Auto Trait Implementations§
impl !RefUnwindSafe for ProvisionCommandHandler
impl !Send for ProvisionCommandHandler
impl !Sync for ProvisionCommandHandler
impl !UnwindSafe for ProvisionCommandHandler
impl Freeze for ProvisionCommandHandler
impl Unpin for ProvisionCommandHandler
impl UnsafeUnpin for ProvisionCommandHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request