-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stores/restores the solution's 'requested by' data into/from the spfs…
… runtime Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
- Loading branch information
Showing
9 changed files
with
176 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
crates/spk-solve/crates/solution/src/package_solve_data.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Sony Pictures Imageworks, et al. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// https://github.com/imageworks/spk | ||
use std::collections::BTreeMap; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use spk_schema::ident::RequestedBy; | ||
use spk_schema::BuildIdent; | ||
|
||
/// Key for extra data stored in spfs runtimes by spk when creating a | ||
/// runtime and read back in by spk commands run inside that spfs/spk | ||
/// environment. | ||
pub const SPK_SOLVE_EXTRA_DATA_KEY: &str = "SPK_solve"; | ||
|
||
/// Current data structure version number for PackageToSolveData | ||
pub const PACKAGE_TO_SOLVE_DATA_VERSION: u32 = 1; | ||
|
||
/// Holds the extra solve related data for a package | ||
#[derive(Clone, Debug, Serialize, Deserialize, Default)] | ||
pub struct PackageSolveData { | ||
/// What a resolved package was requested by | ||
pub requested_by: Vec<RequestedBy>, | ||
/// Name of the repo the resolve package was found in. Optional | ||
/// because embedded packages will have not have source repos. | ||
pub source_repo_name: Option<String>, | ||
} | ||
|
||
/// The extra solve data for all the resolve packages for saving in | ||
/// the spfs runtime's created by spk after a solver run | ||
#[derive(Default, Serialize, Deserialize)] | ||
pub struct PackagesToSolveData { | ||
/// For tracking data structure changes | ||
version: u32, | ||
/// Resolved package id to solve data mapping | ||
data: BTreeMap<BuildIdent, PackageSolveData>, | ||
} | ||
|
||
impl PackagesToSolveData { | ||
pub fn get(&self, key: &BuildIdent) -> Option<&PackageSolveData> { | ||
self.data.get(key) | ||
} | ||
} | ||
|
||
impl From<BTreeMap<BuildIdent, PackageSolveData>> for PackagesToSolveData { | ||
fn from(data: BTreeMap<BuildIdent, PackageSolveData>) -> Self { | ||
let version = PACKAGE_TO_SOLVE_DATA_VERSION; | ||
PackagesToSolveData { version, data } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters