This commit is contained in:
sparkzky 2025-02-27 22:34:50 +08:00
parent 377d649d4e
commit a04fd9b185
6 changed files with 13 additions and 17 deletions

2
Cargo.lock generated
View File

@ -1699,8 +1699,8 @@ dependencies = [
"env_logger",
"hex",
"log",
"oci-spec",
"my-workspace-hack",
"oci-spec",
"prost-types",
"serde",
"serde_json",

View File

@ -1,5 +1,5 @@
use crate::types::*;
use actix_web::{web, HttpResponse, Responder};
use actix_web::{HttpResponse, Responder, web};
use service::Service;
use std::sync::Arc;
@ -36,4 +36,4 @@ pub async fn get_container_list(
HttpResponse::Ok().json(container_list)
}
// 添加更多的路由处理函数...
// 添加更多的路由处理函数...

View File

@ -1,6 +1,6 @@
use std::sync::Arc;
use actix_web::{web, App, HttpServer};
use actix_web::{App, HttpServer, web};
use service::Service;
pub mod handlers;
@ -29,4 +29,4 @@ async fn main() -> std::io::Result<()> {
.bind("0.0.0.0:18080")?
.run()
.await
}
}

View File

@ -17,4 +17,4 @@ pub struct RemoveContainerInfo {
pub struct GetContainerListQuery {
pub status: Option<String>,
pub ns: String,
}
}

View File

@ -1,16 +1,17 @@
pub mod spec;
use containerd_client::{
Client,
services::v1::{
container::Runtime,
snapshots::{MountsRequest, PrepareSnapshotRequest},
Container, CreateContainerRequest, CreateTaskRequest, DeleteContainerRequest,
DeleteTaskRequest, GetImageRequest, KillRequest, ListContainersRequest, ListTasksRequest,
ReadContentRequest, StartRequest, WaitRequest,
container::Runtime,
snapshots::{MountsRequest, PrepareSnapshotRequest},
},
tonic::Request,
types::Mount,
with_namespace, Client,
with_namespace,
};
use oci_spec::image::{Arch, ImageConfiguration, ImageIndex, ImageManifest, MediaType, Os};
use prost_types::Any;
@ -63,12 +64,7 @@ impl Service {
Ok(resp)
}
pub async fn create_container(
&self,
image_name: &str,
cid: &str,
ns: &str,
) -> Result<(), Err> {
pub async fn create_container(&self, image_name: &str, cid: &str, ns: &str) -> Result<(), Err> {
let namespace = match ns {
"" => spec::DEFAULT_NAMESPACE,
_ => ns,
@ -524,4 +520,4 @@ impl Service {
}
}
//容器是容器,要先启动,然后才能运行任务
//要想删除一个正在运行的Task必须先kill掉这个task然后才能删除。
//要想删除一个正在运行的Task必须先kill掉这个task然后才能删除。

View File

@ -315,4 +315,4 @@ pub fn generate_spec(id: &str, ns: &str) -> Result<String, std::io::Error> {
let path = format!("{}/{}/{}.json", PATH_TO_SPEC_PREFIX, namespace, id);
save_spec_to_file(&spec, &path)?;
Ok(path)
}
}