Skip to content

Commit 5cac506

Browse files
committed
feat: manager decide whether to enable encryption
Signed-off-by: chohee <[email protected]>
1 parent 273d418 commit 5cac506

File tree

6 files changed

+285
-137
lines changed

6 files changed

+285
-137
lines changed

pkg/apis/manager/v2/manager.pb.go

Lines changed: 200 additions & 129 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/manager/v2/manager.pb.validate.go

Lines changed: 25 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/manager/v2/manager.proto

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,20 @@ message RequestEncryptionKeyRequest {
312312
string ip = 3 [(validate.rules).string.ip = true];
313313
}
314314

315+
// Encryption status enumeration.
316+
enum EncryptionStatus {
317+
// Encryption is not enabled.
318+
ENCRYPTION_DISABLED = 0;
319+
// Encryption is enabled and key is provided.
320+
ENCRYPTION_ENABLED = 1;
321+
}
322+
315323
// RequestEncryptionKeyResponse represents response of RequestEncryptionKey.
316324
message RequestEncryptionKeyResponse {
317-
// Encryption key provided by manager.
318-
bytes encryption_key = 1;
325+
// Encryption status.
326+
EncryptionStatus status = 1 [(validate.rules).enum.defined_only = true];
327+
// Encryption key provided by manager (only present when status is ENCRYPTION_ENABLED).
328+
optional bytes encryption_key = 2 [(validate.rules).bytes = {min_len: 32, max_len: 1024}];
319329
}
320330

321331
// Manager RPC Service.

proto/manager.proto

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,20 @@ message RequestEncryptionKeyRequest {
309309
string ip = 3;
310310
}
311311

312+
// Encryption status enumeration.
313+
enum EncryptionStatus {
314+
// Encryption is not enabled.
315+
ENCRYPTION_DISABLED = 0;
316+
// Encryption is enabled and key is provided.
317+
ENCRYPTION_ENABLED = 1;
318+
}
319+
312320
// RequestEncryptionKeyResponse represents response of RequestEncryptionKey.
313321
message RequestEncryptionKeyResponse {
314-
// Encryption key provided by manager.
315-
bytes encryption_key = 1;
322+
// Encryption status.
323+
EncryptionStatus status = 1;
324+
// Encryption key provided by manager (only present when status is ENCRYPTION_ENABLED).
325+
optional bytes encryption_key = 2;
316326
}
317327

318328
// Manager RPC Service.

src/descriptor.bin

1.45 KB
Binary file not shown.

src/manager.v2.rs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,12 @@ pub struct RequestEncryptionKeyRequest {
418418
#[allow(clippy::derive_partial_eq_without_eq)]
419419
#[derive(Clone, PartialEq, ::prost::Message)]
420420
pub struct RequestEncryptionKeyResponse {
421-
/// Encryption key provided by manager.
422-
#[prost(bytes = "vec", tag = "1")]
423-
pub encryption_key: ::prost::alloc::vec::Vec<u8>,
421+
/// Encryption status.
422+
#[prost(enumeration = "EncryptionStatus", tag = "1")]
423+
pub status: i32,
424+
/// Encryption key provided by manager (only present when status is ENCRYPTION_ENABLED).
425+
#[prost(bytes = "vec", optional, tag = "2")]
426+
pub encryption_key: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
424427
}
425428
/// Request source type.
426429
#[derive(serde::Serialize, serde::Deserialize)]
@@ -456,6 +459,36 @@ impl SourceType {
456459
}
457460
}
458461
}
462+
/// Encryption status enumeration.
463+
#[derive(serde::Serialize, serde::Deserialize)]
464+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
465+
#[repr(i32)]
466+
pub enum EncryptionStatus {
467+
/// Encryption is not enabled.
468+
EncryptionDisabled = 0,
469+
/// Encryption is enabled and key is provided.
470+
EncryptionEnabled = 1,
471+
}
472+
impl EncryptionStatus {
473+
/// String value of the enum field names used in the ProtoBuf definition.
474+
///
475+
/// The values are not transformed in any way and thus are considered stable
476+
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
477+
pub fn as_str_name(&self) -> &'static str {
478+
match self {
479+
EncryptionStatus::EncryptionDisabled => "ENCRYPTION_DISABLED",
480+
EncryptionStatus::EncryptionEnabled => "ENCRYPTION_ENABLED",
481+
}
482+
}
483+
/// Creates an enum from field names used in the ProtoBuf definition.
484+
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
485+
match value {
486+
"ENCRYPTION_DISABLED" => Some(Self::EncryptionDisabled),
487+
"ENCRYPTION_ENABLED" => Some(Self::EncryptionEnabled),
488+
_ => None,
489+
}
490+
}
491+
}
459492
/// Generated client implementations.
460493
pub mod manager_client {
461494
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]

0 commit comments

Comments
 (0)