Skip to content

Commit b1b7fb0

Browse files
committed
fix: always create conatiner with the images's platform
1 parent 15352c4 commit b1b7fb0

File tree

7 files changed

+26
-24
lines changed

7 files changed

+26
-24
lines changed

Cargo.lock

Lines changed: 7 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
@@ -1,6 +1,6 @@
11
[package]
22
name = "rooz"
3-
version = "0.129.0"
3+
version = "0.130.0"
44
edition = "2021"
55

66
[dependencies]

src/api/container.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
api::{image::ImageInfo, ContainerApi},
2+
api::ContainerApi,
33
constants,
44
model::types::{AnyError, ContainerResult, OneShotResult, RunMode, RunSpec},
55
util::{
@@ -245,13 +245,7 @@ impl<'a> ContainerApi<'a> {
245245

246246
let options = CreateContainerOptions {
247247
name: Some(spec.container_name.to_string()),
248-
platform: match image_info {
249-
ImageInfo {
250-
platform: Some(platform),
251-
..
252-
} => platform,
253-
_ => self.backend.platform.to_string(),
254-
},
248+
platform: image_info.platform.unwrap(),
255249
};
256250

257251
let oom_score_adj = match self.backend.engine {

src/api/image.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl<'a> ImageApi<'a> {
2626
}
2727
.to_string(),
2828
),
29+
platform: self.backend.platform.to_string(),
2930
..Default::default()
3031
}),
3132
None,

src/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub mod workspace;
1313

1414
pub struct ImageApi<'a> {
1515
pub client: &'a Docker,
16+
pub backend: &'a ContainerBackend,
1617
}
1718

1819
pub struct ExecApi<'a> {

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ async fn main() -> Result<(), AnyError> {
8080
client: &docker,
8181
backend: &backend,
8282
};
83-
let image_api = ImageApi { client: &docker };
83+
let image_api = ImageApi {
84+
client: &docker,
85+
backend: &backend,
86+
};
8487
let container_api = ContainerApi {
8588
client: &docker,
8689
image: &image_api,

src/util/backend.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,47 @@ impl ContainerBackend {
2020
fn backend(info: &SystemInfo, version: &SystemVersion) -> ContainerBackend {
2121
if let SystemInfo {
2222
operating_system: Some(name),
23-
architecture: Some(architecture),
2423
..
2524
} = &info
2625
{
26+
let os = &version.os.as_deref().unwrap();
27+
let arch = &version.arch.as_deref().unwrap();
28+
let platform = format!("{}/{}", os, arch);
29+
2730
match name.as_str() {
2831
"Rancher Desktop WSL Distribution" => ContainerBackend {
2932
engine: ContainerEngine::RancherDesktop,
30-
platform: architecture.to_string(),
33+
platform: platform.to_string(),
3134
},
3235
"Docker Desktop" => ContainerBackend {
3336
engine: ContainerEngine::DockerDesktop,
34-
platform: architecture.to_string(),
37+
platform: platform.to_string(),
3538
},
3639
_ => {
3740
if let Some(components) = &version.components {
3841
if components.iter().any(|c| c.name == "Podman Engine") {
3942
ContainerBackend {
4043
engine: ContainerEngine::Podman,
41-
platform: architecture.to_string(),
44+
platform: platform.to_string(),
4245
}
4346
} else {
4447
ContainerBackend {
4548
engine: ContainerEngine::Unknown,
46-
platform: architecture.to_string(),
49+
platform: platform.to_string(),
4750
}
4851
}
4952
} else {
5053
ContainerBackend {
5154
engine: ContainerEngine::Unknown,
52-
platform: architecture.to_string(),
55+
platform: platform.to_string(),
5356
}
5457
}
5558
}
5659
}
5760
} else {
5861
ContainerBackend {
5962
engine: ContainerEngine::Unknown,
60-
platform: "Unknown".to_string(),
63+
platform: "unknown".to_string(),
6164
}
6265
}
6366
}

0 commit comments

Comments
 (0)