@@ -64,16 +64,17 @@ impl Containerd {
64
64
. unwrap_or ( 2 ) ;
65
65
info ! ( "containerd version: {}" , version) ;
66
66
67
- let plugin_key = if version == 3 {
67
+ let plugin_id = if version == 3 {
68
68
"io.containerd.cri.v1.images"
69
69
} else {
70
70
"io.containerd.grpc.v1.cri"
71
71
} ;
72
+
72
73
// If containerd supports config_path mode and config_path is not empty,
73
74
// add registries to the certs.d directory.
74
75
if let Some ( config_path) = containerd_config
75
76
. get ( "plugins" )
76
- . and_then ( |plugins| plugins. get ( plugin_key ) )
77
+ . and_then ( |plugins| plugins. get ( plugin_id ) )
77
78
. and_then ( |cri| cri. get ( "registry" ) )
78
79
. and_then ( |registry| registry. get ( "config_path" ) )
79
80
. and_then ( |config_path| config_path. as_str ( ) )
@@ -105,11 +106,9 @@ impl Containerd {
105
106
let mut registry_table = Table :: new ( ) ;
106
107
registry_table. set_implicit ( true ) ;
107
108
registry_table. insert ( "config_path" , value ( config_path) ) ;
108
- containerd_config[ "plugins" ] [ plugin_key ]
109
+ containerd_config[ "plugins" ] [ plugin_id ]
109
110
. 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) ) ) ?
113
112
. insert ( "registry" , Item :: Table ( registry_table) ) ;
114
113
115
114
// Override containerd configuration.
@@ -200,7 +199,7 @@ mod tests {
200
199
use tokio:: fs;
201
200
202
201
#[ tokio:: test]
203
- async fn test_containerd_config_with_existing_config_path ( ) {
202
+ async fn test_containerd_config_with_v2_config_path ( ) {
204
203
let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
205
204
let config_path = temp_dir. path ( ) . join ( "config.toml" ) ;
206
205
let certs_dir = temp_dir. path ( ) . join ( "certs.d" ) ;
@@ -262,7 +261,7 @@ X-Dragonfly-Registry = "https://registry.example.com"
262
261
263
262
assert_eq ! ( contents. trim( ) , expected_contents. trim( ) ) ;
264
263
}
265
-
264
+
266
265
#[ tokio:: test]
267
266
async fn test_containerd_config_with_v3_config_path ( ) {
268
267
let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
0 commit comments