Skip to content

Commit 8530adc

Browse files
committed
Adds new Indexed repository type, related RepositoryIndex traits, and flabuffers index and configuration
Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
1 parent 47ea722 commit 8530adc

File tree

19 files changed

+2784
-175
lines changed

19 files changed

+2784
-175
lines changed

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ indicatif = "0.17.8"
7777
is_default_derive_macro = { path = "crates/is_default_derive_macro" }
7878
itertools = "0.14"
7979
libc = "0.2.172"
80+
memmap2 = "0.9.10"
8081
miette = "7.0"
8182
nix = { version = "0.29", features = ["mount", "sched", "user"] }
8283
nom = "7.1"

crates/spk-build/src/archive_test.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ async fn test_archive_create_parents(#[case] solver: SolverImpl) {
4040
let filename = rt.tmpdir.path().join("deep/nested/path/archive.spk");
4141
let repo = match &*rt.tmprepo {
4242
spk_solve::RepositoryHandle::SPFS(repo) => repo,
43-
spk_solve::RepositoryHandle::Mem(_) | spk_solve::RepositoryHandle::Runtime(_) => {
43+
spk_solve::RepositoryHandle::Mem(_)
44+
| spk_solve::RepositoryHandle::Runtime(_)
45+
| spk_solve::RepositoryHandle::Indexed(_) => {
4446
panic!("only spfs repositories are supported")
4547
}
4648
};

crates/spk-cli/group3/src/cmd_export.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ impl Run for Export {
5252
.iter()
5353
.map(|repo| match &**repo {
5454
storage::RepositoryHandle::SPFS(repo) => Ok(repo),
55-
storage::RepositoryHandle::Mem(_) | storage::RepositoryHandle::Runtime(_) => {
55+
storage::RepositoryHandle::Mem(_)
56+
| storage::RepositoryHandle::Runtime(_)
57+
| storage::RepositoryHandle::Indexed(_) => {
5658
bail!("Only spfs repositories are supported")
5759
}
5860
})

crates/spk-cli/group3/src/cmd_import_test.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ async fn test_archive_io(#[case] solver: SolverImpl) {
4242
filename.ensure();
4343
let repo = match &*rt.tmprepo {
4444
spk_solve::RepositoryHandle::SPFS(repo) => repo,
45-
spk_solve::RepositoryHandle::Mem(_) | spk_solve::RepositoryHandle::Runtime(_) => {
45+
spk_solve::RepositoryHandle::Mem(_)
46+
| spk_solve::RepositoryHandle::Runtime(_)
47+
| spk_solve::RepositoryHandle::Indexed(_) => {
4648
panic!("only spfs repositories are supported")
4749
}
4850
};

crates/spk-config/src/config.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,36 @@ pub struct Solver {
8787

8888
/// Name of the solver whose output to show when multiple solvers are being run.
8989
pub solver_to_show: String,
90+
91+
/// Whether to get the solver to use repository indexes instead of
92+
/// the repository directly.
93+
pub use_indexes: bool,
94+
95+
/// What kinds of index to use. Only applies if there is more than
96+
/// one kinds of index available for the repositories. The default
97+
/// is 'flatb', a flatbuffers file based index.
98+
pub index_kind: String,
99+
100+
/// Whether to validate flatbuffers index data before using it.
101+
/// Validating is safer but adds some overhead at the start of a
102+
/// solve when using an index.
103+
pub verify_flatbuffers_index_before_use: bool,
104+
}
105+
106+
// /// A map of repositories, name to settings
107+
// #[derive(Clone, Default, Debug, Deserialize, Serialize)]
108+
// #[serde(default)]
109+
// pub struct Repositories {
110+
// pub repositories: HashMap<String, Repository>,
111+
// }
112+
113+
/// The settings for a single repository
114+
#[derive(Clone, Default, Debug, Deserialize, Serialize)]
115+
#[serde(default)]
116+
pub struct Repository {
117+
/// Whether to use an index with this repository, if one is
118+
/// available.
119+
pub use_index: bool,
90120
}
91121

92122
#[derive(Clone, Default, Debug, Deserialize, Serialize)]
@@ -142,6 +172,7 @@ pub struct Config {
142172
// with environment variables.
143173
pub sentry: Sentry,
144174
pub solver: Solver,
175+
pub repositories: HashMap<String, Repository>,
145176
pub statsd: Statsd,
146177
pub metadata: Metadata,
147178
pub cli: Cli,

0 commit comments

Comments
 (0)