Skip to content

Commit 04890b6

Browse files
committed
Merge branch 'main' into 2592-mapper-bridge
2 parents 392cfcf + bcb637b commit 04890b6

File tree

117 files changed

+2145
-1889
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2145
-1889
lines changed

.gitattributes

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/pull-request-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ jobs:
293293
runs-on: ubuntu-latest
294294
steps:
295295
- uses: actions/checkout@v4
296-
- uses: crate-ci/typos@v1.18.0
296+
- uses: crate-ci/typos@v1.19.0
297297
continue-on-error: true
298298
- run: exit 0
299299

Cargo.lock

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ url = "2.3"
171171
uzers = "0.11"
172172
walkdir = "2"
173173
which = "4.2"
174-
whoami = "1.2.1"
174+
whoami = "1.5.0"
175175
ws_stream_tungstenite = "0.11"
176176
x509-parser = "0.15"
177177
yansi = "0.5"

ci/build_scripts/build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,22 @@ Args:
3232
3333
Example ARCH (target) values:
3434
35-
MUSL variants
35+
Linux MUSL variants
3636
* x86_64-unknown-linux-musl
3737
* aarch64-unknown-linux-musl
3838
* armv7-unknown-linux-musleabihf
3939
* arm-unknown-linux-musleabihf
4040
41-
GNU variants
41+
Linux GNU variants
4242
* x86_64-unknown-linux-gnu
4343
* aarch64-unknown-linux-gnu
4444
* armv7-unknown-linux-gnueabihf
4545
* arm-unknown-linux-gnueabihf
4646
47+
Apple
48+
* aarch64-apple-darwin
49+
* x86_64-apple-darwin
50+
4751
Flags:
4852
--help|-h Show this help
4953
--skip-build Skip building the binaries and only package them (e.g. just create the linux packages)

ci/build_scripts/package.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ VERSION=
6868
CLEAN=1
6969
PACKAGES=()
7070
COMMAND=
71-
PACKAGE_TYPES="deb,apk,rpm,tarball"
71+
PACKAGE_TYPES=
7272

7373
while [ $# -gt 0 ]
7474
do
@@ -117,6 +117,14 @@ if [ -z "$TARGET" ]; then
117117
TARGET=$(./ci/build_scripts/detect_target.sh)
118118
fi
119119

120+
if [ -z "$PACKAGE_TYPES" ]; then
121+
case "$TARGET" in
122+
*linux*) PACKAGE_TYPES="deb,apk,rpm,tarball" ;;
123+
*apple*) PACKAGE_TYPES="tarball" ;;
124+
*) PACKAGE_TYPES="tarball" ;;
125+
esac
126+
fi
127+
120128
# Normalize output dir
121129
OUTPUT_DIR="${OUTPUT_DIR%/}"
122130

@@ -204,6 +212,8 @@ get_package_arch() {
204212
riscv64gc-unknown-linux-*) pkg_arch=riscv64 ;;
205213
mips64el-unknown-linux-*abi64) pkg_arch=mips64le ;;
206214
mipsel-unknown-linux-*) pkg_arch=mipsle ;;
215+
aarch64-apple-darwin) pkg_arch=arm64 ;;
216+
x86_64-apple-darwin) pkg_arch=amd64 ;;
207217
*)
208218
echo "Unknown package architecture. value=$1"
209219
exit 1

ci/build_scripts/publish_packages.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ get_user_friendly_arch() {
183183
*arm-unknown-linux-musleabihf*)
184184
easy_arch=armv6
185185
;;
186+
*aarch64-apple-darwin*)
187+
easy_arch=macos-arm64
188+
;;
189+
*x86_64-apple-darwin*)
190+
easy_arch=macos-amd64
191+
;;
186192
esac
187193
echo "$easy_arch"
188194
}

crates/common/download/src/download.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::fs::File;
1818
use std::io::Seek;
1919
use std::io::SeekFrom;
2020
use std::io::Write;
21+
#[cfg(target_os = "linux")]
2122
use std::os::unix::prelude::AsRawFd;
2223
use std::path::Path;
2324
use std::path::PathBuf;
@@ -487,7 +488,6 @@ fn try_pre_allocate_space(file: &File, path: &Path, file_len: u64) -> Result<(),
487488
#[allow(deprecated)]
488489
mod tests {
489490
use super::*;
490-
use nix::sys::statvfs;
491491
use std::io::Write;
492492
use tempfile::tempdir;
493493
use tempfile::NamedTempFile;
@@ -557,6 +557,7 @@ mod tests {
557557
#[tokio::test]
558558
#[ignore = "Overriding Content-Length doesn't work in mockito"]
559559
async fn downloader_download_with_content_length_larger_than_usable_disk_space() {
560+
use nix::sys::statvfs;
560561
let tmpstats = statvfs::statvfs("/tmp").unwrap();
561562
let usable_disk_space = tmpstats.blocks_free() * tmpstats.block_size();
562563

crates/common/logged_command/src/logged_command.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ EOF
317317

318318
// On expect the errors to be logged
319319
let log_content = String::from_utf8(std::fs::read(log_file_path)?)?;
320+
#[cfg(target_os = "linux")]
320321
assert_eq!(
321322
log_content,
322323
r#"----- $ ls "dummy-file"
@@ -328,6 +329,20 @@ EOF
328329
stderr <<EOF
329330
ls: cannot access 'dummy-file': No such file or directory
330331
EOF
332+
"#
333+
);
334+
#[cfg(target_os = "macos")]
335+
assert_eq!(
336+
log_content,
337+
r#"----- $ ls "dummy-file"
338+
exit status: 1
339+
340+
stdout <<EOF
341+
EOF
342+
343+
stderr <<EOF
344+
ls: dummy-file: No such file or directory
345+
EOF
331346
"#
332347
);
333348
Ok(())

crates/common/tedge_config/src/lib.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,34 @@ pub use self::tedge_config_cli::error::*;
77
pub use self::tedge_config_cli::models::*;
88
pub use self::tedge_config_cli::tedge_config::*;
99
pub use self::tedge_config_cli::tedge_config_location::*;
10-
pub use self::tedge_config_cli::tedge_config_repository::*;
1110
pub use camino::Utf8Path as Path;
1211
pub use camino::Utf8PathBuf as PathBuf;
1312
pub use certificate::CertificateError;
1413
pub use tedge_config_macros::all_or_nothing;
1514
pub use tedge_config_macros::OptionalConfig;
1615

17-
/// loads the new tedge config from system default
18-
pub fn get_new_tedge_config() -> Result<TEdgeConfig, TEdgeConfigError> {
19-
let tedge_config_location = TEdgeConfigLocation::default();
20-
TEdgeConfigRepository::new(tedge_config_location).load()
21-
}
16+
impl TEdgeConfig {
17+
pub fn try_new(config_location: TEdgeConfigLocation) -> Result<Self, TEdgeConfigError> {
18+
config_location.load()
19+
}
20+
21+
pub fn load(config_dir: &Path) -> Result<TEdgeConfig, TEdgeConfigError> {
22+
let config_location = TEdgeConfigLocation::from_custom_root(config_dir);
23+
TEdgeConfig::try_new(config_location)
24+
}
2225

23-
/// loads the tedge config from a config directory
24-
pub fn load_tedge_config(config_dir: &Path) -> Result<TEdgeConfig, TEdgeConfigError> {
25-
let tedge_config_location = TEdgeConfigLocation::from_custom_root(config_dir);
26-
TEdgeConfigRepository::new(tedge_config_location).load()
26+
#[cfg(feature = "test")]
27+
/// A test only method designed for injecting configuration into tests
28+
///
29+
/// ```
30+
/// use tedge_config::TEdgeConfig;
31+
/// let config = TEdgeConfig::load_toml_str("service.ty = \"service\"");
32+
///
33+
/// assert_eq!(&config.service.ty, "service");
34+
/// // Defaults are preserved
35+
/// assert_eq!(config.sudo.enable, true);
36+
/// ```
37+
pub fn load_toml_str(toml: &str) -> TEdgeConfig {
38+
TEdgeConfigLocation::load_toml_str(toml)
39+
}
2740
}

0 commit comments

Comments
 (0)