Skip to content

Commit

Permalink
Fix illegal env vars
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Bottriell <rbottriell@ilm.com>
  • Loading branch information
Krisha Iquin authored and rydrman committed Jul 12, 2023
1 parent c55abbb commit ce7b3c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions crates/spk-schema/crates/foundation/src/spec_ops/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ use crate::name::PkgName;
pub trait Named {
/// The name of the associated package
fn name(&self) -> &PkgName;
/// Valid env var of the associated package
fn env_name(&self) -> String {
self.name().replace('-', "_")
}
}

impl<T: Named> Named for Arc<T> {
Expand Down
17 changes: 10 additions & 7 deletions crates/spk-solve/crates/solution/src/solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,29 +252,32 @@ impl Solution {
out.insert("SPK_ACTIVE_PREFIX".to_owned(), "/spfs".to_owned());
for resolved in self.resolved.iter() {
let spec = &resolved.spec;
out.insert(format!("SPK_PKG_{}", spec.name()), spec.ident().to_string());
out.insert(
format!("SPK_PKG_{}_VERSION", spec.name()),
format!("SPK_PKG_{}", spec.env_name()),
spec.ident().to_string(),
);
out.insert(
format!("SPK_PKG_{}_VERSION", spec.env_name()),
spec.version().to_string(),
);
out.insert(
format!("SPK_PKG_{}_BUILD", spec.name()),
format!("SPK_PKG_{}_BUILD", spec.env_name()),
spec.ident().build().to_string(),
);
out.insert(
format!("SPK_PKG_{}_VERSION_MAJOR", spec.name()),
format!("SPK_PKG_{}_VERSION_MAJOR", spec.env_name()),
spec.version().major().to_string(),
);
out.insert(
format!("SPK_PKG_{}_VERSION_MINOR", spec.name()),
format!("SPK_PKG_{}_VERSION_MINOR", spec.env_name()),
spec.version().minor().to_string(),
);
out.insert(
format!("SPK_PKG_{}_VERSION_PATCH", spec.name()),
format!("SPK_PKG_{}_VERSION_PATCH", spec.env_name()),
spec.version().patch().to_string(),
);
out.insert(
format!("SPK_PKG_{}_VERSION_BASE", spec.name()),
format!("SPK_PKG_{}_VERSION_BASE", spec.env_name()),
spec.version()
.parts
.iter()
Expand Down

0 comments on commit ce7b3c9

Please sign in to comment.