diff options
author | Florian Klink <flokli@flokli.de> | 2023-01-16T14·55+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-01-18T17·13+0000 |
commit | 083e24bbb1a216b43bfa4fa2e509a1ee6a88ad46 (patch) | |
tree | cf9e6bfe77cbcc801934470ffdfce4b9f119db90 /tvix/derivation/src/validate.rs | |
parent | b1e8fe7212618a61b78eeefa65075295fe2e40b2 (diff) |
feat(tvix/derivation): add validate_output_paths flag for validate r/5700
This allows calling validate() on a derivation that doesn't have its output paths already calculated yet. It allows offloading some of the error checking in builtins.derivation* to be offloaded to that function. Change-Id: Ib4aeadc0eb6583ef8cd765f33e9a9ec32be62729 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7848 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/derivation/src/validate.rs')
-rw-r--r-- | tvix/derivation/src/validate.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tvix/derivation/src/validate.rs b/tvix/derivation/src/validate.rs index c6cd2f8b9e3e..8a8c1b506911 100644 --- a/tvix/derivation/src/validate.rs +++ b/tvix/derivation/src/validate.rs @@ -4,7 +4,11 @@ use tvix_store::store_path::StorePath; impl Derivation { /// validate ensures a Derivation struct is properly populated, /// and returns a [ValidateDerivationError] if not. - pub fn validate(&self) -> Result<(), DerivationError> { + /// if `validate_output_paths` is set to false, the output paths are + /// excluded from validation. + /// This is helpful to validate struct population before invoking + /// [Derivation::calculate_output_paths]. + pub fn validate(&self, validate_output_paths: bool) -> Result<(), DerivationError> { // Ensure the number of outputs is > 1 if self.outputs.is_empty() { return Err(DerivationError::NoOutputs()); @@ -41,7 +45,7 @@ impl Derivation { break; } - if let Err(e) = output.validate() { + if let Err(e) = output.validate(validate_output_paths) { return Err(DerivationError::InvalidOutput(output_name.to_string(), e)); } } |