mirror of
https://git.proxmox.com/git/proxmox
synced 2025-06-04 13:18:45 +00:00
system-config-api: use cargo features to sparate functionality
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
770c5dbd03
commit
3e8b0ee567
@ -22,7 +22,21 @@ proxmox-schema = { workspace = true, features = ["api-macro", "api-types"] }
|
||||
proxmox-time = { workspace = true, optional = true }
|
||||
proxmox-product-config = { workspace = true, optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
default = [ "proxmox-product-config/default" ]
|
||||
impl = [ "dep:proxmox-sys", "dep:proxmox-time", "proxmox-product-config/impl"]
|
||||
default = []
|
||||
dns = ["dep:proxmox-product-config"]
|
||||
dns-impl = [
|
||||
"dns",
|
||||
"dep:proxmox-product-config",
|
||||
"proxmox-product-config?/impl",
|
||||
"dep:proxmox-sys",
|
||||
"dep:proxmox-time",
|
||||
]
|
||||
time = []
|
||||
time-impl = [
|
||||
"time",
|
||||
"dep:proxmox-product-config",
|
||||
"proxmox-product-config?/impl",
|
||||
"dep:proxmox-sys",
|
||||
"dep:proxmox-time",
|
||||
]
|
||||
|
@ -2,7 +2,6 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox_schema::api;
|
||||
use proxmox_schema::api_types::IP_FORMAT;
|
||||
use proxmox_schema::api_types::TIME_ZONE_SCHEMA;
|
||||
use proxmox_schema::Schema;
|
||||
use proxmox_schema::StringSchema;
|
||||
|
||||
@ -93,28 +92,3 @@ pub enum DeletableResolvConfProperty {
|
||||
/// Delete third nameserver entry
|
||||
Dns3,
|
||||
}
|
||||
|
||||
#[api(
|
||||
properties: {
|
||||
timezone: {
|
||||
schema: TIME_ZONE_SCHEMA,
|
||||
},
|
||||
time: {
|
||||
type: i64,
|
||||
description: "Seconds since 1970-01-01 00:00:00 UTC.",
|
||||
minimum: 1_297_163_644,
|
||||
},
|
||||
localtime: {
|
||||
type: i64,
|
||||
description: "Seconds since 1970-01-01 00:00:00 UTC. (local time)",
|
||||
minimum: 1_297_163_644,
|
||||
},
|
||||
}
|
||||
)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
/// Server time and timezone.
|
||||
pub struct ServerTimeInfo {
|
||||
pub timezone: String,
|
||||
pub time: i64,
|
||||
pub localtime: i64,
|
||||
}
|
7
proxmox-system-config-api/src/dns/mod.rs
Normal file
7
proxmox-system-config-api/src/dns/mod.rs
Normal file
@ -0,0 +1,7 @@
|
||||
mod api_types;
|
||||
pub use api_types::*;
|
||||
|
||||
#[cfg(feature = "dns-impl")]
|
||||
mod resolv_conf;
|
||||
#[cfg(feature = "dns-impl")]
|
||||
pub use resolv_conf::*;
|
@ -13,9 +13,9 @@ use proxmox_sys::fs::CreateOptions;
|
||||
|
||||
use proxmox_schema::api_types::IPRE_STR;
|
||||
|
||||
use crate::DeletableResolvConfProperty;
|
||||
use crate::ResolvConf;
|
||||
use crate::ResolvConfWithDigest;
|
||||
use super::DeletableResolvConfProperty;
|
||||
use super::ResolvConf;
|
||||
use super::ResolvConfWithDigest;
|
||||
|
||||
static RESOLV_CONF_FN: &str = "/etc/resolv.conf";
|
||||
|
@ -1,13 +1,5 @@
|
||||
mod api_types;
|
||||
pub use api_types::ServerTimeInfo;
|
||||
pub use api_types::{DeletableResolvConfProperty, ResolvConf, ResolvConfWithDigest};
|
||||
pub use api_types::{
|
||||
FIRST_DNS_SERVER_SCHEMA, SEARCH_DOMAIN_SCHEMA, SECOND_DNS_SERVER_SCHEMA,
|
||||
THIRD_DNS_SERVER_SCHEMA,
|
||||
};
|
||||
#[cfg(feature = "dns")]
|
||||
pub mod dns;
|
||||
|
||||
#[cfg(feature = "impl")]
|
||||
pub mod resolv_conf;
|
||||
|
||||
#[cfg(feature = "impl")]
|
||||
#[cfg(feature = "time")]
|
||||
pub mod time;
|
||||
|
29
proxmox-system-config-api/src/time/api_types.rs
Normal file
29
proxmox-system-config-api/src/time/api_types.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox_schema::api;
|
||||
use proxmox_schema::api_types::TIME_ZONE_SCHEMA;
|
||||
|
||||
#[api(
|
||||
properties: {
|
||||
timezone: {
|
||||
schema: TIME_ZONE_SCHEMA,
|
||||
},
|
||||
time: {
|
||||
type: i64,
|
||||
description: "Seconds since 1970-01-01 00:00:00 UTC.",
|
||||
minimum: 1_297_163_644,
|
||||
},
|
||||
localtime: {
|
||||
type: i64,
|
||||
description: "Seconds since 1970-01-01 00:00:00 UTC. (local time)",
|
||||
minimum: 1_297_163_644,
|
||||
},
|
||||
}
|
||||
)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
/// Server time and timezone.
|
||||
pub struct ServerTimeInfo {
|
||||
pub timezone: String,
|
||||
pub time: i64,
|
||||
pub localtime: i64,
|
||||
}
|
7
proxmox-system-config-api/src/time/mod.rs
Normal file
7
proxmox-system-config-api/src/time/mod.rs
Normal file
@ -0,0 +1,7 @@
|
||||
mod api_types;
|
||||
pub use api_types::*;
|
||||
|
||||
#[cfg(feature = "time-impl")]
|
||||
mod time_impl;
|
||||
#[cfg(feature = "time-impl")]
|
||||
pub use time_impl::*;
|
@ -3,7 +3,7 @@ use anyhow::{bail, format_err, Error};
|
||||
use proxmox_product_config::replace_system_config;
|
||||
use proxmox_sys::fs::file_read_firstline;
|
||||
|
||||
use crate::api_types::ServerTimeInfo;
|
||||
use super::ServerTimeInfo;
|
||||
|
||||
pub fn read_etc_localtime() -> Result<String, Error> {
|
||||
// use /etc/timezone
|
Loading…
Reference in New Issue
Block a user