pub struct InternalConfig {
pub build_dir: PathBuf,
pub data_dir: PathBuf,
}Expand description
Internal paths and configuration derived from user inputs
This struct contains fields that are derived automatically from user inputs and are not directly controlled by users. These represent internal implementation details for organizing build artifacts and data.
§Examples
use torrust_tracker_deployer_lib::domain::environment::internal_config::InternalConfig;
use std::path::PathBuf;
let internal_config = InternalConfig {
build_dir: PathBuf::from("build/production"),
data_dir: PathBuf::from("data/production"),
};Fields§
§build_dir: PathBufBuild directory for this environment (derived from environment name)
data_dir: PathBufData directory for this environment (derived from environment name)
Implementations§
Source§impl InternalConfig
impl InternalConfig
Sourcepub fn new(env_name: &EnvironmentName) -> Self
pub fn new(env_name: &EnvironmentName) -> Self
Creates a new InternalConfig with auto-generated directories
§Arguments
env_name- The environment name used to generate directories
§Returns
A new InternalConfig with:
data_dir:./data/{env_name}build_dir:./build/{env_name}
§Examples
use torrust_tracker_deployer_lib::domain::environment::internal_config::InternalConfig;
use torrust_tracker_deployer_lib::domain::environment::EnvironmentName;
use std::path::PathBuf;
let env_name = EnvironmentName::new("production".to_string())?;
let config = InternalConfig::new(&env_name);
assert_eq!(config.data_dir, PathBuf::from("./data/production"));
assert_eq!(config.build_dir, PathBuf::from("./build/production"));Sourcepub fn with_working_dir(env_name: &EnvironmentName, working_dir: &Path) -> Self
pub fn with_working_dir(env_name: &EnvironmentName, working_dir: &Path) -> Self
Creates a new InternalConfig with directories relative to a working directory
This version creates absolute paths by prepending the working directory to the generated data and build directories.
§Arguments
env_name- The environment name used to generate directoriesworking_dir- The base working directory for operations
§Returns
A new InternalConfig with:
data_dir:{working_dir}/data/{env_name}build_dir:{working_dir}/build/{env_name}
§Examples
use torrust_tracker_deployer_lib::domain::environment::internal_config::InternalConfig;
use torrust_tracker_deployer_lib::domain::environment::EnvironmentName;
use std::path::PathBuf;
let env_name = EnvironmentName::new("production".to_string())?;
let working_dir = PathBuf::from("/opt/deployments");
let config = InternalConfig::with_working_dir(&env_name, &working_dir);
assert_eq!(config.data_dir, PathBuf::from("/opt/deployments/data/production"));
assert_eq!(config.build_dir, PathBuf::from("/opt/deployments/build/production"));
Sourcepub fn templates_dir(&self) -> PathBuf
pub fn templates_dir(&self) -> PathBuf
Returns the templates directory for this environment
Path: data/{env_name}/templates/
Sourcepub fn traces_dir(&self) -> PathBuf
pub fn traces_dir(&self) -> PathBuf
Returns the traces directory for this environment
Path: data/{env_name}/traces/
Sourcepub fn ansible_build_dir(&self) -> PathBuf
pub fn ansible_build_dir(&self) -> PathBuf
Returns the ansible build directory
Path: build/{env_name}/ansible
Sourcepub fn tofu_build_dir_for_provider(&self, provider: Provider) -> PathBuf
pub fn tofu_build_dir_for_provider(&self, provider: Provider) -> PathBuf
Returns the OpenTofu build directory for a specific provider
Path: build/{env_name}/tofu/{provider_name}
§Arguments
provider- The provider type (LXD, Hetzner, etc.)
Sourcepub fn ansible_templates_dir(&self) -> PathBuf
pub fn ansible_templates_dir(&self) -> PathBuf
Returns the ansible templates directory
Path: data/{env_name}/templates/ansible
Sourcepub fn tofu_templates_dir(&self) -> PathBuf
pub fn tofu_templates_dir(&self) -> PathBuf
Returns the tofu templates directory
Path: data/{env_name}/templates/tofu
Trait Implementations§
Source§impl Clone for InternalConfig
impl Clone for InternalConfig
Source§impl Debug for InternalConfig
impl Debug for InternalConfig
Source§impl<'de> Deserialize<'de> for InternalConfig
impl<'de> Deserialize<'de> for InternalConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for InternalConfig
impl RefUnwindSafe for InternalConfig
impl Send for InternalConfig
impl Sync for InternalConfig
impl Unpin for InternalConfig
impl UnsafeUnpin for InternalConfig
impl UnwindSafe for InternalConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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