diff --git a/Cargo.toml b/Cargo.toml index dd91c587..577ed93c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,13 +20,13 @@ colorized = "1" derive_builder = "0.13" directories = "5" env_logger = "0.11" +format_serde_error = "0.3.0" futures-util = { version = "0.3", optional = true } fuzzy-matcher = "0.3" indexmap = { version = "2", features = ["serde"] } log = "0.4" open = "5" # update os module config and tests when upgrading os_info -shadow-rs = { version = "0.26" } os_info = "3.7" podman-api = { version = "0.10.0", optional = true } process_control = { version = "4.0.3", features = ["crossbeam-channel"] } @@ -34,13 +34,13 @@ requestty = { version = "0.5", features = ["macros", "termion"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde_yaml = "0.9.30" +shadow-rs = { version = "0.26" } sigstore = { version = "0.8.0", optional = true } tokio = { version = "1", features = ["full"], optional = true } typed-builder = "0.18.1" urlencoding = "2.1.3" users = "0.11.0" which = "6" -format_serde_error = "0.3.0" [features] default = [] diff --git a/src/commands/template.rs b/src/commands/template.rs index d6acafce..6d12d870 100644 --- a/src/commands/template.rs +++ b/src/commands/template.rs @@ -1,5 +1,5 @@ use std::{ - env, fs, + fs, path::{Path, PathBuf}, process, }; @@ -11,7 +11,7 @@ use log::{debug, error, info, trace}; use typed_builder::TypedBuilder; use crate::{ - constants::RECIPE_PATH, + constants::{self}, module_recipe::{Module, ModuleExt, Recipe}, }; @@ -58,7 +58,7 @@ impl BlueBuildCommand for TemplateCommand { "Templating for recipe at {}", self.recipe .clone() - .unwrap_or_else(|| PathBuf::from(RECIPE_PATH)) + .unwrap_or_else(|| PathBuf::from(constants::RECIPE_PATH)) .display() ); @@ -73,7 +73,7 @@ impl TemplateCommand { let recipe_path = self .recipe .clone() - .unwrap_or_else(|| PathBuf::from(RECIPE_PATH)); + .unwrap_or_else(|| PathBuf::from(constants::RECIPE_PATH)); debug!("Deserializing recipe"); let recipe_de = Recipe::parse(&recipe_path)?; @@ -126,9 +126,11 @@ fn print_script(script_contents: &ExportsTemplate) -> String { ) } -fn running_gitlab_actions() -> bool { - trace!(" running_gitlab_actions()"); - env::var("GITHUB_ACTIONS").is_ok_and(|e| e == "true") +fn has_cosign_file() -> bool { + trace!("has_cosign_file()"); + std::env::current_dir() + .map(|p| p.join(constants::COSIGN_PATH).exists()) + .unwrap_or(false) } #[must_use] diff --git a/src/module_recipe.rs b/src/module_recipe.rs index 970f6a7e..4a43b8fd 100644 --- a/src/module_recipe.rs +++ b/src/module_recipe.rs @@ -46,6 +46,7 @@ pub struct Recipe<'a> { } impl<'a> Recipe<'a> { + #[must_use] pub fn generate_tags(&self) -> Vec { trace!("Recipe::generate_tags()"); trace!("Generating image tags for {}", &self.name); @@ -231,7 +232,7 @@ impl ImageInspection { self.labels .get("org.opencontainers.image.version")? .as_str() - .map(|v| v.to_string())? + .map(std::string::ToString::to_string)? .split('.') .take(1) .collect(), diff --git a/templates/Containerfile b/templates/Containerfile index 23f26860..185a9d82 100644 --- a/templates/Containerfile +++ b/templates/Containerfile @@ -6,7 +6,7 @@ LABEL io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue- LABEL io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4 ARG RECIPE={{ recipe_path.display() }} -{%- if self::running_gitlab_actions() %} +{%- if self::has_cosign_file() %} ARG IMAGE_REGISTRY=ghcr.io/ublue-os COPY cosign.pub /usr/share/ublue-os/cosign.pub {%- endif %}