-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmod.rs
More file actions
71 lines (66 loc) · 2.59 KB
/
mod.rs
File metadata and controls
71 lines (66 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Configuration management for deployment settings
//!
//! This module provides the `Config` struct which manages essential file system
//! paths for the deployment process including template sources and build outputs.
//!
//! ## Current Configuration Areas
//!
//! - File system paths for templates and build outputs
//! - Project root directory for resolving relative paths
//!
//! ## Path Relationships
//!
//! Typically, the paths have this relationship:
//! - `project_root`: `/path/to/torrust-tracker-deploy`
//! - `templates_dir`: `{project_root}/templates`
//! - `build_dir`: `{project_root}/build`
//!
//! The configuration is typically created once at deployment start and passed
//! throughout the system to ensure consistent path resolution across all components.
use std::path::PathBuf;
/// Configuration parameters for deployment environments.
///
/// Centralizes all deployment-related configuration including file paths,
/// service connection details, and runtime behavior settings.
///
/// Created once at deployment start and passed to [`Services::new()`](crate::bootstrap::container::Services::new).
pub struct Config {
/// Directory containing template files for rendering configurations.
///
/// This directory should contain subdirectories for different template
/// types (e.g., "ansible/", "tofu/") with template files that will be
/// processed and rendered to the build directory.
pub templates_dir: PathBuf,
/// Root directory of the project.
///
/// Used for resolving relative paths and locating project resources
/// such as SSH key fixtures and project-specific configuration files.
pub project_root: PathBuf,
/// Directory where rendered configuration files will be written.
///
/// All processed templates and generated configuration files are written
/// to subdirectories within this build directory. This directory is
/// typically git-ignored to avoid committing generated files.
pub build_dir: PathBuf,
}
impl Config {
/// Creates a new configuration with the provided parameters.
///
/// ```rust
/// # use std::path::PathBuf;
/// # use torrust_tracker_deployer_lib::config::Config;
/// let config = Config::new(
/// PathBuf::from("/home/user/project/templates"),
/// PathBuf::from("/home/user/project"),
/// PathBuf::from("/home/user/project/build"),
/// );
/// ```
#[must_use]
pub fn new(templates_dir: PathBuf, project_root: PathBuf, build_dir: PathBuf) -> Self {
Self {
templates_dir,
project_root,
build_dir,
}
}
}