Skip to content

Commit

Permalink
fix/nanocld: update event for secret and resource (#907)
Browse files Browse the repository at this point in the history
* fix/nanocld: update event for secret and resource
  • Loading branch information
leon3s authored May 6, 2024
1 parent b3667f7 commit 2327324
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 83 deletions.
64 changes: 0 additions & 64 deletions bin/nanocld/specs/swagger.yaml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion bin/nanocld/src/objects/generic/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pub trait ObjPatchByPk {
type ObjPatchIn;
type ObjPatchOut;

fn get_patch_event() -> NativeEventAction {
NativeEventAction::Updating
}

async fn fn_patch_obj_by_pk(
pk: &str,
obj: &Self::ObjPatchIn,
Expand All @@ -22,7 +26,7 @@ pub trait ObjPatchByPk {
Self::ObjPatchOut: Into<EventActor> + Clone,
{
let obj = Self::fn_patch_obj_by_pk(pk, obj, state).await?;
state.emit_normal_native_action(&obj, NativeEventAction::Updating);
state.emit_normal_native_action(&obj, Self::get_patch_event());
Ok(obj)
}
}
6 changes: 5 additions & 1 deletion bin/nanocld/src/objects/generic/put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pub trait ObjPutByPk {
type ObjPutIn;
type ObjPutOut;

fn get_put_event() -> NativeEventAction {
NativeEventAction::Updating
}

async fn fn_put_obj_by_pk(
pk: &str,
obj: &Self::ObjPutIn,
Expand All @@ -22,7 +26,7 @@ pub trait ObjPutByPk {
Self::ObjPutOut: Into<EventActor> + Clone,
{
let obj = Self::fn_put_obj_by_pk(pk, obj, state).await?;
state.emit_normal_native_action(&obj, NativeEventAction::Updating);
state.emit_normal_native_action(&obj, Self::get_put_event());
Ok(obj)
}
}
9 changes: 8 additions & 1 deletion bin/nanocld/src/objects/resource.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use nanocl_error::http::{HttpResult, HttpError};
use nanocl_stubs::resource::{ResourcePartial, Resource};
use nanocl_stubs::{
resource::{Resource, ResourcePartial},
system::NativeEventAction,
};

use crate::{
repositories::generic::*,
Expand Down Expand Up @@ -60,6 +63,10 @@ impl ObjPutByPk for ResourceDb {
type ObjPutIn = ResourcePartial;
type ObjPutOut = Resource;

fn get_put_event() -> NativeEventAction {
NativeEventAction::Update
}

async fn fn_put_obj_by_pk(
pk: &str,
obj: &Self::ObjPutIn,
Expand Down
9 changes: 8 additions & 1 deletion bin/nanocld/src/objects/secret.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use nanocl_error::http::HttpResult;
use nanocl_stubs::secret::{Secret, SecretPartial, SecretUpdate};
use nanocl_stubs::{
secret::{Secret, SecretPartial, SecretUpdate},
system::NativeEventAction,
};

use crate::{
repositories::generic::*,
Expand Down Expand Up @@ -41,6 +44,10 @@ impl ObjPatchByPk for SecretDb {
type ObjPatchIn = SecretUpdate;
type ObjPatchOut = Secret;

fn get_patch_event() -> NativeEventAction {
NativeEventAction::Update
}

async fn fn_patch_obj_by_pk(
pk: &str,
obj: &Self::ObjPatchIn,
Expand Down
2 changes: 0 additions & 2 deletions bin/ncdns/specs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ paths:
tags:
- Rules
summary: Create/Update a new DnsRule
description: Create/Update a new DnsRule
operationId: apply_rule
parameters:
- name: name
Expand All @@ -58,7 +57,6 @@ paths:
tags:
- Rules
summary: Delete a ProxyRule
description: Delete a ProxyRule
operationId: remove_rule
parameters:
- name: name
Expand Down
2 changes: 0 additions & 2 deletions bin/ncproxy/specs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ paths:
tags:
- Rules
summary: Create/Update a new ProxyRule
description: Create/Update a new ProxyRule
operationId: apply_rule
parameters:
- name: name
Expand All @@ -61,7 +60,6 @@ paths:
tags:
- Rules
summary: Delete a ProxyRule
description: Delete a ProxyRule
operationId: remove_rule
parameters:
- name: name
Expand Down
10 changes: 5 additions & 5 deletions bin/ncproxy/src/models/templates/http.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ server {
ssl_certificate {{ssl.Certificate}};
ssl_certificate_key {{ssl.CertificateKey}};{% if ssl.Dhparam %}
ssl_dhparam {{ssl.Dhparam}};
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 4h;
ssl_handshake_timeout 30s;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 4h;
ssl_handshake_timeout 30s;
{% endif %}{% if ssl.CertificateClient %}ssl_client_certificate {{ssl.CertificateClient}};
{% endif %}{% if ssl.VerifyClient %}
ssl_verify_client on;
Expand Down
10 changes: 5 additions & 5 deletions bin/ncproxy/src/models/templates/stream.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ server {
{% if ssl %}
ssl_certificate {{ ssl.Certificate }};
ssl_certificate_key {{ ssl.CertificateKey }};
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 4h;
ssl_handshake_timeout 30s;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 4h;
ssl_handshake_timeout 30s;
{% if ssl.Dhparam %}
ssl_dhparam {{ ssl.Dhparam }};
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion bin/ncproxy/src/utils/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub async fn gen_ssl_config(
let key_path = format!("{secret_path}.key");
tokio::fs::write(&key_path, ssl_config.certificate_key.clone()).await?;
if let Some(certificate_client) = ssl_config.certificate_client {
let certificate_client_path = format!("{secret_path}.client.cert");
let certificate_client_path = format!("{secret_path}.ca");
tokio::fs::write(&certificate_client_path, certificate_client).await?;
ssl_config.certificate_client = Some(certificate_client_path);
}
Expand Down

0 comments on commit 2327324

Please sign in to comment.