Skip to content

Commit

Permalink
feat: add Compose::validate_all()
Browse files Browse the repository at this point in the history
  • Loading branch information
k9withabone committed May 29, 2024
1 parent fa61655 commit 2701f3a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@ pub struct Compose {
}

impl Compose {
/// Ensure that all [`Resource`]s ([`Network`]s, [`Volume`]s, [`Config`]s, and [`Secret`]s) used
/// in each [`Service`] are defined in the appropriate top-level field.
///
/// Runs, in order, [`validate_networks()`](Self::validate_networks()),
/// [`validate_volumes()`](Self::validate_volumes()),
/// [`validate_configs()`](Self::validate_configs()), and
/// [`validate_secrets()`](Self::validate_secrets()).
///
/// # Errors
///
/// Returns the first error encountered, meaning an [`Identifier`] for a [`Resource`] was used
/// in a [`Service`] which is not defined in the appropriate top-level field.
pub fn validate_all(&self) -> Result<(), ValidationError> {
self.validate_networks()?;
self.validate_volumes()?;
self.validate_configs()?;
self.validate_secrets()?;
Ok(())
}

/// Ensure that the networks used in each [`Service`] are defined in the `networks` field.
///
/// # Errors
Expand Down

0 comments on commit 2701f3a

Please sign in to comment.