Skip to content

Commit

Permalink
Change SPK_REQUEST_PRIORITY_ORDER to use spk config
Browse files Browse the repository at this point in the history
Pull the default value for this, if any, from the spk config file.
Remove custom env var name in lieu of using the standard method of
setting config settings via env vars.

Signed-off-by: J Robert Ray <jrray@jrray.org>
  • Loading branch information
jrray authored and J Robert Ray committed Aug 22, 2023
1 parent 0fee1ff commit f1873ef
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .site/spi/spk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ username_override_var = "GITLAB_USER_LOGIN"

[solver]
build_key_name_order = "gcc,python"
request_priority_order = "*platform*"

[statsd]
host = "statsd.k8s.spimageworks.com"
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/spk-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ pub struct Solver {
/// Comma-separated list of option names to promote to the front of the
/// build key order.
pub build_key_name_order: String,

/// Comma-separated list of option names to promote to the front of the
/// resolve order.
pub request_priority_order: String,
}

#[derive(Clone, Default, Debug, Deserialize, Serialize)]
Expand Down
10 changes: 6 additions & 4 deletions crates/spk-solve/crates/graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ version = { workspace = true }

[features]
migration-to-components = [
"spk-solve-package-iterator/migration-to-components",
"spk-solve-solution/migration-to-components",
"spk-schema/migration-to-components",
"spk-storage/migration-to-components",
"spk-config/migration-to-components",
"spk-solve-package-iterator/migration-to-components",
"spk-solve-solution/migration-to-components",
"spk-schema/migration-to-components",
"spk-storage/migration-to-components",
]

[dependencies]
Expand All @@ -25,6 +26,7 @@ once_cell = { workspace = true }
priority-queue = "1.2"
serde_json = { workspace = true }
spfs = { path = "../../../spfs" }
spk-config = { path = "../../../spk-config" }
spk-solve-package-iterator = { path = "../package-iterator" }
spk-solve-solution = { path = "../solution" }
spk-schema = { path = "../../../spk-schema" }
Expand Down
7 changes: 3 additions & 4 deletions crates/spk-solve/crates/graph/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use std::collections::hash_map::{DefaultHasher, Entry};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::ffi::OsString;
use std::hash::{Hash, Hasher};
use std::iter::FromIterator;
use std::sync::atomic::{AtomicU64, Ordering};
Expand Down Expand Up @@ -48,9 +47,9 @@ const BRANCH_ALREADY_ATTEMPTED: &str = "Branch already attempted";
/// front of the request list.
static REQUESTS_PRIORITY_ORDER: Lazy<PromotionPatterns> = Lazy::new(|| {
PromotionPatterns::new(
std::env::var_os("SPK_REQUEST_PRIORITY_ORDER")
.unwrap_or_else(|| OsString::from("*platform*"))
.to_string_lossy()
spk_config::get_config()
.map(|c| c.solver.request_priority_order.clone())
.unwrap_or_else(|_| "".to_string())

Check warning on line 52 in crates/spk-solve/crates/graph/src/graph.rs

View check run for this annotation

Codecov / codecov/patch

crates/spk-solve/crates/graph/src/graph.rs#L52

Added line #L52 was not covered by tests
.as_ref(),
)
});
Expand Down

0 comments on commit f1873ef

Please sign in to comment.