Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust-toolchain: [stable, stable 12 months ago]
rust-toolchain: ["1.88.0"]
steps:
- name: Install libudev
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clippy-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust-toolchain: [stable, stable 12 months ago]
rust-toolchain: ["1.88.0"]
steps:
- name: Install libudev
run: |
Expand Down
13 changes: 4 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "azure-init"
version = "0.1.1"
edition = "2021"
rust-version = "1.74"
rust-version = "1.88"
repository = "https://github.com/Azure/azure-init/"
homepage = "https://github.com/Azure/azure-init/"
license = "MIT"
Expand All @@ -19,9 +19,7 @@ clap = { version = "4.5.21", features = ["derive", "cargo", "env"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tokio-util = "0.7"

# Pin sysinfo to <=0.36 for MSRV issues with Rust < 1.85.0.
# This should be unpinned around 2026-02-17 if we continue with our ~1 year MSRV policy
sysinfo = "=0.36"
sysinfo = "0.38"

[dev-dependencies]
assert_cmd = "2.0.16"
Expand All @@ -30,7 +28,8 @@ predicates-core = "1.0.8"
predicates-tree = "1.0.11"
tempfile = "3.3.0"

# Pin idna_adapter to <=1.2.0 for MSRV issues with cargo-clippy of Rust 1.78.0.
# Pin idna_adapter to <=1.2.0 for MSRV issues with older Rust versions.
# With MSRV 1.88, this pin may no longer be necessary.
idna_adapter = "<=1.2.0"

[dependencies.libazureinit]
Expand Down Expand Up @@ -61,7 +60,3 @@ useradd = []
systemd_linux = ["passwd", "hostnamectl", "useradd"]

default = ["systemd_linux"]

[build-dependencies]
vergen = { version = "9.0.6", features = ["build", "cargo", "rustc", "si"] }
vergen-gitcl = "1"
48 changes: 37 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::env;
use vergen::Emitter;
use vergen_gitcl::GitclBuilder;
use std::process::Command;

fn main() {
// Re-run if the packaging version override changes
Expand All @@ -9,20 +8,47 @@ fn main() {
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/index");

let mut gitcl_builder = GitclBuilder::default();
// Parameters: use_tag=true, dirty=true, pattern=None
gitcl_builder.describe(true, true, None);
let git = gitcl_builder.build().ok();

let mut emitter = Emitter::default();
if let Some(g) = git.as_ref() {
let _ = emitter.add_instructions(g);
if let Some(git_version) = git_describe() {
println!("cargo:rustc-env=AZURE_INIT_BUILD_VERSION={git_version}");
} else if let Some(git_sha) = git_sha() {
println!("cargo:rustc-env=AZURE_INIT_BUILD_SHA={git_sha}");
}
let _ = emitter.emit();

// Allow packaging to supply a custom version
if let Ok(custom_version) = env::var("AZURE_INIT_VERSION") {
println!("cargo:rustc-env=AZURE_INIT_VERSION={custom_version}");
println!("cargo:rustc-env=AZURE_INIT_BUILD_VERSION={custom_version}");
}
}

fn git_describe() -> Option<String> {
let output = Command::new("git")
.args(["describe", "--dirty", "--tags"])
.output()
.ok()?;
if !output.status.success() {
return None;
}
let describe = String::from_utf8_lossy(&output.stdout).trim().to_string();
if describe.is_empty() {
None
} else {
Some(describe)
}
}

fn git_sha() -> Option<String> {
let output = Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.ok()?;
if !output.status.success() {
return None;
}
let sha = String::from_utf8_lossy(&output.stdout).trim().to_string();
if sha.is_empty() {
None
} else {
Some(sha)
}
}
10 changes: 4 additions & 6 deletions libazureinit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libazureinit"
version = "0.1.1"
edition = "2021"
rust-version = "1.74"
rust-version = "1.88"
build = "build.rs"
repository = "https://github.com/Azure/azure-init/"
homepage = "https://github.com/Azure/azure-init/"
Expand All @@ -16,17 +16,15 @@ thiserror = "2.0.3"
tokio = { version = "1", features = ["full"] }
serde-xml-rs = "0.8.0"
serde_json = "1.0.96"
nix = {version = "0.30.1", features = ["fs", "user"]}
nix = {version = "0.31.1", features = ["fs", "user"]}
block-utils = "0.11.1"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
opentelemetry = "0.31.0"
opentelemetry_sdk = "0.31.0"
tracing-opentelemetry = "0.32"
tokio-util = "0.7"
# Pin sysinfo to <=0.36 for MSRV issues with Rust < 1.85.0.
# This should be unpinned around 2026-02-17 if we continue with our ~1 year MSRV policy
sysinfo = "=0.36"
sysinfo = "0.38"
anyhow = "1"
fstab = "0.4.0"
toml = "0.9"
Expand All @@ -44,7 +42,7 @@ tracing-test = { version = "0.2", features = ["no-env-filter"] }
tempfile = "3"
tokio = { version = "1", features = ["full"] }
tokio-util = "0.7.11"
whoami = "1"
whoami = "2"
anyhow = "1.0.81"
gag = "1.0.0"
serial_test = "3.0.0"
Expand Down
3 changes: 1 addition & 2 deletions libazureinit/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,11 @@ impl Config {

figment
.extract::<Config>()
.map(|config| {
.inspect(|_config| {
tracing::info!(
target: "libazureinit::config::success",
"Configuration successfully loaded."
);
config
})
.map_err(|e| {
tracing::error!("Failed to extract configuration: {:?}", e);
Expand Down
9 changes: 5 additions & 4 deletions libazureinit/src/provision/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,11 @@ mod tests {
let home_dir =
tempfile::TempDir::new().expect("Failed to create temp directory");

let mut user =
nix::unistd::User::from_name(whoami::username().as_str())
.expect("Failed to get user")
.expect("User does not exist");
let mut user = nix::unistd::User::from_name(
whoami::username().expect("Failed to get username").as_str(),
)
.expect("Failed to get user")
.expect("User does not exist");
user.dir = home_dir.path().into();

if create_ssh_dir {
Expand Down
13 changes: 7 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ fn version_string() -> String {
return v.to_string();
}

if let Some(desc) = option_env!("VERGEN_GIT_DESCRIBE") {
format!("{PKG_VERSION}-{desc}")
} else if let Some(sha) = option_env!("VERGEN_GIT_SHA") {
if let Some(build) = option_env!("AZURE_INIT_BUILD_VERSION") {
return format!("{PKG_VERSION}-{build}");
}
if let Some(sha) = option_env!("AZURE_INIT_BUILD_SHA") {
let short = &sha[..std::cmp::min(7, sha.len())];
format!("{PKG_VERSION}-{short}")
} else {
PKG_VERSION.to_string()
return format!("{PKG_VERSION}-{short}");
}

PKG_VERSION.to_string()
}

/// Minimal provisioning agent for Azure
Expand Down