Compare commits
5
Commits
2a33d34a76
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eaa925025d
|
||
|
|
65ed7ab1d2
|
||
|
|
8e9c461a45
|
||
|
|
c183f1a5f1
|
||
|
|
f9f0be1e92
|
@@ -1,5 +1,14 @@
|
||||
[workspace]
|
||||
pr_name = "chore(release): Release v{{ version }}"
|
||||
changelog_path = "./CHANGELOG.md"
|
||||
|
||||
[[package]]
|
||||
name = "crete"
|
||||
changelog_include = ["ipxe"]
|
||||
|
||||
[[package]]
|
||||
name = "ipxe"
|
||||
release = false
|
||||
|
||||
[[package]]
|
||||
name = "xtask"
|
||||
|
||||
Generated
+302
-446
File diff suppressed because it is too large
Load Diff
+6
-5
@@ -10,8 +10,8 @@ license = "GPL-3.0-or-later"
|
||||
members = ["ipxe", "xtask"]
|
||||
|
||||
[workspace.dependencies]
|
||||
schemars = { version = "1.2.2", features = ["semver1"] }
|
||||
serde_json = "1.0.151"
|
||||
schemars = { version = "1.2.3", features = ["semver1"] }
|
||||
serde_json = "1.0.154"
|
||||
|
||||
[dependencies]
|
||||
async-walkdir = "2.2.0"
|
||||
@@ -19,8 +19,8 @@ byteorder = "1.5.0"
|
||||
clap = { version = "4.6.7", features = ["derive"] }
|
||||
clap_complete = "4.6.11"
|
||||
futures = "0.3.34"
|
||||
gix-discover = { version = "0.56.0", features = ["sha1"] }
|
||||
minijinja = { version = "2.24.0", features = ["json", "loader"] }
|
||||
gix-discover = { version = "0.57.0", features = ["sha1"] }
|
||||
minijinja = { version = "3.0.1", features = ["json", "serde"] }
|
||||
netascii = "0.1.0"
|
||||
num_enum = "0.7.6"
|
||||
optional_struct = "0.5.2"
|
||||
@@ -34,11 +34,12 @@ serde = { version = "1.0.229", features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
serde_yaml = "0.9.34"
|
||||
thiserror = "2.0.21"
|
||||
tokio = { version = "1.52.1", features = ["full"] }
|
||||
tokio = { version = "1.54.0", features = ["full"] }
|
||||
ipxe = { path = "./ipxe" }
|
||||
axum = { version = "0.8.9", features = ["macros"] }
|
||||
socket2 = "0.6.5"
|
||||
socket-pktinfo = "0.4.1"
|
||||
serde-saphyr = "2.0.0"
|
||||
|
||||
[lib]
|
||||
test = false
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ use gix::Repository;
|
||||
use gix::progress::Discard;
|
||||
|
||||
const URL: &str = "https://github.com/ipxe/ipxe";
|
||||
const REVISION: &str = "fe159d0910cac1cd49bab8d4b9296dbe2d9d3cc2";
|
||||
const REVISION: &str = "2fa08affe9a1a1422766f54b2fb045234b571f06";
|
||||
const FILES: &[&str] = &["bin/ipxe.pxe", "bin-x86_64-efi/ipxe.efi"];
|
||||
|
||||
const SRC_DIR: &str = "src";
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ impl Cluster {
|
||||
path.add_extension("yaml");
|
||||
let content = tokio::fs::read_to_string(path).await.unwrap();
|
||||
|
||||
let mut cluster: OptionalClusterDeserialize = serde_yaml::from_str(&content).unwrap();
|
||||
let mut cluster: OptionalClusterDeserialize = serde_saphyr::from_str(&content).unwrap();
|
||||
|
||||
// For some reason apply on the cluster does not properly apply to the default settings...
|
||||
// So we manually apply it here first
|
||||
|
||||
+13
-7
@@ -4,8 +4,8 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use async_walkdir::WalkDir;
|
||||
use futures::{Stream, StreamExt};
|
||||
use minijinja::value::ViaDeserialize;
|
||||
use minijinja::{AutoEscape, Environment, path_loader};
|
||||
use minijinja::syntax::SyntaxConfig;
|
||||
use minijinja::{AutoEscape, Environment, path_loader, value};
|
||||
|
||||
use crate::{get_configs_path, get_talos_path};
|
||||
|
||||
@@ -19,21 +19,27 @@ pub struct PathEnvironment<'a> {
|
||||
}
|
||||
|
||||
fn apply_netmask(
|
||||
ip: ViaDeserialize<Ipv4Addr>,
|
||||
netmask: ViaDeserialize<Ipv4Addr>,
|
||||
ip: value::Serde<Ipv4Addr>,
|
||||
netmask: value::Serde<Ipv4Addr>,
|
||||
) -> Result<String, minijinja::Error> {
|
||||
Ok((*ip & *netmask).to_string())
|
||||
}
|
||||
|
||||
pub fn configure_environment(env: &mut Environment) {
|
||||
// Configure jinja
|
||||
env.set_trim_blocks(true);
|
||||
env.set_lstrip_blocks(true);
|
||||
// Configure jinja
|
||||
env.set_syntax(
|
||||
SyntaxConfig::builder()
|
||||
.trim_blocks(true)
|
||||
.lstrip_blocks(true)
|
||||
.build()
|
||||
.expect("Syntax config should be valid"),
|
||||
);
|
||||
env.set_undefined_behavior(minijinja::UndefinedBehavior::Strict);
|
||||
env.set_auto_escape_callback(|_| AutoEscape::None);
|
||||
|
||||
// Add filters
|
||||
env.add_filter("to_prefix", |netmask: ViaDeserialize<Ipv4Addr>| {
|
||||
env.add_filter("to_prefix", |netmask: value::Serde<Ipv4Addr>| {
|
||||
let mask = netmask.to_bits();
|
||||
let prefix = mask.leading_ones();
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
use crete::cluster::Cluster;
|
||||
use crete::environment::configure_environment;
|
||||
use ipxe::IPXE_DIR;
|
||||
use minijinja::{Environment, context};
|
||||
use minijinja::{Environment, context, value};
|
||||
use regex::regex;
|
||||
|
||||
pub async fn get_file(
|
||||
@@ -26,7 +26,7 @@ pub async fn get_file(
|
||||
let clusters = Cluster::get_all().await;
|
||||
let content = template
|
||||
.render(context! {
|
||||
clusters => clusters.values().collect::<Vec<_>>(),
|
||||
clusters => value::Serde(clusters.values().collect::<Vec<_>>()),
|
||||
httpUrl => http_url.to_string()
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ use crete::talosconfig::{get_current_context, set_context};
|
||||
use crete::{get_configs_path, get_repo_path, set_repo_path, tftp};
|
||||
use futures::StreamExt;
|
||||
use futures::future::join_all;
|
||||
use minijinja::context;
|
||||
use minijinja::{context, value};
|
||||
|
||||
use crate::cli::{Cli, Commands, GlobalOpts};
|
||||
use crate::error::Error;
|
||||
@@ -44,8 +44,8 @@ async fn generate(opts: &GlobalOpts) -> Result<(), Error> {
|
||||
|
||||
let content = template
|
||||
.render(context! {
|
||||
clusters => clusters.values().collect::<Vec<_>>(),
|
||||
root => opts.repo
|
||||
clusters => value::Serde(clusters.values().collect::<Vec<_>>()),
|
||||
root => value::Serde(&opts.repo)
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
||||
+2
-2
@@ -102,7 +102,7 @@ pub struct Node {
|
||||
ntp: String,
|
||||
install: Install,
|
||||
kernel_args: Vec<String>,
|
||||
patches: Patches<serde_yaml::Value>,
|
||||
patches: Patches<serde_json::Value>,
|
||||
sops: Secret,
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ impl Node {
|
||||
path.add_extension("yaml");
|
||||
let content = tokio::fs::read_to_string(path).await.unwrap();
|
||||
|
||||
let node: OptionalNodeDeserialize = serde_yaml::from_str(&content).unwrap();
|
||||
let node: OptionalNodeDeserialize = serde_saphyr::from_str(&content).unwrap();
|
||||
|
||||
// We want all vectors to be empty vectors by default
|
||||
// Sadly we have to this manually
|
||||
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
use minijinja::{Environment, context};
|
||||
use minijinja::{Environment, context, value};
|
||||
use optional_struct::optional_struct;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -21,7 +21,7 @@ async fn render(
|
||||
env: &Environment<'static>,
|
||||
cluster: &Cluster,
|
||||
node: &Node,
|
||||
) -> Vec<serde_yaml::Value> {
|
||||
) -> Vec<serde_json::Value> {
|
||||
let env = env.clone();
|
||||
let cluster = cluster.clone();
|
||||
let node = node.clone();
|
||||
@@ -35,12 +35,12 @@ async fn render(
|
||||
.get_template(&name)
|
||||
.unwrap()
|
||||
.render(context! {
|
||||
node,
|
||||
cluster
|
||||
node => value::Serde(&node),
|
||||
cluster => value::Serde(&cluster)
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
serde_yaml::from_str(&content).unwrap()
|
||||
serde_saphyr::from_str(&content).unwrap()
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
@@ -64,7 +64,7 @@ impl Patches<String> {
|
||||
env: &Environment<'static>,
|
||||
cluster: &Cluster,
|
||||
node: &Node,
|
||||
) -> Patches<serde_yaml::Value> {
|
||||
) -> Patches<serde_json::Value> {
|
||||
Patches {
|
||||
all: render(self.all.clone(), env, cluster, node).await,
|
||||
control_plane: render(self.control_plane.clone(), env, cluster, node).await,
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ pub async fn get_current_context() -> Option<String> {
|
||||
tokio::fs::read(&TalosConfig::merged_path())
|
||||
.await
|
||||
.ok()
|
||||
.and_then(|config| serde_yaml::from_slice(&config).ok())
|
||||
.and_then(|config| serde_saphyr::from_slice(&config).ok())
|
||||
.map(|config: TalosConfig| config.context)
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -5,7 +5,7 @@ use std::time::Duration;
|
||||
use socket_pktinfo::{PktInfo, PktInfoUdpSocket};
|
||||
use socket2::Domain;
|
||||
use thiserror::Error;
|
||||
use tokio::io::unix::AsyncFd;
|
||||
use tokio::io::unix::{AsyncFd, AsyncFdRegisterError};
|
||||
use tokio::net::UdpSocket;
|
||||
|
||||
use crate::tftp::packet::{ErrorCode, Mode, PACKET_SIZE};
|
||||
@@ -29,6 +29,8 @@ pub enum Error {
|
||||
UnexpectedPacket(Packet),
|
||||
#[error("Timeout")]
|
||||
Timeout,
|
||||
#[error("AsyncFd: {0}")]
|
||||
AsyncFd(#[from] AsyncFdRegisterError<PktInfoUdpSocket>),
|
||||
}
|
||||
|
||||
pub async fn handle_connection<F, Fut>(
|
||||
@@ -161,7 +163,8 @@ where
|
||||
let addr: SocketAddr = (ip, 69).into();
|
||||
socket.bind(&addr.into())?;
|
||||
|
||||
let async_fd = AsyncFd::new(socket)?;
|
||||
let async_fd = unsafe { AsyncFd::register(socket)? };
|
||||
|
||||
let mut buf = [0u8; PACKET_SIZE];
|
||||
|
||||
println!("Tftp server started on {addr}");
|
||||
|
||||
Reference in New Issue
Block a user