Skip to content

Commit 2264619

Browse files
committed
docs: update InstanceName documentation to reflect dual use for VMs and containers
- Update module-level docs to clarify usage for both LXD VMs and testing containers - Add Use Cases section explaining deployment VMs vs E2E test containers - Update examples with more realistic naming patterns (vm-prod, test-container-01) - Enhance method documentation to mention both use cases - Maintain technical accuracy while improving context clarity
1 parent 3a915ed commit 2264619

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/domain/instance_name.rs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
//! LXD instance name validation and management
1+
//! Instance name validation and management for LXD VMs and containers
22
//!
3-
//! This module provides the `InstanceName` type which ensures LXD instance names
3+
//! This module provides the `InstanceName` type which ensures instance names
44
//! follow the strict naming requirements imposed by LXD for security and
5-
//! compatibility reasons.
5+
//! compatibility reasons. The validated names are used for:
6+
//!
7+
//! - **LXD Virtual Machines**: Names for provisioned VMs in production/deployment environments
8+
//! - **Testing Containers**: Names for Docker containers used in end-to-end tests
69
//!
710
//! ## Naming Requirements
811
//!
@@ -39,7 +42,10 @@ pub enum InstanceNameError {
3942
InvalidCharacters,
4043
}
4144

42-
/// A validated LXD instance name following LXD naming requirements.
45+
/// A validated instance name following LXD naming requirements.
46+
///
47+
/// This type ensures that names are valid for both LXD virtual machines used in
48+
/// production deployments and Docker containers used in end-to-end testing.
4349
///
4450
/// Valid instance names must fulfill the following requirements:
4551
/// - The name must be between 1 and 63 characters long
@@ -50,15 +56,20 @@ pub enum InstanceNameError {
5056
/// These requirements ensure that the instance name can be used in DNS records,
5157
/// on the file system, in various security profiles and as the host name.
5258
///
59+
/// # Use Cases
60+
///
61+
/// - **LXD Virtual Machines**: Naming VMs provisioned for deployment environments
62+
/// - **Testing Containers**: Naming Docker containers in E2E test scenarios
63+
///
5364
/// # Examples
5465
///
5566
/// ```rust
5667
/// use torrust_tracker_deploy::domain::InstanceName;
5768
///
5869
/// // Valid instance names - accepts both &str and String
59-
/// let instance1 = InstanceName::new("test-instance")?;
60-
/// let instance2 = InstanceName::new("web-server-01".to_string())?;
61-
/// let instance3 = InstanceName::new(format!("app-{}", "prod"))?;
70+
/// let vm_instance = InstanceName::new("torrust-vm-prod")?;
71+
/// let test_container = InstanceName::new("test-container-01".to_string())?;
72+
/// let dynamic_name = InstanceName::new(format!("app-{}", "staging"))?;
6273
///
6374
/// // Invalid instance names
6475
/// assert!(InstanceName::new("").is_err());
@@ -74,6 +85,9 @@ pub struct InstanceName(String);
7485
impl InstanceName {
7586
/// Creates a new `InstanceName` from a string if it's valid.
7687
///
88+
/// This method validates that the provided name meets the requirements for both
89+
/// LXD virtual machines and testing containers.
90+
///
7791
/// # Arguments
7892
///
7993
/// * `name` - The instance name to validate (accepts `&str`, `String`, or anything that implements `Into<String>`)
@@ -97,10 +111,10 @@ impl InstanceName {
97111
/// ```rust
98112
/// use torrust_tracker_deploy::domain::InstanceName;
99113
///
100-
/// // Valid names - accepts both &str and String
101-
/// let name1 = InstanceName::new("test-instance")?;
102-
/// let name2 = InstanceName::new("web-01".to_string())?;
103-
/// let name3 = InstanceName::new(format!("app-{}", "prod"))?;
114+
/// // Valid names for VMs and containers - accepts both &str and String
115+
/// let vm_name = InstanceName::new("torrust-vm-prod")?;
116+
/// let container_name = InstanceName::new("test-web-01".to_string())?;
117+
/// let dynamic_name = InstanceName::new(format!("app-{}", "staging"))?;
104118
///
105119
/// // Invalid names
106120
/// assert!(InstanceName::new("").is_err());

0 commit comments

Comments
 (0)