use std::path::Path;
use serde::de::DeserializeOwned;
use serde::Serialize;
use crate::core::types::{BuildOutput, DeploymentResult};
use crate::error::DeploymentError;
pub trait DeploymentProvider {
type Config: DeserializeOwned + Serialize + Clone + core::fmt::Debug;
type Resources: core::fmt::Debug;
fn name(&self) -> &str;
fn detect(project_dir: &Path) -> Option<Self::Config>
where
Self: Sized;
fn validate(&self, config: &Self::Config) -> Result<(), DeploymentError>;
fn build(
&self,
config: &Self::Config,
env: Option<&str>,
) -> Result<BuildOutput, DeploymentError>;
fn deploy(
&self,
config: &Self::Config,
env: Option<&str>,
dry_run: bool,
) -> Result<DeploymentResult, DeploymentError>;
fn rollback(
&self,
config: &Self::Config,
env: Option<&str>,
previous_state: Option<&Self::Resources>,
) -> Result<(), DeploymentError>;
fn logs(&self, config: &Self::Config, env: Option<&str>) -> Result<(), DeploymentError>;
fn destroy(&self, config: &Self::Config, env: Option<&str>) -> Result<(), DeploymentError>;
fn status(
&self,
config: &Self::Config,
env: Option<&str>,
) -> Result<Self::Resources, DeploymentError>;
fn verify(&self, result: &DeploymentResult) -> Result<bool, DeploymentError> {
let _ = result;
Ok(true)
}
}