/// A predicate on the replica version records contained in a registry
/// snapshot.
///
/// For each replica version that is either referred to in an SubnetRecord
/// of a subnet that is listed in the subnet list or that is contained
/// the BlessedReplicaVersions-List, the following is checked:
///
/// * The corresponding ReplicaVersionRecord exists.
/// * At least one of either the replica, orchestrator or release package is
///   specified.
/// * Each set URL is well-formed.
/// * Each set hash is a well-formed hex-encoded SHA256 value.
A predicate on the replica version records contained in a registry
snapshot.

For each replica version that is either referred to in an SubnetRecord
of a subnet that is listed in the subnet list or that is contained
the BlessedReplicaVersions-List, the following is checked.

The corresponding ReplicaVersionRecord exists.
At least one of either the replica, orchestrator or release package is
specified.
Each set URL is well-formed.
Each set hash is a well-formed hex-encoded SHA256 value.
A predicate on the replica version records contained in a registry snapshot . For each replica version that is either referred to in an SubnetRecord of a subnet that is listed in the subnet list or that is contained the BlessedReplicaVersions - List the following is checked . The corresponding ReplicaVersionRecord exists . At least one of either the replica orchestrator or release package is specified . Each set URL is well - formed . Each set hash is a well - formed hex - encoded SHA256 value .
pub(crate) fn check_replica_version_invariants(
    snapshot: &RegistrySnapshot,
    strict: bool,
) -> Result<(), InvariantCheckError> {
    let mut versions = get_all_replica_versions_of_subnets(snapshot);
    let blessed_version_ids = snapshot
        .get(make_blessed_replica_version_key().as_bytes())
        .map(|bytes| {
            let version_list = decode_or_panic::<BlessedReplicaVersions>(bytes.clone());
            version_list.blessed_version_ids
        })
        .unwrap_or_else(Vec::default);
    versions.extend(blessed_version_ids);
    versions.dedup();
    // Check whether release package URL (iso image) and corresponding
    // hash is well-formed. As file-based URLs are only used in
    // test-deployments, we disallow file:/// URLs.
    if strict {
        for version in versions {
            let r = get_replica_version_record(snapshot, version);
            // An entry where all URLs are unspecified is invalid.
            if r.release_package_url.is_empty() {
                return Err(InvariantCheckError {
                    msg: "release package URL must be set".to_string(),
                    source: None,
                });
            }
            assert_valid_url_and_hash(&r.release_package_url, &r.release_package_sha256_hex, false);
        }
    }
    Ok(())
}
pub ( crate ) fn check_replica_version_invariants ( snapshot : & RegistrySnapshot , strict : bool , ) -> Result < ( ) , InvariantCheckError > { let mut versions = get_all_replica_versions_of_subnets ( snapshot ) ; let blessed_version_ids = snapshot . get ( make_blessed_replica_version_key ( ) . as_bytes ( ) ) . map ( | bytes | { let version_list = decode_or_panic :: < BlessedReplicaVersions > ( bytes . clone ( ) ) ; version_list . blessed_version_ids } ) . unwrap_or_else ( Vec :: default ) ; versions . extend ( blessed_version_ids ) ; versions . dedup ( ) ; // Check whether release package URL (iso image) and corresponding // hash is well-formed. As file-based URLs are only used in // test-deployments, we disallow file:/// URLs. if strict { for version in versions { let r = get_replica_version_record ( snapshot , version ) ; // An entry where all URLs are unspecified is invalid. if r . release_package_url . is_empty ( ) { return Err ( InvariantCheckError { msg : " " . to_string ( ) , source : None , } ) ; } assert_valid_url_and_hash ( & r . release_package_url , & r . release_package_sha256_hex , false ) ; } } Ok ( ( ) ) }
A predicate on the replica version records contained in a registry
snapshot.
A predicate on the replica version records contained in a registry snapshot .
snapshot
&RegistrySnapshot
strict
bool