Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update containerfile to check for presence of cosign.pub #46

Merged
merged 6 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ 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"] }
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 = []
Expand Down
16 changes: 9 additions & 7 deletions src/commands/template.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
env, fs,
fs,
path::{Path, PathBuf},
process,
};
Expand All @@ -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},
};

Expand Down Expand Up @@ -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()
);

Expand All @@ -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)?;
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion src/module_recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub struct Recipe<'a> {
}

impl<'a> Recipe<'a> {
#[must_use]
pub fn generate_tags(&self) -> Vec<String> {
trace!("Recipe::generate_tags()");
trace!("Generating image tags for {}", &self.name);
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion templates/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
Loading