chore: Remove feature flags

This commit is contained in:
Gerald Pinder 2025-05-31 13:15:40 -04:00
parent 33bebb5e29
commit f67dea41a3
23 changed files with 69 additions and 305 deletions

View file

@ -19,7 +19,7 @@ nu-ansi-term = { version = "0.50", features = ["gnu_legacy"] }
os_pipe = { version = "1", features = ["io_safety"] }
rand = "0.9"
signal-hook = { version = "0.3", features = ["extended-siginfo"] }
sigstore = { version = "0.11", features = ["full-rustls-tls", "cached-client", "sigstore-trust-root", "sign"], default-features = false, optional = true }
sigstore = { version = "0.11", features = ["full-rustls-tls", "cached-client", "sigstore-trust-root", "sign"], default-features = false }
zeroize = { version = "1", features = ["aarch64", "derive", "serde"] }
cached.workspace = true
@ -38,7 +38,7 @@ semver.workspace = true
serde.workspace = true
serde_json.workspace = true
tempfile.workspace = true
tokio = { workspace = true, optional = true }
tokio.workspace = true
bon.workspace = true
users.workspace = true
uuid.workspace = true
@ -49,9 +49,3 @@ blue-build-utils = { version = "=0.9.12", path = "../utils", features = ["test"]
[lints]
workspace = true
[features]
sigstore = ["dep:tokio", "dep:sigstore"]
validate = ["dep:tokio"]
prune = []
rechunk = []

View file

@ -39,10 +39,9 @@ use crate::logging::Logger;
pub use self::{
buildah_driver::BuildahDriver, cosign_driver::CosignDriver, docker_driver::DockerDriver,
github_driver::GithubDriver, gitlab_driver::GitlabDriver, local_driver::LocalDriver,
podman_driver::PodmanDriver, skopeo_driver::SkopeoDriver, traits::*,
podman_driver::PodmanDriver, sigstore_driver::SigstoreDriver, skopeo_driver::SkopeoDriver,
traits::*,
};
#[cfg(feature = "sigstore")]
pub use sigstore_driver::SigstoreDriver;
mod buildah_driver;
mod cosign_driver;
@ -53,7 +52,6 @@ mod gitlab_driver;
mod local_driver;
pub mod opts;
mod podman_driver;
#[cfg(feature = "sigstore")]
mod sigstore_driver;
mod skopeo_driver;
mod traits;
@ -335,7 +333,6 @@ impl BuildDriver for Driver {
impl_build_driver!(login())
}
#[cfg(feature = "prune")]
fn prune(opts: &opts::PruneOpts) -> Result<()> {
impl_build_driver!(prune(opts))
}
@ -349,8 +346,6 @@ macro_rules! impl_signing_driver {
($func:ident($($args:expr),*)) => {
match Self::get_signing_driver() {
SigningDriverType::Cosign => CosignDriver::$func($($args,)*),
#[cfg(feature = "sigstore")]
SigningDriverType::Sigstore => SigstoreDriver::$func($($args,)*),
}
};
@ -476,7 +471,6 @@ impl CiDriver for Driver {
}
}
#[cfg(feature = "rechunk")]
impl ContainerMountDriver for Driver {
fn mount_container(opts: &opts::ContainerOpts) -> Result<types::MountId> {
PodmanDriver::mount_container(opts)
@ -491,14 +485,12 @@ impl ContainerMountDriver for Driver {
}
}
#[cfg(feature = "rechunk")]
impl OciCopy for Driver {
fn copy_oci_dir(opts: &opts::CopyOciDirOpts) -> Result<()> {
SkopeoDriver::copy_oci_dir(opts)
}
}
#[cfg(feature = "rechunk")]
impl RechunkDriver for Driver {
fn rechunk(opts: &opts::RechunkOpts) -> Result<Vec<String>> {
PodmanDriver::rechunk(opts)

View file

@ -23,13 +23,7 @@ struct BuildahVersionJson {
pub struct BuildahDriver;
impl DriverVersion for BuildahDriver {
// RUN mounts for bind, cache, and tmpfs first supported in 1.24.0
// https://buildah.io/releases/#changes-for-v1240
#[cfg(not(feature = "prune"))]
const VERSION_REQ: &'static str = ">=1.24";
// The prune command wasn't present until 1.29
#[cfg(feature = "prune")]
const VERSION_REQ: &'static str = ">=1.29";
fn version() -> Result<Version> {
@ -194,7 +188,6 @@ impl BuildDriver for BuildahDriver {
Ok(())
}
#[cfg(feature = "prune")]
fn prune(opts: &super::opts::PruneOpts) -> Result<()> {
trace!("PodmanDriver::prune({opts:?})");

View file

@ -233,7 +233,6 @@ mod test {
}
#[test]
#[cfg(feature = "sigstore")]
fn compatibility() {
use crate::drivers::sigstore_driver::SigstoreDriver;

View file

@ -321,7 +321,6 @@ impl BuildDriver for DockerDriver {
Ok(())
}
#[cfg(feature = "prune")]
fn prune(opts: &super::opts::PruneOpts) -> Result<()> {
trace!("DockerDriver::prune({opts:?})");

View file

@ -3,7 +3,6 @@ use clap::ValueEnum;
pub use build::*;
pub use ci::*;
pub use inspect::*;
#[cfg(feature = "rechunk")]
pub use rechunk::*;
pub use run::*;
pub use signing::*;
@ -11,7 +10,6 @@ pub use signing::*;
mod build;
mod ci;
mod inspect;
#[cfg(feature = "rechunk")]
mod rechunk;
mod run;
mod signing;

View file

@ -54,7 +54,6 @@ pub struct PushOpts<'scope> {
}
#[derive(Debug, Clone, Builder)]
#[cfg(feature = "prune")]
pub struct PruneOpts {
pub all: bool,
pub volumes: bool,

View file

@ -19,6 +19,11 @@ use oci_distribution::Reference;
use serde::Deserialize;
use tempfile::TempDir;
use super::{
ContainerMountDriver, RechunkDriver,
opts::{CreateContainerOpts, RemoveContainerOpts, RemoveImageOpts},
types::{ContainerId, MountId},
};
use crate::{
drivers::{
BuildDriver, DriverVersion, InspectDriver, RunDriver,
@ -29,13 +34,6 @@ use crate::{
signal_handler::{ContainerRuntime, ContainerSignalId, add_cid, remove_cid},
};
#[cfg(feature = "rechunk")]
use super::{ContainerMountDriver, RechunkDriver, types::MountId};
use super::{
opts::{CreateContainerOpts, RemoveContainerOpts, RemoveImageOpts},
types::ContainerId,
};
const SUDO_PROMPT: &str = "Password for %u required to run 'podman' as privileged";
#[derive(Deserialize, Debug, Clone)]
@ -305,7 +303,6 @@ impl BuildDriver for PodmanDriver {
Ok(())
}
#[cfg(feature = "prune")]
fn prune(opts: &super::opts::PruneOpts) -> Result<()> {
trace!("PodmanDriver::prune({opts:?})");
@ -402,7 +399,6 @@ fn get_metadata_cache(opts: &GetMetadataOpts) -> Result<ImageMetadata> {
.inspect(|metadata| trace!("{metadata:#?}"))
}
#[cfg(feature = "rechunk")]
impl ContainerMountDriver for PodmanDriver {
fn mount_container(opts: &super::opts::ContainerOpts) -> Result<MountId> {
let use_sudo = opts.privileged && !running_as_root();
@ -501,7 +497,6 @@ impl ContainerMountDriver for PodmanDriver {
}
}
#[cfg(feature = "rechunk")]
impl RechunkDriver for PodmanDriver {}
impl RunDriver for PodmanDriver {

View file

@ -63,7 +63,6 @@ fn get_metadata_cache(opts: &GetMetadataOpts) -> Result<ImageMetadata> {
serde_json::from_slice(&output.stdout).into_diagnostic()
}
#[cfg(feature = "rechunk")]
impl super::OciCopy for SkopeoDriver {
fn copy_oci_dir(opts: &super::opts::CopyOciDirOpts) -> Result<()> {
use crate::logging::CommandLogging;

View file

@ -16,8 +16,6 @@ use crate::drivers::{
types::{CiDriverType, ImageRef},
};
#[cfg(feature = "sigstore")]
use super::sigstore_driver::SigstoreDriver;
use super::{
buildah_driver::BuildahDriver,
cosign_driver::CosignDriver,
@ -27,15 +25,15 @@ use super::{
local_driver::LocalDriver,
opts::{
BuildOpts, BuildTagPushOpts, CheckKeyPairOpts, CreateContainerOpts, GenerateImageNameOpts,
GenerateKeyPairOpts, GenerateTagsOpts, GetMetadataOpts, PushOpts, RemoveContainerOpts,
RemoveImageOpts, RunOpts, SignOpts, SignVerifyOpts, TagOpts, VerifyOpts, VerifyType,
GenerateKeyPairOpts, GenerateTagsOpts, GetMetadataOpts, PushOpts, RechunkOpts,
RemoveContainerOpts, RemoveImageOpts, RunOpts, SignOpts, SignVerifyOpts, TagOpts,
VerifyOpts, VerifyType,
},
podman_driver::PodmanDriver,
sigstore_driver::SigstoreDriver,
skopeo_driver::SkopeoDriver,
types::{ContainerId, ImageMetadata},
types::{ContainerId, ImageMetadata, MountId},
};
#[cfg(feature = "rechunk")]
use super::{opts::RechunkOpts, types::MountId};
trait PrivateDriver {}
@ -58,11 +56,9 @@ impl_private_driver!(
CosignDriver,
SkopeoDriver,
CiDriverType,
SigstoreDriver,
);
#[cfg(feature = "sigstore")]
impl_private_driver!(SigstoreDriver);
/// Trait for retrieving version of a driver.
#[allow(private_bounds)]
pub trait DriverVersion: PrivateDriver {
@ -116,7 +112,6 @@ pub trait BuildDriver: PrivateDriver {
///
/// # Errors
/// Will error if the driver fails to prune.
#[cfg(feature = "prune")]
fn prune(opts: &super::opts::PruneOpts) -> Result<()>;
/// Runs the logic for building, tagging, and pushing an image.
@ -240,7 +235,6 @@ pub trait RunDriver: PrivateDriver {
}
#[allow(private_bounds)]
#[cfg(feature = "rechunk")]
pub(super) trait ContainerMountDriver: PrivateDriver {
/// Mounts the container
///
@ -261,13 +255,11 @@ pub(super) trait ContainerMountDriver: PrivateDriver {
fn remove_volume(opts: &super::opts::VolumeOpts) -> Result<()>;
}
#[cfg(feature = "rechunk")]
pub(super) trait OciCopy {
fn copy_oci_dir(opts: &super::opts::CopyOciDirOpts) -> Result<()>;
}
#[allow(private_bounds)]
#[cfg(feature = "rechunk")]
pub trait RechunkDriver: RunDriver + BuildDriver + ContainerMountDriver {
const RECHUNK_IMAGE: &str = "ghcr.io/hhd-dev/rechunk:v1.0.1";

View file

@ -99,7 +99,6 @@ impl DetermineDriver<BuildDriverType> for Option<BuildDriverType> {
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum SigningDriverType {
Cosign,
#[cfg(feature = "sigstore")]
Sigstore,
}
@ -107,18 +106,10 @@ impl DetermineDriver<SigningDriverType> for Option<SigningDriverType> {
fn determine_driver(&mut self) -> SigningDriverType {
trace!("SigningDriverType::determine_signing_driver()");
#[cfg(feature = "sigstore")]
{
*self.get_or_insert(
blue_build_utils::check_command_exists("cosign")
.map_or(SigningDriverType::Sigstore, |()| SigningDriverType::Cosign),
)
}
#[cfg(not(feature = "sigstore"))]
{
SigningDriverType::Cosign
}
*self.get_or_insert(
blue_build_utils::check_command_exists("cosign")
.map_or(SigningDriverType::Sigstore, |()| SigningDriverType::Cosign),
)
}
}
@ -272,49 +263,41 @@ impl AsRef<std::ffi::OsStr> for ContainerId {
}
}
#[cfg(feature = "rechunk")]
pub struct MountId(pub(super) String);
#[cfg(feature = "rechunk")]
impl std::fmt::Display for MountId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", &self.0)
}
}
#[cfg(feature = "rechunk")]
impl AsRef<std::ffi::OsStr> for MountId {
fn as_ref(&self) -> &std::ffi::OsStr {
self.0.as_ref()
}
}
#[cfg(feature = "rechunk")]
impl<'a> From<&'a MountId> for std::borrow::Cow<'a, str> {
fn from(value: &'a MountId) -> Self {
Self::Borrowed(&value.0)
}
}
#[cfg(feature = "rechunk")]
#[derive(Debug, Clone)]
pub struct OciDir(String);
#[cfg(feature = "rechunk")]
impl std::fmt::Display for OciDir {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", &self.0)
}
}
#[cfg(feature = "rechunk")]
impl AsRef<std::ffi::OsStr> for OciDir {
fn as_ref(&self) -> &std::ffi::OsStr {
self.0.as_ref()
}
}
#[cfg(feature = "rechunk")]
impl TryFrom<std::path::PathBuf> for OciDir {
type Error = miette::Report;

View file

@ -6,7 +6,6 @@ pub mod drivers;
pub mod logging;
pub mod signal_handler;
#[cfg(any(feature = "sigstore", feature = "validate"))]
pub static ASYNC_RUNTIME: std::sync::LazyLock<tokio::runtime::Runtime> =
std::sync::LazyLock::new(|| {
tokio::runtime::Builder::new_multi_thread()