pub struct ImageManager { /* private fields */ }Expand description
综合镜像管理器 - 4种操作模式的统一入口
Implementations§
Source§impl ImageManager
impl ImageManager
Sourcepub fn new(cache_dir: Option<&str>, verbose: bool) -> Result<Self>
pub fn new(cache_dir: Option<&str>, verbose: bool) -> Result<Self>
创建新的镜像管理器
Examples found in repository?
examples/optimized_upload_demo.rs (line 14)
10async fn main() -> Result<()> {
11 println!("Docker Image Pusher - Optimized Upload Demo");
12
13 // Create image manager with optimizations enabled (default)
14 let mut manager = ImageManager::new(None, true)?;
15
16 // Configure pipeline for demonstration
17 let config = PipelineConfig {
18 max_concurrent: 8,
19 buffer_size: 1024,
20 small_blob_threshold: 10 * 1024 * 1024, // 10MB
21 medium_blob_threshold: 100 * 1024 * 1024, // 100MB
22 large_blob_threshold: 500 * 1024 * 1024, // 500MB
23 timeout_seconds: 7200,
24 retry_attempts: 3,
25 memory_limit_mb: 512,
26 enable_compression: true,
27 enable_streaming: true,
28 };
29 manager.configure_pipeline(config);
30
31 // Verify configuration
32 let (optimized, pipeline_config) = manager.get_config();
33 println!("Optimized mode: {}", optimized);
34 println!("Pipeline config: {:?}", pipeline_config);
35
36 // Example registry client (would need real registry URL)
37 let client = RegistryClientBuilder::new("https://registry.example.com".to_string())
38 .with_verbose(true)
39 .build()?;
40
41 // Test connectivity (this would fail with example URL)
42 println!("Testing registry connectivity...");
43 match client.test_connectivity().await {
44 Ok(_) => println!("✓ Registry connectivity successful"),
45 Err(e) => println!(
46 "✗ Registry connectivity failed: {} (expected with example URL)",
47 e
48 ),
49 }
50
51 // Example operation mode for pushing from tar
52 let mode = OperationMode::PushFromTar {
53 tar_file: "example-image.tar".to_string(),
54 repository: "myapp".to_string(),
55 reference: "latest".to_string(),
56 };
57
58 println!("Operation mode: {}", mode.description());
59
60 // In a real scenario, you would call:
61 // manager.execute_operation(&mode, Some(&client), None).await?;
62
63 println!("Demo completed successfully!");
64 println!("\nKey benefits of optimized mode:");
65 println!("• Priority-based upload scheduling (small blobs first)");
66 println!("• Streaming TAR processing with parallel uploads");
67 println!("• Memory-efficient processing of large files");
68 println!("• Configurable pipeline parameters");
69
70 Ok(())
71}More examples
examples/extract_and_cache_demo.rs (line 46)
12async fn main() -> Result<()> {
13 println!("📦 Docker Image Pusher - Extract and Cache Demo");
14 println!("===================================================");
15
16 // 配置参数
17 let tar_file = get_tar_file_path();
18 let cache_dir = ".cache_extract_demo";
19
20 // 从tar文件名推导repository和reference
21 let file_stem = Path::new(&tar_file)
22 .file_stem()
23 .and_then(|s| s.to_str())
24 .unwrap_or("extracted-image");
25 let repository = format!("local/{}", file_stem);
26 let reference = "latest";
27
28 println!("📥 Configuration:");
29 println!(" Tar File: {}", tar_file);
30 println!(" Repository: {}", repository);
31 println!(" Reference: {}", reference);
32 println!(" Cache Directory: {}", cache_dir);
33 println!();
34
35 // 1. 验证tar文件存在
36 if !Path::new(&tar_file).exists() {
37 eprintln!("❌ Tar file not found: {}", tar_file);
38 eprintln!("💡 Please ensure the dufs.tar file exists in the examples/ directory");
39 return Err(docker_image_pusher::error::RegistryError::Validation(
40 format!("Tar file does not exist: {}", tar_file),
41 ));
42 }
43
44 // 2. 创建 ImageManager
45 println!("🔧 Creating ImageManager...");
46 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
47 println!("✅ ImageManager created successfully");
48
49 // 3. 定义操作模式
50 let mode = OperationMode::ExtractAndCache {
51 tar_file: tar_file.clone(),
52 repository: repository.clone(),
53 reference: reference.to_string(),
54 };
55
56 println!("📋 Operation Mode: {}", mode.description());
57 println!();
58
59 // 4. 执行提取和缓存操作
60 println!("🔄 Starting extract and cache operation...");
61 match image_manager.execute_operation(&mode, None, None).await {
62 Ok(()) => {
63 println!("✅ Extract and cache operation completed successfully!");
64 println!();
65 println!("📂 Image extracted and cached to: {}", cache_dir);
66 println!("🔍 You can now inspect the cache contents:");
67 println!(
68 " - Manifests: {}/manifests/{}/{}",
69 cache_dir, repository, reference
70 );
71 println!(" - Blobs: {}/blobs/sha256/", cache_dir);
72 println!(" - Index: {}/index.json", cache_dir);
73 }
74 Err(e) => {
75 eprintln!("❌ Extract and cache operation failed: {}", e);
76 std::process::exit(1);
77 }
78 }
79
80 // 5. 显示提取统计
81 show_extraction_stats(&tar_file, cache_dir).await;
82
83 Ok(())
84}examples/pull_and_cache_demo.rs (line 33)
13async fn main() -> Result<()> {
14 println!("🚀 Docker Image Pusher - Pull and Cache Demo");
15 println!("==================================================");
16
17 // 配置参数 - 支持环境变量
18 let registry = env::var("DOCKER_REGISTRY")
19 .unwrap_or_else(|_| "https://registry.cn-beijing.aliyuncs.com".to_string());
20 let repository = env::var("DOCKER_REPOSITORY").unwrap_or_else(|_| "yoce/cblt".to_string());
21 let reference = env::var("DOCKER_REFERENCE").unwrap_or_else(|_| "yoce".to_string());
22 let cache_dir = ".cache_demo";
23
24 println!("📥 Configuration:");
25 println!(" Registry: {}", registry);
26 println!(" Repository: {}", repository);
27 println!(" Reference: {}", reference);
28 println!(" Cache Directory: {}", cache_dir);
29 println!();
30
31 // 1. 创建 ImageManager
32 println!("🔧 Creating ImageManager...");
33 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
34 println!("✅ ImageManager created successfully");
35
36 // 2. 构建 Registry Client
37 println!("🌐 Building Registry Client...");
38 let client = RegistryClientBuilder::new(registry.to_string())
39 .with_timeout(3600)
40 .with_verbose(true)
41 .build()?;
42 println!("✅ Registry Client built successfully");
43
44 // 3. 获取认证(总是尝试,支持匿名token)
45 println!("🔐 Attempting authentication...");
46 let auth_token = if let (Ok(username), Ok(password)) =
47 (env::var("DOCKER_USERNAME"), env::var("DOCKER_PASSWORD"))
48 {
49 println!(" Using provided credentials for user: {}", username);
50 let auth_config = AuthConfig::new(username, password);
51 client
52 .authenticate_for_repository(&auth_config, &repository)
53 .await?
54 } else {
55 println!(" No credentials provided, trying anonymous authentication...");
56 // 使用直接认证方法尝试获取匿名token
57 let auth = docker_image_pusher::registry::auth::Auth::new();
58 let output = docker_image_pusher::logging::Logger::new(true);
59 auth.authenticate_with_registry(®istry, &repository, None, None, &output)
60 .await?
61 };
62
63 if auth_token.is_some() {
64 println!("✅ Authentication successful");
65 } else {
66 println!("ℹ️ No authentication required");
67 }
68
69 // 4. 定义操作模式
70 let mode = OperationMode::PullAndCache {
71 repository: repository.to_string(),
72 reference: reference.to_string(),
73 };
74
75 println!("📋 Operation Mode: {}", mode.description());
76 println!();
77
78 // 5. 执行拉取和缓存操作
79 println!("🔄 Starting pull and cache operation...");
80 match image_manager
81 .execute_operation(&mode, Some(&client), auth_token.as_deref())
82 .await
83 {
84 Ok(()) => {
85 println!("✅ Pull and cache operation completed successfully!");
86 println!();
87 println!("📂 Image cached to: {}", cache_dir);
88 println!("🔍 You can now inspect the cache contents:");
89 println!(
90 " - Manifests: {}/manifests/{}/{}",
91 cache_dir, repository, reference
92 );
93 println!(" - Blobs: {}/blobs/sha256/", cache_dir);
94 println!(" - Index: {}/index.json", cache_dir);
95 }
96 Err(e) => {
97 eprintln!("❌ Pull and cache operation failed: {}", e);
98 std::process::exit(1);
99 }
100 }
101
102 // 6. 显示缓存统计
103 show_cache_stats(cache_dir).await;
104
105 Ok(())
106}examples/push_to_aliyun_demo.rs (line 46)
11async fn main() -> Result<()> {
12 println!("🚀 Docker Image Pusher - Push to Aliyun Registry Demo");
13 println!("=======================================================");
14
15 // 阿里云配置
16 let aliyun_registry = "registry.cn-beijing.aliyuncs.com";
17 let aliyun_username = "canny_best@163.com";
18 let aliyun_password = "ra201222";
19
20 // 源镜像(从缓存)
21 let source_repository = "yoce/cblt";
22 let source_reference = "yoce";
23
24 // 目标镜像(推送到阿里云)- 推送回同一个仓库,不同tag
25 let target_repository = "yoce/cblt";
26 let target_reference = "push-test";
27 let cache_dir = ".cache_demo";
28
29 println!("📥 Configuration:");
30 println!(
31 " Source (Cache): {}/{}",
32 source_repository, source_reference
33 );
34 println!(" Target Registry: {}", aliyun_registry);
35 println!(" Target Repository: {}", target_repository);
36 println!(" Target Reference: {}", target_reference);
37 println!(" Cache Directory: {}", cache_dir);
38 println!(" Username: {}", aliyun_username);
39 println!();
40
41 // 1. 检查缓存是否存在
42 check_cache_exists(cache_dir, source_repository, source_reference).await?;
43
44 // 2. 创建 ImageManager
45 println!("🔧 Creating ImageManager...");
46 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
47 println!("✅ ImageManager created successfully");
48
49 // 3. 复制缓存中的镜像到目标仓库名称
50 println!("📋 Copying cached image to target repository name...");
51 copy_image_in_cache(
52 cache_dir,
53 source_repository,
54 source_reference,
55 target_repository,
56 target_reference,
57 )
58 .await?;
59 println!("✅ Image copied in cache");
60
61 // 4. 构建 Registry Client for 阿里云
62 println!("🌐 Building Registry Client for Aliyun...");
63 let client = RegistryClientBuilder::new(format!("https://{}", aliyun_registry))
64 .with_timeout(3600)
65 .with_skip_tls(false)
66 .with_verbose(true)
67 .build()?;
68 println!("✅ Registry Client built successfully");
69
70 // 4. 认证到阿里云
71 println!("🔐 Authenticating with Aliyun registry...");
72 let auth_config = AuthConfig::new(aliyun_username.to_string(), aliyun_password.to_string());
73 let auth_token = client
74 .authenticate_for_repository(&auth_config, target_repository)
75 .await?;
76 println!("✅ Authentication successful");
77
78 // 5. 定义操作模式 - 推送缓存中的镜像到阿里云
79 let mode = OperationMode::PushFromCacheUsingManifest {
80 repository: target_repository.to_string(),
81 reference: target_reference.to_string(),
82 };
83
84 println!("📋 Operation Mode: {}", mode.description());
85 println!();
86
87 // 6. 执行推送操作
88 println!("🔄 Starting push to Aliyun operation...");
89 println!(
90 "🎯 Target: {}/{}/{}",
91 aliyun_registry, target_repository, target_reference
92 );
93
94 match image_manager
95 .execute_operation(&mode, Some(&client), auth_token.as_deref())
96 .await
97 {
98 Ok(()) => {
99 println!("✅ Push to Aliyun operation completed successfully!");
100 println!(
101 "🎯 Image pushed to: {}/{}/{}",
102 aliyun_registry, target_repository, target_reference
103 );
104 println!("🔍 You can verify the upload in Aliyun Console:");
105 println!(" https://cr.console.aliyun.com");
106
107 // 验证推送结果
108 verify_push_result(&client, target_repository, target_reference, &auth_token).await;
109 }
110 Err(e) => {
111 eprintln!("❌ Push to Aliyun operation failed: {}", e);
112 eprintln!("💡 Possible solutions:");
113 eprintln!(" - Check Aliyun credentials and permissions");
114 eprintln!(" - Verify repository name format (namespace/repo)");
115 eprintln!(" - Check network connectivity to Aliyun registry");
116 eprintln!(" - Ensure the repository exists in Aliyun console");
117 eprintln!(" - Check if the namespace 'yoce' exists");
118 std::process::exit(1);
119 }
120 }
121
122 Ok(())
123}examples/push_from_cache_manifest_demo.rs (line 41)
13async fn main() -> Result<()> {
14 println!("🚀 Docker Image Pusher - Push from Cache (Manifest) Demo");
15 println!("============================================================");
16
17 // 配置参数 - 使用Aliyun registry,推送到已存在的repository
18 let source_repository = "yoce/cblt"; // 从缓存中读取
19 let source_reference = "yoce";
20 let target_registry = "registry.cn-beijing.aliyuncs.com";
21 let target_repository = "yoce/cblt"; // 推送回同一个repository
22 let target_reference = "test-push"; // 使用新的tag
23 let cache_dir = ".cache_demo";
24
25 println!("📥 Configuration:");
26 println!(
27 " Source (Cache): {}/{}",
28 source_repository, source_reference
29 );
30 println!(" Target Registry: {}", target_registry);
31 println!(" Target Repository: {}", target_repository);
32 println!(" Target Reference: {}", target_reference);
33 println!(" Cache Directory: {}", cache_dir);
34 println!();
35
36 // 1. 检查缓存是否存在
37 check_cache_exists(cache_dir, source_repository, source_reference).await?;
38
39 // 2. 创建 ImageManager
40 println!("🔧 Creating ImageManager...");
41 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
42 println!("✅ ImageManager created successfully");
43
44 // 3. 构建 Registry Client - 配置为Aliyun registry
45 println!("🌐 Building Registry Client for Aliyun registry...");
46 let client = RegistryClientBuilder::new(format!("https://{}", target_registry))
47 .with_timeout(3600)
48 .with_skip_tls(false) // Aliyun registry使用TLS
49 .with_verbose(true)
50 .build()?;
51 println!("✅ Registry Client built successfully");
52
53 // 4. 获取认证 - 使用Aliyun registry凭据
54 println!("🔐 Authenticating with Aliyun registry...");
55 let username = env::var("ALIYUN_USERNAME").unwrap_or_else(|_| "canny_best@163.com".to_string());
56 let password = env::var("ALIYUN_PASSWORD").unwrap_or_else(|_| "ra201222".to_string());
57
58 let auth_config = AuthConfig::new(username.clone(), password.clone());
59 let auth_token = client
60 .authenticate_for_repository(&auth_config, target_repository)
61 .await?;
62 println!("✅ Authentication successful with user: {}", username);
63 println!("🔑 Token scope: repository:{}:pull,push", target_repository);
64
65 // 5. 定义操作模式 - 使用 manifest 方式推送
66 let mode = OperationMode::PushFromCacheUsingManifest {
67 repository: target_repository.to_string(),
68 reference: target_reference.to_string(),
69 };
70
71 println!("📋 Operation Mode: {}", mode.description());
72 println!();
73
74 // 6. 执行推送操作
75 println!("🔄 Starting push from cache operation...");
76 match image_manager
77 .execute_operation(&mode, Some(&client), auth_token.as_deref())
78 .await
79 {
80 Ok(()) => {
81 println!("✅ Push from cache operation completed successfully!");
82 println!();
83 println!(
84 "🎯 Image pushed to: {}/{}/{}",
85 target_registry, target_repository, target_reference
86 );
87 println!("🔍 You can now verify the upload:");
88 println!(
89 " curl -H \"Authorization: Bearer <token>\" https://{}/v2/{}/manifests/{}",
90 target_registry, target_repository, target_reference
91 );
92 println!(
93 " curl -H \"Authorization: Bearer <token>\" https://{}/v2/{}/tags/list",
94 target_registry, target_repository
95 );
96 }
97 Err(e) => {
98 eprintln!("❌ Push from cache operation failed: {}", e);
99 eprintln!("💡 Possible solutions:");
100 eprintln!(
101 " - Check if source image exists in cache: {}/{}",
102 source_repository, source_reference
103 );
104 eprintln!(" - Verify Aliyun registry credentials");
105 eprintln!(" - Check network connectivity to Aliyun registry");
106 std::process::exit(1);
107 }
108 }
109
110 // 7. 验证推送结果
111 verify_push_result(&client, target_repository, target_reference, &auth_token).await;
112
113 Ok(())
114}examples/push_from_cache_tar_demo.rs (line 42)
13async fn main() -> Result<()> {
14 println!("📦 Docker Image Pusher - Push from Cache (Tar Reference) Demo");
15 println!("================================================================");
16
17 // 配置参数
18 let target_registry = "registry.cn-beijing.aliyuncs.com";
19 let target_repository = "yoce/cblt"; // 推送到相同的repository
20 let target_reference = "yoce"; // 推送到相同的reference
21 let cache_dir = ".cache_demo"; // 使用已有的缓存
22
23 println!("📥 Configuration:");
24 println!(" Cache Directory: {}", cache_dir);
25 println!(" Target Registry: {}", target_registry);
26 println!(" Target Repository: {}", target_repository);
27 println!(" Target Reference: {}", target_reference);
28 println!();
29
30 println!(
31 "ℹ️ Note: This mode pushes cached image {}/{} to target registry",
32 target_repository, target_reference
33 );
34 println!(" The implementation is identical to manifest-based push");
35 println!();
36
37 // 1. 检查缓存是否存在
38 check_cache_exists(cache_dir, target_repository, target_reference).await?;
39
40 // 2. 创建 ImageManager
41 println!("🔧 Creating ImageManager...");
42 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
43 println!("✅ ImageManager created successfully");
44
45 // 3. 构建 Registry Client
46 println!("🌐 Building Registry Client for Aliyun registry...");
47 let client = RegistryClientBuilder::new(format!("https://{}", target_registry))
48 .with_timeout(3600)
49 .with_skip_tls(false) // Aliyun uses TLS
50 .with_verbose(true)
51 .build()?;
52 println!("✅ Registry Client built successfully");
53
54 // 4. 获取认证(Aliyun credentials)
55 println!("🔐 Authenticating with Aliyun registry...");
56 let auth_config = AuthConfig::new("canny_best@163.com".to_string(), "ra201222".to_string());
57 let auth_token = client
58 .authenticate_for_repository(&auth_config, target_repository)
59 .await?;
60 println!(
61 "✅ Authentication successful with user: {}",
62 auth_config.username
63 );
64 println!("🔑 Token scope: repository:{}:pull,push", target_repository);
65
66 // 5. 定义操作模式 - 使用 tar 引用方式推送(实际上与manifest模式相同)
67 let mode = OperationMode::PushFromCacheUsingTar {
68 repository: target_repository.to_string(),
69 reference: target_reference.to_string(),
70 };
71
72 println!("📋 Operation Mode: {}", mode.description());
73 println!("🔄 Internal Process: Reading from unified cache format (same as manifest mode)");
74 println!();
75
76 // 6. 执行推送操作
77 println!("🔄 Starting push from cache operation...");
78 match image_manager
79 .execute_operation(&mode, Some(&client), auth_token.as_deref())
80 .await
81 {
82 Ok(()) => {
83 println!("✅ Push from cache (tar reference) operation completed successfully!");
84 println!();
85 println!(
86 "🎯 Image pushed to: {}/{}/{}",
87 target_registry, target_repository, target_reference
88 );
89 println!("🔍 You can now verify the upload:");
90 println!(
91 " curl http://{}/v2/{}/manifests/{}",
92 target_registry, target_repository, target_reference
93 );
94 println!(
95 " curl http://{}/v2/{}/tags/list",
96 target_registry, target_repository
97 );
98
99 // 显示模式差异说明
100 show_mode_explanation();
101 }
102 Err(e) => {
103 eprintln!("❌ Push from cache (tar reference) operation failed: {}", e);
104 eprintln!("💡 Possible solutions:");
105 eprintln!(
106 " - Check if target registry is running: docker run -d -p 5000:5000 registry:2"
107 );
108 eprintln!(" - Verify cache contains the source image");
109 eprintln!(" - Check network connectivity to target registry");
110 std::process::exit(1);
111 }
112 }
113
114 // 7. 验证推送结果并对比两种模式
115 verify_push_result_and_compare(&client, target_repository, target_reference, &auth_token).await;
116
117 Ok(())
118}Additional examples can be found in:
Sourcepub fn with_config(
cache_dir: Option<&str>,
verbose: bool,
use_optimized_upload: bool,
) -> Result<Self>
pub fn with_config( cache_dir: Option<&str>, verbose: bool, use_optimized_upload: bool, ) -> Result<Self>
创建镜像管理器,并允许配置优化选项
Sourcepub async fn execute_operation(
&mut self,
mode: &OperationMode,
client: Option<&RegistryClient>,
auth_token: Option<&str>,
) -> Result<()>
pub async fn execute_operation( &mut self, mode: &OperationMode, client: Option<&RegistryClient>, auth_token: Option<&str>, ) -> Result<()>
执行指定的操作模式 - 统一入口点
Examples found in repository?
examples/extract_and_cache_demo.rs (line 61)
12async fn main() -> Result<()> {
13 println!("📦 Docker Image Pusher - Extract and Cache Demo");
14 println!("===================================================");
15
16 // 配置参数
17 let tar_file = get_tar_file_path();
18 let cache_dir = ".cache_extract_demo";
19
20 // 从tar文件名推导repository和reference
21 let file_stem = Path::new(&tar_file)
22 .file_stem()
23 .and_then(|s| s.to_str())
24 .unwrap_or("extracted-image");
25 let repository = format!("local/{}", file_stem);
26 let reference = "latest";
27
28 println!("📥 Configuration:");
29 println!(" Tar File: {}", tar_file);
30 println!(" Repository: {}", repository);
31 println!(" Reference: {}", reference);
32 println!(" Cache Directory: {}", cache_dir);
33 println!();
34
35 // 1. 验证tar文件存在
36 if !Path::new(&tar_file).exists() {
37 eprintln!("❌ Tar file not found: {}", tar_file);
38 eprintln!("💡 Please ensure the dufs.tar file exists in the examples/ directory");
39 return Err(docker_image_pusher::error::RegistryError::Validation(
40 format!("Tar file does not exist: {}", tar_file),
41 ));
42 }
43
44 // 2. 创建 ImageManager
45 println!("🔧 Creating ImageManager...");
46 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
47 println!("✅ ImageManager created successfully");
48
49 // 3. 定义操作模式
50 let mode = OperationMode::ExtractAndCache {
51 tar_file: tar_file.clone(),
52 repository: repository.clone(),
53 reference: reference.to_string(),
54 };
55
56 println!("📋 Operation Mode: {}", mode.description());
57 println!();
58
59 // 4. 执行提取和缓存操作
60 println!("🔄 Starting extract and cache operation...");
61 match image_manager.execute_operation(&mode, None, None).await {
62 Ok(()) => {
63 println!("✅ Extract and cache operation completed successfully!");
64 println!();
65 println!("📂 Image extracted and cached to: {}", cache_dir);
66 println!("🔍 You can now inspect the cache contents:");
67 println!(
68 " - Manifests: {}/manifests/{}/{}",
69 cache_dir, repository, reference
70 );
71 println!(" - Blobs: {}/blobs/sha256/", cache_dir);
72 println!(" - Index: {}/index.json", cache_dir);
73 }
74 Err(e) => {
75 eprintln!("❌ Extract and cache operation failed: {}", e);
76 std::process::exit(1);
77 }
78 }
79
80 // 5. 显示提取统计
81 show_extraction_stats(&tar_file, cache_dir).await;
82
83 Ok(())
84}More examples
examples/pull_and_cache_demo.rs (line 81)
13async fn main() -> Result<()> {
14 println!("🚀 Docker Image Pusher - Pull and Cache Demo");
15 println!("==================================================");
16
17 // 配置参数 - 支持环境变量
18 let registry = env::var("DOCKER_REGISTRY")
19 .unwrap_or_else(|_| "https://registry.cn-beijing.aliyuncs.com".to_string());
20 let repository = env::var("DOCKER_REPOSITORY").unwrap_or_else(|_| "yoce/cblt".to_string());
21 let reference = env::var("DOCKER_REFERENCE").unwrap_or_else(|_| "yoce".to_string());
22 let cache_dir = ".cache_demo";
23
24 println!("📥 Configuration:");
25 println!(" Registry: {}", registry);
26 println!(" Repository: {}", repository);
27 println!(" Reference: {}", reference);
28 println!(" Cache Directory: {}", cache_dir);
29 println!();
30
31 // 1. 创建 ImageManager
32 println!("🔧 Creating ImageManager...");
33 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
34 println!("✅ ImageManager created successfully");
35
36 // 2. 构建 Registry Client
37 println!("🌐 Building Registry Client...");
38 let client = RegistryClientBuilder::new(registry.to_string())
39 .with_timeout(3600)
40 .with_verbose(true)
41 .build()?;
42 println!("✅ Registry Client built successfully");
43
44 // 3. 获取认证(总是尝试,支持匿名token)
45 println!("🔐 Attempting authentication...");
46 let auth_token = if let (Ok(username), Ok(password)) =
47 (env::var("DOCKER_USERNAME"), env::var("DOCKER_PASSWORD"))
48 {
49 println!(" Using provided credentials for user: {}", username);
50 let auth_config = AuthConfig::new(username, password);
51 client
52 .authenticate_for_repository(&auth_config, &repository)
53 .await?
54 } else {
55 println!(" No credentials provided, trying anonymous authentication...");
56 // 使用直接认证方法尝试获取匿名token
57 let auth = docker_image_pusher::registry::auth::Auth::new();
58 let output = docker_image_pusher::logging::Logger::new(true);
59 auth.authenticate_with_registry(®istry, &repository, None, None, &output)
60 .await?
61 };
62
63 if auth_token.is_some() {
64 println!("✅ Authentication successful");
65 } else {
66 println!("ℹ️ No authentication required");
67 }
68
69 // 4. 定义操作模式
70 let mode = OperationMode::PullAndCache {
71 repository: repository.to_string(),
72 reference: reference.to_string(),
73 };
74
75 println!("📋 Operation Mode: {}", mode.description());
76 println!();
77
78 // 5. 执行拉取和缓存操作
79 println!("🔄 Starting pull and cache operation...");
80 match image_manager
81 .execute_operation(&mode, Some(&client), auth_token.as_deref())
82 .await
83 {
84 Ok(()) => {
85 println!("✅ Pull and cache operation completed successfully!");
86 println!();
87 println!("📂 Image cached to: {}", cache_dir);
88 println!("🔍 You can now inspect the cache contents:");
89 println!(
90 " - Manifests: {}/manifests/{}/{}",
91 cache_dir, repository, reference
92 );
93 println!(" - Blobs: {}/blobs/sha256/", cache_dir);
94 println!(" - Index: {}/index.json", cache_dir);
95 }
96 Err(e) => {
97 eprintln!("❌ Pull and cache operation failed: {}", e);
98 std::process::exit(1);
99 }
100 }
101
102 // 6. 显示缓存统计
103 show_cache_stats(cache_dir).await;
104
105 Ok(())
106}examples/push_to_aliyun_demo.rs (line 95)
11async fn main() -> Result<()> {
12 println!("🚀 Docker Image Pusher - Push to Aliyun Registry Demo");
13 println!("=======================================================");
14
15 // 阿里云配置
16 let aliyun_registry = "registry.cn-beijing.aliyuncs.com";
17 let aliyun_username = "canny_best@163.com";
18 let aliyun_password = "ra201222";
19
20 // 源镜像(从缓存)
21 let source_repository = "yoce/cblt";
22 let source_reference = "yoce";
23
24 // 目标镜像(推送到阿里云)- 推送回同一个仓库,不同tag
25 let target_repository = "yoce/cblt";
26 let target_reference = "push-test";
27 let cache_dir = ".cache_demo";
28
29 println!("📥 Configuration:");
30 println!(
31 " Source (Cache): {}/{}",
32 source_repository, source_reference
33 );
34 println!(" Target Registry: {}", aliyun_registry);
35 println!(" Target Repository: {}", target_repository);
36 println!(" Target Reference: {}", target_reference);
37 println!(" Cache Directory: {}", cache_dir);
38 println!(" Username: {}", aliyun_username);
39 println!();
40
41 // 1. 检查缓存是否存在
42 check_cache_exists(cache_dir, source_repository, source_reference).await?;
43
44 // 2. 创建 ImageManager
45 println!("🔧 Creating ImageManager...");
46 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
47 println!("✅ ImageManager created successfully");
48
49 // 3. 复制缓存中的镜像到目标仓库名称
50 println!("📋 Copying cached image to target repository name...");
51 copy_image_in_cache(
52 cache_dir,
53 source_repository,
54 source_reference,
55 target_repository,
56 target_reference,
57 )
58 .await?;
59 println!("✅ Image copied in cache");
60
61 // 4. 构建 Registry Client for 阿里云
62 println!("🌐 Building Registry Client for Aliyun...");
63 let client = RegistryClientBuilder::new(format!("https://{}", aliyun_registry))
64 .with_timeout(3600)
65 .with_skip_tls(false)
66 .with_verbose(true)
67 .build()?;
68 println!("✅ Registry Client built successfully");
69
70 // 4. 认证到阿里云
71 println!("🔐 Authenticating with Aliyun registry...");
72 let auth_config = AuthConfig::new(aliyun_username.to_string(), aliyun_password.to_string());
73 let auth_token = client
74 .authenticate_for_repository(&auth_config, target_repository)
75 .await?;
76 println!("✅ Authentication successful");
77
78 // 5. 定义操作模式 - 推送缓存中的镜像到阿里云
79 let mode = OperationMode::PushFromCacheUsingManifest {
80 repository: target_repository.to_string(),
81 reference: target_reference.to_string(),
82 };
83
84 println!("📋 Operation Mode: {}", mode.description());
85 println!();
86
87 // 6. 执行推送操作
88 println!("🔄 Starting push to Aliyun operation...");
89 println!(
90 "🎯 Target: {}/{}/{}",
91 aliyun_registry, target_repository, target_reference
92 );
93
94 match image_manager
95 .execute_operation(&mode, Some(&client), auth_token.as_deref())
96 .await
97 {
98 Ok(()) => {
99 println!("✅ Push to Aliyun operation completed successfully!");
100 println!(
101 "🎯 Image pushed to: {}/{}/{}",
102 aliyun_registry, target_repository, target_reference
103 );
104 println!("🔍 You can verify the upload in Aliyun Console:");
105 println!(" https://cr.console.aliyun.com");
106
107 // 验证推送结果
108 verify_push_result(&client, target_repository, target_reference, &auth_token).await;
109 }
110 Err(e) => {
111 eprintln!("❌ Push to Aliyun operation failed: {}", e);
112 eprintln!("💡 Possible solutions:");
113 eprintln!(" - Check Aliyun credentials and permissions");
114 eprintln!(" - Verify repository name format (namespace/repo)");
115 eprintln!(" - Check network connectivity to Aliyun registry");
116 eprintln!(" - Ensure the repository exists in Aliyun console");
117 eprintln!(" - Check if the namespace 'yoce' exists");
118 std::process::exit(1);
119 }
120 }
121
122 Ok(())
123}examples/push_from_cache_manifest_demo.rs (line 77)
13async fn main() -> Result<()> {
14 println!("🚀 Docker Image Pusher - Push from Cache (Manifest) Demo");
15 println!("============================================================");
16
17 // 配置参数 - 使用Aliyun registry,推送到已存在的repository
18 let source_repository = "yoce/cblt"; // 从缓存中读取
19 let source_reference = "yoce";
20 let target_registry = "registry.cn-beijing.aliyuncs.com";
21 let target_repository = "yoce/cblt"; // 推送回同一个repository
22 let target_reference = "test-push"; // 使用新的tag
23 let cache_dir = ".cache_demo";
24
25 println!("📥 Configuration:");
26 println!(
27 " Source (Cache): {}/{}",
28 source_repository, source_reference
29 );
30 println!(" Target Registry: {}", target_registry);
31 println!(" Target Repository: {}", target_repository);
32 println!(" Target Reference: {}", target_reference);
33 println!(" Cache Directory: {}", cache_dir);
34 println!();
35
36 // 1. 检查缓存是否存在
37 check_cache_exists(cache_dir, source_repository, source_reference).await?;
38
39 // 2. 创建 ImageManager
40 println!("🔧 Creating ImageManager...");
41 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
42 println!("✅ ImageManager created successfully");
43
44 // 3. 构建 Registry Client - 配置为Aliyun registry
45 println!("🌐 Building Registry Client for Aliyun registry...");
46 let client = RegistryClientBuilder::new(format!("https://{}", target_registry))
47 .with_timeout(3600)
48 .with_skip_tls(false) // Aliyun registry使用TLS
49 .with_verbose(true)
50 .build()?;
51 println!("✅ Registry Client built successfully");
52
53 // 4. 获取认证 - 使用Aliyun registry凭据
54 println!("🔐 Authenticating with Aliyun registry...");
55 let username = env::var("ALIYUN_USERNAME").unwrap_or_else(|_| "canny_best@163.com".to_string());
56 let password = env::var("ALIYUN_PASSWORD").unwrap_or_else(|_| "ra201222".to_string());
57
58 let auth_config = AuthConfig::new(username.clone(), password.clone());
59 let auth_token = client
60 .authenticate_for_repository(&auth_config, target_repository)
61 .await?;
62 println!("✅ Authentication successful with user: {}", username);
63 println!("🔑 Token scope: repository:{}:pull,push", target_repository);
64
65 // 5. 定义操作模式 - 使用 manifest 方式推送
66 let mode = OperationMode::PushFromCacheUsingManifest {
67 repository: target_repository.to_string(),
68 reference: target_reference.to_string(),
69 };
70
71 println!("📋 Operation Mode: {}", mode.description());
72 println!();
73
74 // 6. 执行推送操作
75 println!("🔄 Starting push from cache operation...");
76 match image_manager
77 .execute_operation(&mode, Some(&client), auth_token.as_deref())
78 .await
79 {
80 Ok(()) => {
81 println!("✅ Push from cache operation completed successfully!");
82 println!();
83 println!(
84 "🎯 Image pushed to: {}/{}/{}",
85 target_registry, target_repository, target_reference
86 );
87 println!("🔍 You can now verify the upload:");
88 println!(
89 " curl -H \"Authorization: Bearer <token>\" https://{}/v2/{}/manifests/{}",
90 target_registry, target_repository, target_reference
91 );
92 println!(
93 " curl -H \"Authorization: Bearer <token>\" https://{}/v2/{}/tags/list",
94 target_registry, target_repository
95 );
96 }
97 Err(e) => {
98 eprintln!("❌ Push from cache operation failed: {}", e);
99 eprintln!("💡 Possible solutions:");
100 eprintln!(
101 " - Check if source image exists in cache: {}/{}",
102 source_repository, source_reference
103 );
104 eprintln!(" - Verify Aliyun registry credentials");
105 eprintln!(" - Check network connectivity to Aliyun registry");
106 std::process::exit(1);
107 }
108 }
109
110 // 7. 验证推送结果
111 verify_push_result(&client, target_repository, target_reference, &auth_token).await;
112
113 Ok(())
114}examples/push_from_cache_tar_demo.rs (line 79)
13async fn main() -> Result<()> {
14 println!("📦 Docker Image Pusher - Push from Cache (Tar Reference) Demo");
15 println!("================================================================");
16
17 // 配置参数
18 let target_registry = "registry.cn-beijing.aliyuncs.com";
19 let target_repository = "yoce/cblt"; // 推送到相同的repository
20 let target_reference = "yoce"; // 推送到相同的reference
21 let cache_dir = ".cache_demo"; // 使用已有的缓存
22
23 println!("📥 Configuration:");
24 println!(" Cache Directory: {}", cache_dir);
25 println!(" Target Registry: {}", target_registry);
26 println!(" Target Repository: {}", target_repository);
27 println!(" Target Reference: {}", target_reference);
28 println!();
29
30 println!(
31 "ℹ️ Note: This mode pushes cached image {}/{} to target registry",
32 target_repository, target_reference
33 );
34 println!(" The implementation is identical to manifest-based push");
35 println!();
36
37 // 1. 检查缓存是否存在
38 check_cache_exists(cache_dir, target_repository, target_reference).await?;
39
40 // 2. 创建 ImageManager
41 println!("🔧 Creating ImageManager...");
42 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
43 println!("✅ ImageManager created successfully");
44
45 // 3. 构建 Registry Client
46 println!("🌐 Building Registry Client for Aliyun registry...");
47 let client = RegistryClientBuilder::new(format!("https://{}", target_registry))
48 .with_timeout(3600)
49 .with_skip_tls(false) // Aliyun uses TLS
50 .with_verbose(true)
51 .build()?;
52 println!("✅ Registry Client built successfully");
53
54 // 4. 获取认证(Aliyun credentials)
55 println!("🔐 Authenticating with Aliyun registry...");
56 let auth_config = AuthConfig::new("canny_best@163.com".to_string(), "ra201222".to_string());
57 let auth_token = client
58 .authenticate_for_repository(&auth_config, target_repository)
59 .await?;
60 println!(
61 "✅ Authentication successful with user: {}",
62 auth_config.username
63 );
64 println!("🔑 Token scope: repository:{}:pull,push", target_repository);
65
66 // 5. 定义操作模式 - 使用 tar 引用方式推送(实际上与manifest模式相同)
67 let mode = OperationMode::PushFromCacheUsingTar {
68 repository: target_repository.to_string(),
69 reference: target_reference.to_string(),
70 };
71
72 println!("📋 Operation Mode: {}", mode.description());
73 println!("🔄 Internal Process: Reading from unified cache format (same as manifest mode)");
74 println!();
75
76 // 6. 执行推送操作
77 println!("🔄 Starting push from cache operation...");
78 match image_manager
79 .execute_operation(&mode, Some(&client), auth_token.as_deref())
80 .await
81 {
82 Ok(()) => {
83 println!("✅ Push from cache (tar reference) operation completed successfully!");
84 println!();
85 println!(
86 "🎯 Image pushed to: {}/{}/{}",
87 target_registry, target_repository, target_reference
88 );
89 println!("🔍 You can now verify the upload:");
90 println!(
91 " curl http://{}/v2/{}/manifests/{}",
92 target_registry, target_repository, target_reference
93 );
94 println!(
95 " curl http://{}/v2/{}/tags/list",
96 target_registry, target_repository
97 );
98
99 // 显示模式差异说明
100 show_mode_explanation();
101 }
102 Err(e) => {
103 eprintln!("❌ Push from cache (tar reference) operation failed: {}", e);
104 eprintln!("💡 Possible solutions:");
105 eprintln!(
106 " - Check if target registry is running: docker run -d -p 5000:5000 registry:2"
107 );
108 eprintln!(" - Verify cache contains the source image");
109 eprintln!(" - Check network connectivity to target registry");
110 std::process::exit(1);
111 }
112 }
113
114 // 7. 验证推送结果并对比两种模式
115 verify_push_result_and_compare(&client, target_repository, target_reference, &auth_token).await;
116
117 Ok(())
118}examples/comprehensive_demo.rs (line 82)
56async fn run_comprehensive_demo(cache_dir: &str, target_registry: &str) -> Result<()> {
57 // =========================================================================
58 // 模式1: PullAndCache - 从registry拉取并缓存
59 // =========================================================================
60 println!("📥 MODE 1: Pull and Cache from Registry");
61 println!("========================================");
62
63 let pull_start = Instant::now();
64
65 // 创建ImageManager
66 let mut image_manager = ImageManager::new(Some(cache_dir), true)?;
67
68 // 构建registry client
69 let source_client = RegistryClientBuilder::new("https://registry-1.docker.io".to_string())
70 .with_timeout(3600)
71 .with_verbose(true)
72 .build()?;
73
74 // 定义拉取操作
75 let pull_mode = OperationMode::PullAndCache {
76 repository: "library/hello-world".to_string(),
77 reference: "latest".to_string(),
78 };
79
80 println!("🔄 Executing: {}", pull_mode.description());
81 image_manager
82 .execute_operation(&pull_mode, Some(&source_client), None)
83 .await?;
84
85 let pull_duration = pull_start.elapsed();
86 println!("✅ Mode 1 completed in {:.2}s", pull_duration.as_secs_f64());
87 println!();
88
89 // =========================================================================
90 // 模式2: ExtractAndCache - 从tar文件提取并缓存
91 // =========================================================================
92 println!("📦 MODE 2: Extract and Cache from Tar File");
93 println!("===========================================");
94
95 let extract_start = Instant::now();
96
97 // 创建示例tar文件
98 let tar_file = "nginx-demo.tar";
99 create_demo_tar_file(tar_file, "nginx:alpine").await?;
100
101 // 定义提取操作
102 let extract_mode = OperationMode::ExtractAndCache {
103 tar_file: tar_file.to_string(),
104 repository: "local/nginx".to_string(),
105 reference: "alpine".to_string(),
106 };
107
108 println!("🔄 Executing: {}", extract_mode.description());
109 image_manager
110 .execute_operation(&extract_mode, None, None)
111 .await?;
112
113 let extract_duration = extract_start.elapsed();
114 println!(
115 "✅ Mode 2 completed in {:.2}s",
116 extract_duration.as_secs_f64()
117 );
118 println!();
119
120 // =========================================================================
121 // 准备目标registry客户端
122 // =========================================================================
123 println!("🌐 Setting up target registry...");
124 ensure_target_registry_running(target_registry).await;
125
126 let target_client = RegistryClientBuilder::new(format!("http://{}", target_registry))
127 .with_timeout(3600)
128 .with_skip_tls(true)
129 .with_verbose(true)
130 .build()?;
131
132 // =========================================================================
133 // 模式3: PushFromCacheUsingManifest - 从缓存推送(manifest方式)
134 // =========================================================================
135 println!("🚀 MODE 3: Push from Cache using Manifest");
136 println!("==========================================");
137
138 let push_manifest_start = Instant::now();
139
140 // 定义推送操作(manifest方式)
141 let push_manifest_mode = OperationMode::PushFromCacheUsingManifest {
142 repository: "demo/hello-world-manifest".to_string(),
143 reference: "v1.0".to_string(),
144 };
145
146 println!("🔄 Executing: {}", push_manifest_mode.description());
147 image_manager
148 .execute_operation(&push_manifest_mode, Some(&target_client), None)
149 .await?;
150
151 let push_manifest_duration = push_manifest_start.elapsed();
152 println!(
153 "✅ Mode 3 completed in {:.2}s",
154 push_manifest_duration.as_secs_f64()
155 );
156 println!();
157
158 // =========================================================================
159 // 模式4: PushFromCacheUsingTar - 从缓存推送(tar引用方式)
160 // =========================================================================
161 println!("📦 MODE 4: Push from Cache using Tar Reference");
162 println!("===============================================");
163
164 let push_tar_start = Instant::now();
165
166 // 定义推送操作(tar引用方式)
167 let push_tar_mode = OperationMode::PushFromCacheUsingTar {
168 repository: "demo/nginx-tar-ref".to_string(),
169 reference: "alpine".to_string(),
170 };
171
172 println!("🔄 Executing: {}", push_tar_mode.description());
173 image_manager
174 .execute_operation(&push_tar_mode, Some(&target_client), None)
175 .await?;
176
177 let push_tar_duration = push_tar_start.elapsed();
178 println!(
179 "✅ Mode 4 completed in {:.2}s",
180 push_tar_duration.as_secs_f64()
181 );
182 println!();
183
184 // 验证所有推送结果
185 verify_all_pushes(&target_client, target_registry).await;
186
187 Ok(())
188}Additional examples can be found in:
Sourcepub fn get_cache_stats(&self) -> Result<CacheStats>
pub fn get_cache_stats(&self) -> Result<CacheStats>
获取缓存统计信息
Sourcepub fn list_cached_images(&self) -> Vec<(String, String)>
pub fn list_cached_images(&self) -> Vec<(String, String)>
列出缓存中的所有镜像
Sourcepub fn configure_pipeline(&mut self, config: PipelineConfig)
pub fn configure_pipeline(&mut self, config: PipelineConfig)
配置流式处理管道参数
Examples found in repository?
examples/optimized_upload_demo.rs (line 29)
10async fn main() -> Result<()> {
11 println!("Docker Image Pusher - Optimized Upload Demo");
12
13 // Create image manager with optimizations enabled (default)
14 let mut manager = ImageManager::new(None, true)?;
15
16 // Configure pipeline for demonstration
17 let config = PipelineConfig {
18 max_concurrent: 8,
19 buffer_size: 1024,
20 small_blob_threshold: 10 * 1024 * 1024, // 10MB
21 medium_blob_threshold: 100 * 1024 * 1024, // 100MB
22 large_blob_threshold: 500 * 1024 * 1024, // 500MB
23 timeout_seconds: 7200,
24 retry_attempts: 3,
25 memory_limit_mb: 512,
26 enable_compression: true,
27 enable_streaming: true,
28 };
29 manager.configure_pipeline(config);
30
31 // Verify configuration
32 let (optimized, pipeline_config) = manager.get_config();
33 println!("Optimized mode: {}", optimized);
34 println!("Pipeline config: {:?}", pipeline_config);
35
36 // Example registry client (would need real registry URL)
37 let client = RegistryClientBuilder::new("https://registry.example.com".to_string())
38 .with_verbose(true)
39 .build()?;
40
41 // Test connectivity (this would fail with example URL)
42 println!("Testing registry connectivity...");
43 match client.test_connectivity().await {
44 Ok(_) => println!("✓ Registry connectivity successful"),
45 Err(e) => println!(
46 "✗ Registry connectivity failed: {} (expected with example URL)",
47 e
48 ),
49 }
50
51 // Example operation mode for pushing from tar
52 let mode = OperationMode::PushFromTar {
53 tar_file: "example-image.tar".to_string(),
54 repository: "myapp".to_string(),
55 reference: "latest".to_string(),
56 };
57
58 println!("Operation mode: {}", mode.description());
59
60 // In a real scenario, you would call:
61 // manager.execute_operation(&mode, Some(&client), None).await?;
62
63 println!("Demo completed successfully!");
64 println!("\nKey benefits of optimized mode:");
65 println!("• Priority-based upload scheduling (small blobs first)");
66 println!("• Streaming TAR processing with parallel uploads");
67 println!("• Memory-efficient processing of large files");
68 println!("• Configurable pipeline parameters");
69
70 Ok(())
71}Sourcepub fn set_optimized_upload(&mut self, enabled: bool)
pub fn set_optimized_upload(&mut self, enabled: bool)
设置是否使用优化的上传模式
Sourcepub fn get_config(&self) -> (bool, &PipelineConfig)
pub fn get_config(&self) -> (bool, &PipelineConfig)
获取当前配置状态
Examples found in repository?
examples/optimized_upload_demo.rs (line 32)
10async fn main() -> Result<()> {
11 println!("Docker Image Pusher - Optimized Upload Demo");
12
13 // Create image manager with optimizations enabled (default)
14 let mut manager = ImageManager::new(None, true)?;
15
16 // Configure pipeline for demonstration
17 let config = PipelineConfig {
18 max_concurrent: 8,
19 buffer_size: 1024,
20 small_blob_threshold: 10 * 1024 * 1024, // 10MB
21 medium_blob_threshold: 100 * 1024 * 1024, // 100MB
22 large_blob_threshold: 500 * 1024 * 1024, // 500MB
23 timeout_seconds: 7200,
24 retry_attempts: 3,
25 memory_limit_mb: 512,
26 enable_compression: true,
27 enable_streaming: true,
28 };
29 manager.configure_pipeline(config);
30
31 // Verify configuration
32 let (optimized, pipeline_config) = manager.get_config();
33 println!("Optimized mode: {}", optimized);
34 println!("Pipeline config: {:?}", pipeline_config);
35
36 // Example registry client (would need real registry URL)
37 let client = RegistryClientBuilder::new("https://registry.example.com".to_string())
38 .with_verbose(true)
39 .build()?;
40
41 // Test connectivity (this would fail with example URL)
42 println!("Testing registry connectivity...");
43 match client.test_connectivity().await {
44 Ok(_) => println!("✓ Registry connectivity successful"),
45 Err(e) => println!(
46 "✗ Registry connectivity failed: {} (expected with example URL)",
47 e
48 ),
49 }
50
51 // Example operation mode for pushing from tar
52 let mode = OperationMode::PushFromTar {
53 tar_file: "example-image.tar".to_string(),
54 repository: "myapp".to_string(),
55 reference: "latest".to_string(),
56 };
57
58 println!("Operation mode: {}", mode.description());
59
60 // In a real scenario, you would call:
61 // manager.execute_operation(&mode, Some(&client), None).await?;
62
63 println!("Demo completed successfully!");
64 println!("\nKey benefits of optimized mode:");
65 println!("• Priority-based upload scheduling (small blobs first)");
66 println!("• Streaming TAR processing with parallel uploads");
67 println!("• Memory-efficient processing of large files");
68 println!("• Configurable pipeline parameters");
69
70 Ok(())
71}Auto Trait Implementations§
impl Freeze for ImageManager
impl RefUnwindSafe for ImageManager
impl Send for ImageManager
impl Sync for ImageManager
impl Unpin for ImageManager
impl UnwindSafe for ImageManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more