feat(iso): Create generate-iso command (#192)

## Tasks

- [x] Add ctrl-c handler to kill spawned children
- [x] add more args to support all variables
- [x] Add integration test
This commit is contained in:
Gerald Pinder 2024-09-04 18:17:08 -04:00 committed by GitHub
parent 4634f40840
commit e6cce3d542
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 737 additions and 201 deletions

View file

@ -14,6 +14,7 @@ blue-build-utils = { version = "=0.8.14", path = "../utils" }
colored.workspace = true
log.workspace = true
miette.workspace = true
oci-distribution.workspace = true
indexmap.workspace = true
serde.workspace = true
serde_yaml.workspace = true

View file

@ -1,8 +1,10 @@
use std::{borrow::Cow, fs, path::Path};
use blue_build_utils::cowstr;
use indexmap::IndexMap;
use log::{debug, trace};
use miette::{Context, IntoDiagnostic, Result};
use oci_distribution::Reference;
use serde::{Deserialize, Serialize};
use serde_yaml::Value;
use typed_builder::TypedBuilder;
@ -53,7 +55,7 @@ pub struct Recipe<'a> {
/// Any user input will override the `latest` and timestamp tags.
#[serde(alias = "alt-tags", skip_serializing_if = "Option::is_none")]
#[builder(default, setter(into, strip_option))]
pub alt_tags: Option<Vec<Cow<'a, str>>>,
alt_tags: Option<Vec<Cow<'a, str>>>,
/// The stages extension of the recipe.
///
@ -118,4 +120,22 @@ impl<'a> Recipe<'a> {
Ok(recipe)
}
/// Get a `Reference` object of the `base_image`.
///
/// # Errors
/// Will error if it fails to parse the `base_image`.
pub fn base_image_ref(&self) -> Result<Reference> {
self.base_image
.parse()
.into_diagnostic()
.with_context(|| format!("Unable to parse base image {}", self.base_image))
}
#[must_use]
pub fn alt_tags(&'a self) -> Option<Vec<Cow<'a, str>>> {
self.alt_tags
.as_ref()
.map(|tags| tags.iter().map(|tag| cowstr!(&**tag)).collect())
}
}

View file

@ -27,7 +27,7 @@ pub struct StageRequiredFields<'a> {
/// The shell to use in the stage.
#[builder(default, setter(into, strip_option))]
#[serde(skip_serializing_if = "Option::is_none")]
pub shell: Option<Vec<Cow<'a, str>>>,
pub shell: Option<Cow<'a, [Cow<'a, str>]>>,
/// The modules extension for the stage
#[serde(flatten)]