Skip to content

Commit

Permalink
Merge branch 'nightly' into release/nightly/bin/ncproxy/0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leon3s committed Jun 7, 2024
2 parents 59d71a7 + c1f94f8 commit 77d4e51
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 185 deletions.
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/nanocl/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `HOST` env variable to override the default host
- `CERT` and `CERT_KEY` env variable to pass certificate and certificate key to the client
- `nanocl state apply --remove-orphans` to remove orphaned objects
- `nanocl secret create tls` now accept path to the certificate and key

### Fixed

Expand Down
22 changes: 22 additions & 0 deletions bin/nanocl/src/models/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct EnvCreateOpts {

/// Create a new nanocl.io/tls secret
#[derive(Clone, Parser, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct TlsCreateOpts {
/// Certificate
#[clap(long)]
Expand All @@ -63,6 +64,7 @@ pub struct TlsCreateOpts {

/// Create a new nanocl.io/container-registry secret
#[derive(Clone, Parser, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ContainerRegistryCreateOpts {
pub username: Option<String>,
pub password: Option<String>,
Expand All @@ -81,6 +83,26 @@ impl TryFrom<SecretCreateOpts> for SecretPartial {
("nanocl.io/env", serde_json::to_value(&env.values)?)
}
SecretKindCreateCommand::Tls(tls) => {
let mut cert = tls.certificate.clone();
let mut cert_key = tls.certificate_key.clone();
let mut cert_client = tls.certificate_client.clone();
if std::path::Path::new(&cert).exists() {
cert = std::fs::read_to_string(&cert)?;
}
if std::path::Path::new(&cert_key).exists() {
cert_key = std::fs::read_to_string(&cert_key)?;
}
if let Some(ca) = &cert_client {
if std::path::Path::new(ca).exists() {
cert_client = Some(std::fs::read_to_string(ca)?);
}
}
let tls = TlsCreateOpts {
certificate: cert,
certificate_key: cert_key,
certificate_client: cert_client,
..tls.to_owned()
};
("nanocl.io/tls", serde_json::to_value(tls)?)
}
SecretKindCreateCommand::ContainerRegistry(container_registry) => (
Expand Down
81 changes: 42 additions & 39 deletions bin/nanocld/src/system/docker_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,46 +107,49 @@ async fn exec_docker(
}
}
"die" => {
let actual_status =
ObjPsStatusDb::read_by_pk(&kind_key, &state.inner.pool).await?;
match (&kind, &actual_status.wanted) {
(EventActorKind::Cargo, status)
if status != &ObjPsStatusKind::Stop.to_string()
|| status != &ObjPsStatusKind::Start.to_string() =>
{
ObjPsStatusDb::update_actual_status(
&kind_key,
&ObjPsStatusKind::Fail,
&state.inner.pool,
)
.await?;
let cargo =
CargoDb::transform_read_by_pk(&kind_key, &state.inner.pool).await?;
state.emit_warning_native_action(
&cargo,
NativeEventAction::Fail,
Some(format!("Process {name}")),
);
}
(EventActorKind::Vm, status)
if status != &ObjPsStatusKind::Stop.to_string()
|| status != &ObjPsStatusKind::Start.to_string() =>
{
ObjPsStatusDb::update_actual_status(
&kind_key,
&ObjPsStatusKind::Fail,
&state.inner.pool,
)
.await?;
let vm =
VmDb::transform_read_by_pk(&kind_key, &state.inner.pool).await?;
state.emit_warning_native_action(
&vm,
NativeEventAction::Fail,
Some(format!("Process {name}")),
);
if !name.starts_with("tmp-") {
let actual_status =
ObjPsStatusDb::read_by_pk(&kind_key, &state.inner.pool).await?;
match (&kind, &actual_status.wanted) {
(EventActorKind::Cargo, status)
if status != &ObjPsStatusKind::Stop.to_string()
|| status != &ObjPsStatusKind::Start.to_string() =>
{
ObjPsStatusDb::update_actual_status(
&kind_key,
&ObjPsStatusKind::Fail,
&state.inner.pool,
)
.await?;
let cargo =
CargoDb::transform_read_by_pk(&kind_key, &state.inner.pool)
.await?;
state.emit_warning_native_action(
&cargo,
NativeEventAction::Fail,
Some(format!("Process {name}")),
);
}
(EventActorKind::Vm, status)
if status != &ObjPsStatusKind::Stop.to_string()
|| status != &ObjPsStatusKind::Start.to_string() =>
{
ObjPsStatusDb::update_actual_status(
&kind_key,
&ObjPsStatusKind::Fail,
&state.inner.pool,
)
.await?;
let vm =
VmDb::transform_read_by_pk(&kind_key, &state.inner.pool).await?;
state.emit_warning_native_action(
&vm,
NativeEventAction::Fail,
Some(format!("Process {name}")),
);
}
_ => {}
}
_ => {}
}
action.clone_into(&mut event.action);
}
Expand Down
48 changes: 0 additions & 48 deletions doc/man/nanocl-cargo-image.md

This file was deleted.

73 changes: 0 additions & 73 deletions doc/man/nanocl-setup.md

This file was deleted.

Loading

0 comments on commit 77d4e51

Please sign in to comment.