server_forge/
config.rs

1//! # Configuration Module
2//!
3//! This module defines the `Config` struct, which represents the configuration
4//! for the server setup and maintenance tool. It includes various settings
5//! such as the Linux distribution, server role, security level, and deployment options.
6//!
7//! The `Config` struct implements `Serialize` and `Deserialize` traits from serde,
8//! allowing for easy serialization and deserialization of the configuration.
9
10use serde::{Deserialize, Serialize};
11
12/// Represents the configuration for the server setup and maintenance tool.
13///
14/// This struct contains all the necessary settings and options for configuring
15/// a server, including the operating system, security settings, and deployment options.
16#[derive(Serialize, Deserialize, Clone)]
17pub struct Config {
18    /// The Linux distribution being used (e.g., "ubuntu", "centos", "fedora")
19    pub linux_distro: String,
20
21    /// The role of the server (e.g., "web", "database", "application")
22    pub server_role: String,
23
24    /// The desired security level (e.g., "basic", "intermediate", "advanced")
25    pub security_level: String,
26
27    /// Whether to enable monitoring on the server
28    pub monitoring: bool,
29
30    /// The frequency of backups (e.g., "hourly", "daily", "weekly")
31    pub backup_frequency: String,
32
33    /// A list of applications to be deployed on the server
34    pub deployed_apps: Vec<String>,
35
36    /// A list of custom firewall rules to be applied
37    pub custom_firewall_rules: Vec<String>,
38
39    /// The schedule for automatic updates (e.g., "daily", "weekly", "monthly")
40    pub update_schedule: String,
41
42    /// Whether to use containerization for deployments
43    pub use_containers: bool,
44
45    /// Whether to use Kubernetes for container orchestration
46    pub use_kubernetes: bool,
47}
48
49/// Provides default values for the `Config` struct.
50impl Default for Config {
51    /// Returns a new `Config` instance with default values.
52    fn default() -> Self {
53        Config {
54            linux_distro: String::from("ubuntu"),
55            server_role: String::new(),
56            security_level: String::new(),
57            monitoring: false,
58            backup_frequency: String::from("daily"),
59            deployed_apps: Vec::new(),
60            custom_firewall_rules: Vec::new(),
61            update_schedule: String::from("weekly"),
62            use_containers: false,
63            use_kubernetes: false,
64        }
65    }
66}