Skip to content

Commit 09dfeec

Browse files
authored
feat: rename plugin_key to plugin_id in dfinit (#1358)
Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 7c368d5 commit 09dfeec

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ members = [
1212
]
1313

1414
[workspace.package]
15-
version = "1.0.20"
15+
version = "1.0.21"
1616
authors = ["The Dragonfly Developers"]
1717
homepage = "https://d7y.io/"
1818
repository = "https://github.com/dragonflyoss/client.git"
@@ -22,13 +22,13 @@ readme = "README.md"
2222
edition = "2021"
2323

2424
[workspace.dependencies]
25-
dragonfly-client = { path = "dragonfly-client", version = "1.0.20" }
26-
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.0.20" }
27-
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.0.20" }
28-
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.0.20" }
29-
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.0.20" }
30-
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.0.20" }
31-
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.0.20" }
25+
dragonfly-client = { path = "dragonfly-client", version = "1.0.21" }
26+
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.0.21" }
27+
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.0.21" }
28+
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.0.21" }
29+
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.0.21" }
30+
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.0.21" }
31+
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.0.21" }
3232
dragonfly-api = "=2.1.65"
3333
thiserror = "2.0"
3434
futures = "0.3.31"

dragonfly-client-init/src/container_runtime/containerd.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,17 @@ impl Containerd {
6464
.unwrap_or(2);
6565
info!("containerd version: {}", version);
6666

67-
let plugin_key = if version == 3 {
67+
let plugin_id = if version == 3 {
6868
"io.containerd.cri.v1.images"
6969
} else {
7070
"io.containerd.grpc.v1.cri"
7171
};
72+
7273
// If containerd supports config_path mode and config_path is not empty,
7374
// add registries to the certs.d directory.
7475
if let Some(config_path) = containerd_config
7576
.get("plugins")
76-
.and_then(|plugins| plugins.get(plugin_key))
77+
.and_then(|plugins| plugins.get(plugin_id))
7778
.and_then(|cri| cri.get("registry"))
7879
.and_then(|registry| registry.get("config_path"))
7980
.and_then(|config_path| config_path.as_str())
@@ -105,11 +106,9 @@ impl Containerd {
105106
let mut registry_table = Table::new();
106107
registry_table.set_implicit(true);
107108
registry_table.insert("config_path", value(config_path));
108-
containerd_config["plugins"][plugin_key]
109+
containerd_config["plugins"][plugin_id]
109110
.as_table_mut()
110-
.ok_or(Error::Unknown(
111-
format!("{} not found", plugin_key),
112-
))?
111+
.ok_or(Error::Unknown(format!("{} not found", plugin_id)))?
113112
.insert("registry", Item::Table(registry_table));
114113

115114
// Override containerd configuration.
@@ -200,7 +199,7 @@ mod tests {
200199
use tokio::fs;
201200

202201
#[tokio::test]
203-
async fn test_containerd_config_with_existing_config_path() {
202+
async fn test_containerd_config_with_v2_config_path() {
204203
let temp_dir = TempDir::new().unwrap();
205204
let config_path = temp_dir.path().join("config.toml");
206205
let certs_dir = temp_dir.path().join("certs.d");
@@ -262,7 +261,7 @@ X-Dragonfly-Registry = "https://registry.example.com"
262261

263262
assert_eq!(contents.trim(), expected_contents.trim());
264263
}
265-
264+
266265
#[tokio::test]
267266
async fn test_containerd_config_with_v3_config_path() {
268267
let temp_dir = TempDir::new().unwrap();

0 commit comments

Comments
 (0)