clonable config
This commit is contained in:
+8
-8
@@ -11,7 +11,7 @@ pub mod logger;
|
|||||||
pub mod proxy;
|
pub mod proxy;
|
||||||
pub mod rc;
|
pub mod rc;
|
||||||
|
|
||||||
#[derive(Debug, Default, serde::Deserialize, serde::Serialize)]
|
#[derive(Debug, Default, Clone, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub layers: Vec<String>,
|
pub layers: Vec<String>,
|
||||||
pub root_user: RootUser,
|
pub root_user: RootUser,
|
||||||
@@ -25,14 +25,14 @@ pub struct Config {
|
|||||||
pub users: Vec<User>,
|
pub users: Vec<User>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, serde::Deserialize, serde::Serialize)]
|
#[derive(Debug, Default, Clone, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct RootUser {
|
pub struct RootUser {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub password_hash: Option<String>,
|
pub password_hash: Option<String>,
|
||||||
pub authorized_keys: Vec<String>,
|
pub authorized_keys: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, serde::Deserialize, serde::Serialize)]
|
#[derive(Debug, Default, Clone, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct Mount {
|
pub struct Mount {
|
||||||
pub dev: String,
|
pub dev: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
@@ -42,14 +42,14 @@ pub struct Mount {
|
|||||||
pub options: Option<String>,
|
pub options: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct Group {
|
pub struct Group {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub gid: Option<u32>,
|
pub gid: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@@ -58,7 +58,7 @@ pub struct User {
|
|||||||
pub gid: Option<u32>,
|
pub gid: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct File {
|
pub struct File {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@@ -111,12 +111,12 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn base64_decode(s: &str) -> Result<Vec<u8>, base64::DecodeError> {
|
pub fn base64_decode(s: &str) -> Result<Vec<u8>, base64::DecodeError> {
|
||||||
use base64::{Engine as _, prelude::BASE64_STANDARD_NO_PAD as B64};
|
use base64::{prelude::BASE64_STANDARD_NO_PAD as B64, Engine as _};
|
||||||
B64.decode(s.trim_end_matches('='))
|
B64.decode(s.trim_end_matches('='))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn base64_encode(b: &[u8]) -> String {
|
pub fn base64_encode(b: &[u8]) -> String {
|
||||||
use base64::{Engine as _, prelude::BASE64_STANDARD as B64};
|
use base64::{prelude::BASE64_STANDARD as B64, Engine as _};
|
||||||
B64.encode(b)
|
B64.encode(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user