Narrow packaged release API
This commit is contained in:
parent
cb611def86
commit
1e4fa53393
3 changed files with 13 additions and 20 deletions
|
|
@ -124,10 +124,7 @@ pub use packaged_release::{
|
|||
EpiphanyPackagedReleaseEntry, EpiphanyPackagedReleaseHead, PackageReleaseRequest,
|
||||
authenticate_epiphany_packaged_release, epiphany_packaged_release_binary_path,
|
||||
epiphany_packaged_release_witness_sha256, inspect_epiphany_packaged_release_witness,
|
||||
load_epiphany_packaged_release, package_epiphany_release,
|
||||
publish_epiphany_packaged_release, read_epiphany_packaged_release_witness,
|
||||
required_packaged_release_binaries, validate_epiphany_packaged_release,
|
||||
verify_epiphany_packaged_release_files, write_epiphany_packaged_release_witness,
|
||||
package_epiphany_release, publish_epiphany_packaged_release,
|
||||
};
|
||||
pub use persona_conversation::*;
|
||||
pub use persona_discord_crossing::*;
|
||||
|
|
|
|||
|
|
@ -53,15 +53,6 @@ pub fn publish_epiphany_packaged_release(
|
|||
Ok(entry)
|
||||
}
|
||||
|
||||
pub fn load_epiphany_packaged_release(
|
||||
store: &Path,
|
||||
runtime_id: &str,
|
||||
release_id: &str,
|
||||
) -> Result<Option<EpiphanyPackagedReleaseEntry>> {
|
||||
open_epiphany_cultmesh_node(store, runtime_id.to_string())?
|
||||
.get(&format!("{RELEASE_KEY_PREFIX}{release_id}"))
|
||||
}
|
||||
|
||||
pub fn authenticate_epiphany_packaged_release(
|
||||
store: &Path,
|
||||
runtime_id: &str,
|
||||
|
|
@ -69,7 +60,8 @@ pub fn authenticate_epiphany_packaged_release(
|
|||
expected_witness_sha256: &str,
|
||||
) -> Result<EpiphanyPackagedReleaseEntry> {
|
||||
validate_epiphany_packaged_release_sha256(expected_witness_sha256)?;
|
||||
let entry = load_epiphany_packaged_release(store, runtime_id, release_id)?
|
||||
let entry = open_epiphany_cultmesh_node(store, runtime_id.to_string())?
|
||||
.get::<EpiphanyPackagedReleaseEntry>(&format!("{RELEASE_KEY_PREFIX}{release_id}"))?
|
||||
.context("packaged release witness is absent")?;
|
||||
validate_epiphany_packaged_release(&entry)?;
|
||||
verify_epiphany_packaged_release_files(&entry)?;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ pub struct PackageReleaseRequest<'a> {
|
|||
pub target_triple: &'a str,
|
||||
}
|
||||
|
||||
pub fn required_packaged_release_binaries(target_triple: &str) -> Vec<(&'static str, String)> {
|
||||
fn required_packaged_release_binaries(target_triple: &str) -> Vec<(&'static str, String)> {
|
||||
let file_name = |name: &str| target_binary_file_name(target_triple, name);
|
||||
vec![
|
||||
("release-publisher", file_name("epiphany-release")),
|
||||
|
|
@ -572,7 +572,9 @@ fn release_bundle_target_dir(
|
|||
target_root.join(format!("graph-{:x}", digest.finalize()))
|
||||
}
|
||||
|
||||
pub fn validate_epiphany_packaged_release(entry: &EpiphanyPackagedReleaseEntry) -> Result<()> {
|
||||
pub(super) fn validate_epiphany_packaged_release(
|
||||
entry: &EpiphanyPackagedReleaseEntry,
|
||||
) -> Result<()> {
|
||||
if entry.schema_version != EPIPHANY_PACKAGED_RELEASE_SCHEMA_VERSION {
|
||||
bail!("unsupported packaged release schema");
|
||||
}
|
||||
|
|
@ -630,7 +632,9 @@ pub fn validate_epiphany_packaged_release(entry: &EpiphanyPackagedReleaseEntry)
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn verify_epiphany_packaged_release_files(entry: &EpiphanyPackagedReleaseEntry) -> Result<()> {
|
||||
pub(super) fn verify_epiphany_packaged_release_files(
|
||||
entry: &EpiphanyPackagedReleaseEntry,
|
||||
) -> Result<()> {
|
||||
validate_epiphany_packaged_release(entry)?;
|
||||
let root = canonical_path(&entry.package_root).context("packaged release root is absent")?;
|
||||
if root != PathBuf::from(&entry.package_root) {
|
||||
|
|
@ -672,7 +676,7 @@ pub fn verify_epiphany_packaged_release_files(entry: &EpiphanyPackagedReleaseEnt
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_epiphany_packaged_release_witness(
|
||||
fn write_epiphany_packaged_release_witness(
|
||||
path: &Path,
|
||||
entry: &EpiphanyPackagedReleaseEntry,
|
||||
) -> Result<()> {
|
||||
|
|
@ -686,7 +690,7 @@ pub fn write_epiphany_packaged_release_witness(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn read_epiphany_packaged_release_witness(path: &Path) -> Result<EpiphanyPackagedReleaseEntry> {
|
||||
fn read_epiphany_packaged_release_witness(path: &Path) -> Result<EpiphanyPackagedReleaseEntry> {
|
||||
let bytes = fs::read(path)
|
||||
.with_context(|| format!("failed to read packaged release witness {}", path.display()))?;
|
||||
let entry = rmp_serde::from_slice(&bytes).with_context(|| {
|
||||
|
|
@ -727,7 +731,7 @@ pub fn epiphany_packaged_release_witness_sha256(
|
|||
witness_sha256(entry)
|
||||
}
|
||||
|
||||
pub fn validate_epiphany_packaged_release_sha256(value: &str) -> Result<()> {
|
||||
pub(super) fn validate_epiphany_packaged_release_sha256(value: &str) -> Result<()> {
|
||||
validate_sha256(value)
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue