fix: Use lenient_semver for build drivers version check to handle pre-release versions
This commit is contained in:
parent
e88c7561a9
commit
003e473de1
11 changed files with 66 additions and 26 deletions
|
|
@ -14,7 +14,6 @@ path = "process.rs"
|
|||
anyhow = "1"
|
||||
blue-build-utils = { version = "=0.9.6", path = "../utils" }
|
||||
indicatif-log-bridge = "0.2"
|
||||
lenient_semver = "0.4"
|
||||
log4rs = { version = "1", features = ["background_rotation"] }
|
||||
nu-ansi-term = { version = "0.50", features = ["gnu_legacy"] }
|
||||
once_cell = "1"
|
||||
|
|
@ -36,7 +35,7 @@ miette.workspace = true
|
|||
nix = { workspace = true, features = ["signal", "user"] }
|
||||
oci-distribution.workspace = true
|
||||
reqwest.workspace = true
|
||||
semver = { workspace = true, features = ["serde"] }
|
||||
semver.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
tempfile.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
use std::{io::Write, process::Stdio};
|
||||
|
||||
use blue_build_utils::credentials::Credentials;
|
||||
use blue_build_utils::{credentials::Credentials, semver::Version};
|
||||
use colored::Colorize;
|
||||
use comlexr::cmd;
|
||||
use log::{debug, error, info, trace};
|
||||
use miette::{bail, miette, IntoDiagnostic, Result};
|
||||
use semver::Version;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{drivers::types::Platform, logging::CommandLogging};
|
||||
|
|
@ -36,10 +35,13 @@ impl DriverVersion for BuildahDriver {
|
|||
fn version() -> Result<Version> {
|
||||
trace!("BuildahDriver::version()");
|
||||
|
||||
trace!("buildah version --json");
|
||||
let output = cmd!("buildah", "version", "--json")
|
||||
.output()
|
||||
.into_diagnostic()?;
|
||||
let output = {
|
||||
let c = cmd!("buildah", "version", "--json");
|
||||
trace!("{c:?}");
|
||||
c
|
||||
}
|
||||
.output()
|
||||
.into_diagnostic()?;
|
||||
|
||||
let version_json: BuildahVersionJson = serde_json::from_slice(&output.stdout)
|
||||
.inspect_err(|e| error!("{e}: {}", String::from_utf8_lossy(&output.stdout)))
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use std::{
|
|||
use blue_build_utils::{
|
||||
constants::{BB_BUILDKIT_CACHE_GHA, DOCKER_HOST, GITHUB_ACTIONS},
|
||||
credentials::Credentials,
|
||||
semver::Version,
|
||||
string_vec,
|
||||
};
|
||||
use cached::proc_macro::cached;
|
||||
|
|
@ -17,7 +18,6 @@ use log::{debug, info, trace, warn};
|
|||
use miette::{bail, IntoDiagnostic, Result};
|
||||
use oci_distribution::Reference;
|
||||
use once_cell::sync::Lazy;
|
||||
use semver::Version;
|
||||
use serde::Deserialize;
|
||||
use tempfile::TempDir;
|
||||
|
||||
|
|
@ -124,6 +124,8 @@ impl DriverVersion for DockerDriver {
|
|||
const VERSION_REQ: &'static str = ">=23";
|
||||
|
||||
fn version() -> Result<Version> {
|
||||
trace!("DockerDriver::version()");
|
||||
|
||||
let output = {
|
||||
let c = cmd!("docker", "version", "-f", "json");
|
||||
trace!("{c:?}");
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
use blue_build_utils::credentials::Credentials;
|
||||
use blue_build_utils::{credentials::Credentials, semver::Version};
|
||||
use cached::proc_macro::cached;
|
||||
use colored::Colorize;
|
||||
use comlexr::{cmd, pipe};
|
||||
|
|
@ -13,7 +13,6 @@ use indicatif::{ProgressBar, ProgressStyle};
|
|||
use log::{debug, error, info, trace};
|
||||
use miette::{bail, miette, IntoDiagnostic, Report, Result};
|
||||
use oci_distribution::Reference;
|
||||
use semver::Version;
|
||||
use serde::Deserialize;
|
||||
use tempfile::TempDir;
|
||||
|
||||
|
|
@ -114,10 +113,13 @@ impl DriverVersion for PodmanDriver {
|
|||
fn version() -> Result<Version> {
|
||||
trace!("PodmanDriver::version()");
|
||||
|
||||
trace!("podman version -f json");
|
||||
let output = cmd!("podman", "version", "-f", "json")
|
||||
.output()
|
||||
.into_diagnostic()?;
|
||||
let output = {
|
||||
let c = cmd!("podman", "version", "-f", "json");
|
||||
trace!("{c:?}");
|
||||
c
|
||||
}
|
||||
.output()
|
||||
.into_diagnostic()?;
|
||||
|
||||
let version_json: PodmanVersionJson = serde_json::from_slice(&output.stdout)
|
||||
.inspect_err(|e| error!("{e}: {}", String::from_utf8_lossy(&output.stdout)))
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ use std::{
|
|||
process::{ExitStatus, Output},
|
||||
};
|
||||
|
||||
use blue_build_utils::{constants::COSIGN_PUB_PATH, retry, string_vec};
|
||||
use blue_build_utils::{constants::COSIGN_PUB_PATH, retry, semver::Version, string_vec};
|
||||
use log::{debug, info, trace};
|
||||
use miette::{bail, Context, IntoDiagnostic, Result};
|
||||
use oci_distribution::Reference;
|
||||
use semver::{Version, VersionReq};
|
||||
use semver::VersionReq;
|
||||
|
||||
use crate::drivers::{functions::get_private_key, types::CiDriverType, Driver};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
use std::{collections::HashMap, env};
|
||||
|
||||
use blue_build_utils::constants::{GITHUB_ACTIONS, GITLAB_CI, IMAGE_VERSION_LABEL};
|
||||
use blue_build_utils::{
|
||||
constants::{GITHUB_ACTIONS, GITLAB_CI, IMAGE_VERSION_LABEL},
|
||||
semver::Version,
|
||||
};
|
||||
use clap::ValueEnum;
|
||||
use log::trace;
|
||||
use serde::Deserialize;
|
||||
|
|
@ -233,9 +236,9 @@ impl ImageMetadata {
|
|||
pub fn get_version(&self) -> Option<u64> {
|
||||
Some(
|
||||
self.labels
|
||||
.get(IMAGE_VERSION_LABEL)?
|
||||
.as_str()
|
||||
.and_then(|v| lenient_semver::parse(v).ok())?
|
||||
.get(IMAGE_VERSION_LABEL)
|
||||
.map(ToOwned::to_owned)
|
||||
.and_then(|v| serde_json::from_value::<Version>(v).ok())?
|
||||
.major,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue