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

refactor: Move templates to their own crate #83

Merged
merged 8 commits into from
Feb 25, 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
120 changes: 57 additions & 63 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 57 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,51 +1,80 @@
[package]
name = "blue-build"
[workspace]
members = [ "utils", "recipe","template"]

[workspace.package]
version = "0.8.0"
edition = "2021"
description = "A CLI tool built for creating Containerfile templates based on the Ublue Community Project"
edition = "2021"
repository = "https://github.com/blue-build/cli"
license = "Apache-2.0"
categories = ["command-line-utilities"]

[workspace.dependencies]
anyhow = "1"
format_serde_error = "0.3.0"
log = "0.4"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9.30"
typed-builder = "0.18.1"
uuid = { version = "1.7.0", features = ["v4"] }

[workspace.lints.rust]
unsafe_code = "forbid"

[workspace.lints.clippy]
correctness = "warn"
suspicious = "warn"
perf = "warn"
style = "warn"
nursery = "warn"

[package]
name = "blue-build"
build = "build.rs"

version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
anyhow = "1"
askama = { version = "0.12", features = ["serde-json", "serde-yaml"] }
chrono = "0.4"
blue-build-recipe = { path = "./recipe" }
blue-build-template = { path = "./template" }
blue-build-utils = { path = "./utils" }
clap = { version = "4", features = ["derive", "cargo", "unicode"] }
clap-verbosity-flag = "2"
clap_complete = "4"
clap_complete_nushell = "4"
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
os_info = "3.7"
podman-api = { version = "0.10.0", optional = true }
process_control = { version = "4.0.3", features = ["crossbeam-channel"] }
os_info = "3.7" # update os module config and tests when upgrading os_info
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" }
urlencoding = "2.1.3"
users = "0.11.0"

# Optional Dependencies
futures-util = { version = "0.3", optional = true }
podman-api = { version = "0.10.0", optional = true }
signal-hook = { version = "0.3.17", optional = true }
signal-hook-tokio = { version = "0.3.1", features = [
"futures-v0_3",
], optional = true }
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"
uuid = { version = "1.7.0", features = ["v4"] }
which = "6"

# Workspace dependencies
anyhow.workspace = true
log.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
typed-builder.workspace = true
uuid.workspace = true

[features]
default = []
Expand All @@ -66,6 +95,9 @@ rusty-hook = "0.11.2"
shadow-rs = { version = "0.26.1", default-features = false }
dunce = "1.0.4"

[lints]
workspace = true

[profile.release]
lto = true
codegen-units = 1
Expand Down
2 changes: 1 addition & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ common:
FROM ghcr.io/blue-build/earthly-lib/cargo-builder

WORKDIR /app
COPY --keep-ts --dir src/ templates/ /app
COPY --keep-ts --dir src/ template/ recipe/ utils/ /app
COPY --keep-ts Cargo.* /app
COPY --keep-ts *.md /app
COPY --keep-ts LICENSE /app
Expand Down
26 changes: 26 additions & 0 deletions recipe/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "blue-build-recipe"
version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
blue-build-utils = { path = "../utils" }
chrono = "0.4"
indexmap = { version = "2", features = ["serde"] }

anyhow.workspace = true
format_serde_error.workspace = true
log.workspace = true
serde.workspace = true
serde_yaml.workspace = true
serde_json.workspace = true
typed-builder.workspace = true

[lints]
workspace = true

File renamed without changes.
23 changes: 23 additions & 0 deletions recipe/src/image_inspection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use serde::Deserialize;
use serde_json::Value;
use std::collections::HashMap;

#[derive(Deserialize, Debug, Clone)]
pub struct ImageInspection {
#[serde(alias = "Labels")]
labels: HashMap<String, Value>,
}

impl ImageInspection {
pub fn get_version(&self) -> Option<String> {
Some(
self.labels
.get("org.opencontainers.image.version")?
.as_str()
.map(std::string::ToString::to_string)?
.split('.')
.take(1)
.collect(),
)
}
}
11 changes: 11 additions & 0 deletions recipe/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pub mod akmods_info;
pub mod image_inspection;
pub mod module;
pub mod module_ext;
pub mod recipe;

pub use akmods_info::*;
pub use image_inspection::*;
pub use module::*;
pub use module_ext::*;
pub use recipe::*;
Loading