Skip to content

Commit

Permalink
p
Browse files Browse the repository at this point in the history
  • Loading branch information
anonkey committed Dec 20, 2023
1 parent 167b27a commit d10133a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 81 deletions.
77 changes: 0 additions & 77 deletions bin/nanocld/src/services/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,82 +136,6 @@ pub(crate) async fn delete_cargo(
let key = utils::key::gen_key(&namespace, &path.1);
log::debug!("service::delete_cargo: {key}");
utils::cargo::delete_by_key(&key, qs.force, &state).await?;
<<<<<<< HEAD
||||||| parent of 03afd9ff (p)
rt::spawn(async move {
let _ = state
.event_emitter
.emit(Event::CargoDeleted(Box::new(cargo)))
.await;
});
Ok(web::HttpResponse::Accepted().finish())
}

/// Start a cargo
#[cfg_attr(feature = "dev", utoipa::path(
post,
tag = "Cargoes",
path = "/cargoes/{Name}/start",
params(
("Name" = String, Path, description = "Name of the cargo"),
("Namespace" = Option<String>, Query, description = "Namespace of the cargo"),
),
responses(
(status = 202, description = "Cargo started"),
(status = 404, description = "Cargo does not exist"),
),
))]
#[web::post("/cargoes/{name}/start")]
pub(crate) async fn start_cargo(
web::types::Query(qs): web::types::Query<GenericNspQuery>,
path: web::types::Path<(String, String)>,
state: web::types::State<DaemonState>,
) -> Result<web::HttpResponse, HttpError> {
let namespace = utils::key::resolve_nsp(&qs.namespace);
let key = utils::key::gen_key(&namespace, &path.1);
utils::cargo::start_by_key(&key, &state).await?;
rt::spawn(async move {
let cargo = utils::cargo::inspect_by_key(&key, &state).await.unwrap();
let _ = state
.event_emitter
.emit(Event::CargoStarted(Box::new(cargo)))
.await;
});
Ok(web::HttpResponse::Accepted().finish())
}

/// Stop a cargo
#[cfg_attr(feature = "dev", utoipa::path(
post,
tag = "Cargoes",
path = "/cargoes/{Name}/stop",
params(
("Name" = String, Path, description = "Name of the cargo"),
("Namespace" = Option<String>, Query, description = "Namespace of the cargo"),
),
responses(
(status = 202, description = "Cargo stopped"),
(status = 404, description = "Cargo does not exist"),
),
))]
#[web::post("/cargoes/{name}/stop")]
pub(crate) async fn stop_cargo(
web::types::Query(qs): web::types::Query<GenericNspQuery>,
path: web::types::Path<(String, String)>,
state: web::types::State<DaemonState>,
) -> Result<web::HttpResponse, HttpError> {
let namespace = utils::key::resolve_nsp(&qs.namespace);
let key = utils::key::gen_key(&namespace, &path.1);
utils::cargo::inspect_by_key(&key, &state).await?;
utils::cargo::stop_by_key(&key, &state.docker_api).await?;
rt::spawn(async move {
let cargo = utils::cargo::inspect_by_key(&key, &state).await.unwrap();
let _ = state
.event_emitter
.emit(Event::CargoStopped(Box::new(cargo)))
.await;
});
=======
rt::spawn(async move {
let _ = state
.event_emitter
Expand Down Expand Up @@ -291,7 +215,6 @@ pub(crate) async fn stop_cargo(
.emit(Event::CargoStopped(Box::new(cargo)))
.await;
});
>>>>>>> 03afd9ff (p)
Ok(web::HttpResponse::Accepted().finish())
}

Expand Down
8 changes: 4 additions & 4 deletions crates/nanocl_stubs/src/cert_manager.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use serde::{Serialize, Deserialize};

use crate::cargo_config::CargoConfigPartial;
use crate::cargo_spec::CargoSpecPartial;

/// Defines a CertManagerIssuer config
/// Defines a CertManagerIssuer spec
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "PascalCase"))]
pub struct CertManagerIssuer {
/// Certificate generation CargoConfig
pub generate: CargoConfigPartial,
/// Certificate generation CargoSpec
pub generate: CargoSpecPartial,
}

0 comments on commit d10133a

Please sign in to comment.