fix: Parse Version from container and remove ostree commit
This commit is contained in:
parent
783b9cb2d6
commit
33bebb5e29
16 changed files with 30 additions and 30 deletions
|
|
@ -41,4 +41,4 @@ modules:
|
|||
containerfiles:
|
||||
- labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ modules:
|
|||
containerfiles:
|
||||
- labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
||||
- type: copy
|
||||
from: alpine-test
|
||||
|
|
|
|||
|
|
@ -44,4 +44,4 @@ modules:
|
|||
containerfiles:
|
||||
- labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ modules:
|
|||
containerfiles:
|
||||
- labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
||||
- type: copy
|
||||
from: alpine-test
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ modules:
|
|||
containerfiles:
|
||||
labels: labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
||||
- type: copy
|
||||
from: alpine-test
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ modules:
|
|||
containerfiles:
|
||||
- labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
||||
- type: copy
|
||||
from: alpine-test
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ modules:
|
|||
containerfiles:
|
||||
- labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
||||
- type: copy
|
||||
from: alpine-test
|
||||
|
|
|
|||
|
|
@ -14,13 +14,14 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
use blue_build_utils::semver::Version;
|
||||
use bon::{Builder, bon};
|
||||
use cached::proc_macro::cached;
|
||||
use clap::Args;
|
||||
use colored::Colorize;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use log::{info, trace, warn};
|
||||
use miette::{IntoDiagnostic, Result, miette};
|
||||
use miette::{Result, miette};
|
||||
use oci_distribution::Reference;
|
||||
use opts::{
|
||||
BuildOpts, BuildTagPushOpts, CheckKeyPairOpts, CreateContainerOpts, GenerateImageNameOpts,
|
||||
|
|
@ -216,6 +217,7 @@ impl Driver {
|
|||
.build(),
|
||||
)
|
||||
.and_then(|inspection| {
|
||||
trace!("{inspection:?}");
|
||||
inspection.get_version().ok_or_else(|| {
|
||||
miette!(
|
||||
"Failed to parse version from metadata for {}",
|
||||
|
|
@ -300,10 +302,10 @@ fn get_version_run_image(oci_ref: &Reference) -> Result<u64> {
|
|||
progress.finish_and_clear();
|
||||
Logger::multi_progress().remove(&progress);
|
||||
|
||||
String::from_utf8_lossy(&output.stdout)
|
||||
Ok(String::from_utf8_lossy(&output.stdout)
|
||||
.trim()
|
||||
.parse()
|
||||
.into_diagnostic()
|
||||
.parse::<Version>()?
|
||||
.major)
|
||||
}
|
||||
|
||||
macro_rules! impl_build_driver {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use blue_build_utils::{
|
|||
semver::Version,
|
||||
};
|
||||
use clap::ValueEnum;
|
||||
use log::trace;
|
||||
use log::{trace, warn};
|
||||
use oci_distribution::Reference;
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
|
@ -247,7 +247,11 @@ impl ImageMetadata {
|
|||
self.labels
|
||||
.get(IMAGE_VERSION_LABEL)
|
||||
.map(ToOwned::to_owned)
|
||||
.and_then(|v| serde_json::from_value::<Version>(v).ok())?
|
||||
.and_then(|v| {
|
||||
serde_json::from_value::<Version>(v)
|
||||
.inspect_err(|e| warn!("Failed to parse version:\n{e}"))
|
||||
.ok()
|
||||
})?
|
||||
.major,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,4 +3,3 @@
|
|||
set -euo pipefail
|
||||
|
||||
rm -rf /tmp/* /var/*
|
||||
ostree container commit
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
set -euo pipefail
|
||||
|
||||
if ! command -v jq > /dev/null; then
|
||||
rpm-ostree install jq
|
||||
if command -v rpm-ostree > /dev/null; then
|
||||
rpm-ostree install jq
|
||||
else
|
||||
dnf -y install jq
|
||||
fi
|
||||
fi
|
||||
|
||||
ostree container commit
|
||||
|
|
|
|||
|
|
@ -66,7 +66,3 @@ else
|
|||
color_string "$(print_banner "Failed '${module}' Module")" "31"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if command -v ostree > /dev/null; then
|
||||
ostree container commit
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ mod test {
|
|||
#[case(RECIPE, "/description", (109, 29))]
|
||||
#[case(RECIPE, "/image-version", (199, 6))]
|
||||
#[case(RECIPE, "/modules/4/source", (761, 5))]
|
||||
#[case(RECIPE, "/modules/8/from", (1067, 11))]
|
||||
#[case(RECIPE, "/modules/8/from", (1040, 11))]
|
||||
#[case(RECIPE_INVALID, "/image-version", (199, 6))]
|
||||
fn test_getspan(#[case] file: &str, #[case] path: &str, #[case] expected: (usize, usize)) {
|
||||
dbg!(path, expected);
|
||||
|
|
|
|||
|
|
@ -26,20 +26,17 @@ ARG RUST_LOG_STYLE=always
|
|||
# Key RUN
|
||||
RUN --mount=type=bind,from=stage-keys,src=/keys,dst=/tmp/keys \
|
||||
mkdir -p /etc/pki/containers/ \
|
||||
&& cp /tmp/keys/* /etc/pki/containers/ \
|
||||
&& ostree container commit
|
||||
&& cp /tmp/keys/* /etc/pki/containers/
|
||||
|
||||
# Bin RUN
|
||||
RUN --mount=type=bind,from=stage-bins,src=/bins,dst=/tmp/bins \
|
||||
mkdir -p /usr/bin/ \
|
||||
&& cp /tmp/bins/* /usr/bin/ \
|
||||
&& ostree container commit
|
||||
&& cp /tmp/bins/* /usr/bin/
|
||||
|
||||
{%- if should_install_nu() %}
|
||||
RUN --mount=type=bind,from={{ blue_build_utils::constants::NUSHELL_IMAGE }}:{{ get_nu_version() }},src=/nu,dst=/tmp/nu \
|
||||
mkdir -p /usr/libexec/bluebuild/nu \
|
||||
&& cp -r /tmp/nu/* /usr/libexec/bluebuild/nu/ \
|
||||
&& ostree container commit
|
||||
&& cp -r /tmp/nu/* /usr/libexec/bluebuild/nu/
|
||||
{%- endif %}
|
||||
|
||||
RUN --mount=type=bind,from={{ build_scripts_image }},src=/scripts/,dst=/scripts/ \
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ modules:
|
|||
- type: containerfile
|
||||
containerfiles: labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
||||
- type: copy
|
||||
from: alpine-test
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ modules:
|
|||
containerfiles:
|
||||
- labels
|
||||
snippets:
|
||||
- RUN echo "This is a snippet" && ostree container commit
|
||||
- RUN echo "This is a snippet"
|
||||
|
||||
- type: copy
|
||||
from: alpine-test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue