mirror of
https://git.proxmox.com/git/proxmox-offline-mirror
synced 2025-08-09 18:04:49 +00:00
improve interfaces and descriptions
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
a9f22be14c
commit
b42cad3b8e
@ -15,7 +15,7 @@ use proxmox_offline_mirror::helpers::tty::{
|
|||||||
use proxmox_offline_mirror::{
|
use proxmox_offline_mirror::{
|
||||||
config::{save_config, MediaConfig, MirrorConfig},
|
config::{save_config, MediaConfig, MirrorConfig},
|
||||||
mirror,
|
mirror,
|
||||||
types::{ProductType, MIRROR_ID_SCHEMA},
|
types::{ProductType, MEDIA_ID_SCHEMA, MIRROR_ID_SCHEMA},
|
||||||
};
|
};
|
||||||
|
|
||||||
mod proxmox_offline_mirror_cmds;
|
mod proxmox_offline_mirror_cmds;
|
||||||
@ -463,7 +463,7 @@ fn action_add_medium(config: &SectionConfigData) -> Result<MediaConfig, Error> {
|
|||||||
|
|
||||||
let id = loop {
|
let id = loop {
|
||||||
let mut id = read_string_from_tty("Enter medium ID", None)?;
|
let mut id = read_string_from_tty("Enter medium ID", None)?;
|
||||||
while let Err(err) = MIRROR_ID_SCHEMA.parse_simple_value(&id) {
|
while let Err(err) = MEDIA_ID_SCHEMA.parse_simple_value(&id) {
|
||||||
eprintln!("Not a valid medium ID: {err}");
|
eprintln!("Not a valid medium ID: {err}");
|
||||||
id = read_string_from_tty("Enter medium ID", None)?;
|
id = read_string_from_tty("Enter medium ID", None)?;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use proxmox_schema::{api, param_bail, ApiType, ArraySchema, ReturnType};
|
|||||||
use proxmox_offline_mirror::{
|
use proxmox_offline_mirror::{
|
||||||
config::{MediaConfig, MediaConfigUpdater, MirrorConfig, MirrorConfigUpdater},
|
config::{MediaConfig, MediaConfigUpdater, MirrorConfig, MirrorConfigUpdater},
|
||||||
mirror,
|
mirror,
|
||||||
types::MIRROR_ID_SCHEMA,
|
types::{MEDIA_ID_SCHEMA, MIRROR_ID_SCHEMA},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DEFAULT_CONFIG_PATH: &str = "/etc/proxmox-apt-mirror.cfg";
|
pub const DEFAULT_CONFIG_PATH: &str = "/etc/proxmox-apt-mirror.cfg";
|
||||||
@ -313,7 +313,7 @@ async fn list_media(config: Option<String>, param: Value) -> Result<Value, Error
|
|||||||
description: "Path to mirroring config file.",
|
description: "Path to mirroring config file.",
|
||||||
},
|
},
|
||||||
id: {
|
id: {
|
||||||
schema: MIRROR_ID_SCHEMA,
|
schema: MEDIA_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
"output-format": {
|
"output-format": {
|
||||||
schema: OUTPUT_FORMAT,
|
schema: OUTPUT_FORMAT,
|
||||||
@ -392,7 +392,7 @@ async fn add_medium(
|
|||||||
description: "Path to mirroring config file.",
|
description: "Path to mirroring config file.",
|
||||||
},
|
},
|
||||||
id: {
|
id: {
|
||||||
schema: MIRROR_ID_SCHEMA,
|
schema: MEDIA_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
"remove-data": {
|
"remove-data": {
|
||||||
type: bool,
|
type: bool,
|
||||||
@ -444,7 +444,7 @@ async fn remove_medium(
|
|||||||
description: "Path to mirroring config file.",
|
description: "Path to mirroring config file.",
|
||||||
},
|
},
|
||||||
id: {
|
id: {
|
||||||
schema: MIRROR_ID_SCHEMA,
|
schema: MEDIA_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
type: MediaConfigUpdater,
|
type: MediaConfigUpdater,
|
||||||
|
@ -14,7 +14,7 @@ use proxmox_offline_mirror::{
|
|||||||
generate_repo_file_line,
|
generate_repo_file_line,
|
||||||
medium::{self},
|
medium::{self},
|
||||||
mirror,
|
mirror,
|
||||||
types::{ProductType, Snapshot, MIRROR_ID_SCHEMA},
|
types::{ProductType, Snapshot, MEDIA_ID_SCHEMA},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::DEFAULT_CONFIG_PATH;
|
use super::DEFAULT_CONFIG_PATH;
|
||||||
@ -28,7 +28,7 @@ use super::DEFAULT_CONFIG_PATH;
|
|||||||
description: "Path to mirroring config file.",
|
description: "Path to mirroring config file.",
|
||||||
},
|
},
|
||||||
id: {
|
id: {
|
||||||
schema: MIRROR_ID_SCHEMA,
|
schema: MEDIA_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
"output-format": {
|
"output-format": {
|
||||||
schema: OUTPUT_FORMAT,
|
schema: OUTPUT_FORMAT,
|
||||||
@ -62,7 +62,7 @@ async fn garbage_collect(
|
|||||||
description: "Path to mirroring config file.",
|
description: "Path to mirroring config file.",
|
||||||
},
|
},
|
||||||
id: {
|
id: {
|
||||||
schema: MIRROR_ID_SCHEMA,
|
schema: MEDIA_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
"output-format": {
|
"output-format": {
|
||||||
schema: OUTPUT_FORMAT,
|
schema: OUTPUT_FORMAT,
|
||||||
@ -180,7 +180,7 @@ fn get_subscription_keys(
|
|||||||
description: "Path to mirroring config file.",
|
description: "Path to mirroring config file.",
|
||||||
},
|
},
|
||||||
id: {
|
id: {
|
||||||
schema: MIRROR_ID_SCHEMA,
|
schema: MEDIA_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
"keys-only": {
|
"keys-only": {
|
||||||
type: bool,
|
type: bool,
|
||||||
@ -222,9 +222,15 @@ async fn sync(
|
|||||||
|
|
||||||
pub fn medium_commands() -> CommandLineInterface {
|
pub fn medium_commands() -> CommandLineInterface {
|
||||||
let cmd_def = CliCommandMap::new()
|
let cmd_def = CliCommandMap::new()
|
||||||
.insert("gc", CliCommand::new(&API_METHOD_GARBAGE_COLLECT))
|
.insert(
|
||||||
.insert("status", CliCommand::new(&API_METHOD_STATUS))
|
"gc",
|
||||||
.insert("sync", CliCommand::new(&API_METHOD_SYNC));
|
CliCommand::new(&API_METHOD_GARBAGE_COLLECT).arg_param(&["id"]),
|
||||||
|
)
|
||||||
|
.insert(
|
||||||
|
"status",
|
||||||
|
CliCommand::new(&API_METHOD_STATUS).arg_param(&["id"]),
|
||||||
|
)
|
||||||
|
.insert("sync", CliCommand::new(&API_METHOD_SYNC).arg_param(&["id"]));
|
||||||
|
|
||||||
cmd_def.into()
|
cmd_def.into()
|
||||||
}
|
}
|
||||||
|
@ -177,13 +177,25 @@ async fn garbage_collect(config: Option<String>, id: String, _param: Value) -> R
|
|||||||
}
|
}
|
||||||
pub fn mirror_commands() -> CommandLineInterface {
|
pub fn mirror_commands() -> CommandLineInterface {
|
||||||
let snapshot_cmds = CliCommandMap::new()
|
let snapshot_cmds = CliCommandMap::new()
|
||||||
.insert("create", CliCommand::new(&API_METHOD_CREATE_SNAPSHOT))
|
.insert(
|
||||||
.insert("list", CliCommand::new(&API_METHOD_LIST_SNAPSHOTS))
|
"create",
|
||||||
.insert("remove", CliCommand::new(&API_METHOD_REMOVE_SNAPSHOT));
|
CliCommand::new(&API_METHOD_CREATE_SNAPSHOT).arg_param(&["id"]),
|
||||||
|
)
|
||||||
|
.insert(
|
||||||
|
"list",
|
||||||
|
CliCommand::new(&API_METHOD_LIST_SNAPSHOTS).arg_param(&["id"]),
|
||||||
|
)
|
||||||
|
.insert(
|
||||||
|
"remove",
|
||||||
|
CliCommand::new(&API_METHOD_REMOVE_SNAPSHOT).arg_param(&["id", "snapshot"]),
|
||||||
|
);
|
||||||
|
|
||||||
let cmd_def = CliCommandMap::new()
|
let cmd_def = CliCommandMap::new()
|
||||||
.insert("snapshot", snapshot_cmds)
|
.insert("snapshot", snapshot_cmds)
|
||||||
.insert("gc", CliCommand::new(&API_METHOD_GARBAGE_COLLECT));
|
.insert(
|
||||||
|
"gc",
|
||||||
|
CliCommand::new(&API_METHOD_GARBAGE_COLLECT).arg_param(&["id"]),
|
||||||
|
);
|
||||||
|
|
||||||
cmd_def.into()
|
cmd_def.into()
|
||||||
}
|
}
|
||||||
|
@ -348,14 +348,23 @@ async fn remove_key(config: Option<String>, key: String, _param: Value) -> Resul
|
|||||||
|
|
||||||
pub fn key_commands() -> CommandLineInterface {
|
pub fn key_commands() -> CommandLineInterface {
|
||||||
CliCommandMap::new()
|
CliCommandMap::new()
|
||||||
.insert("add", CliCommand::new(&API_METHOD_ADD_KEY))
|
.insert(
|
||||||
|
"add",
|
||||||
|
CliCommand::new(&API_METHOD_ADD_KEY).arg_param(&["key", "server-id"]),
|
||||||
|
)
|
||||||
.insert(
|
.insert(
|
||||||
"add-mirror-key",
|
"add-mirror-key",
|
||||||
CliCommand::new(&API_METHOD_ADD_MIRROR_KEY),
|
CliCommand::new(&API_METHOD_ADD_MIRROR_KEY).arg_param(&["key"]),
|
||||||
|
)
|
||||||
|
.insert(
|
||||||
|
"update",
|
||||||
|
CliCommand::new(&API_METHOD_UPDATE_KEY).arg_param(&["key"]),
|
||||||
)
|
)
|
||||||
.insert("update", CliCommand::new(&API_METHOD_UPDATE_KEY))
|
|
||||||
.insert("refresh", CliCommand::new(&API_METHOD_REFRESH_KEYS))
|
.insert("refresh", CliCommand::new(&API_METHOD_REFRESH_KEYS))
|
||||||
.insert("remove", CliCommand::new(&API_METHOD_REMOVE_KEY))
|
.insert(
|
||||||
|
"remove",
|
||||||
|
CliCommand::new(&API_METHOD_REMOVE_KEY).arg_param(&["key"]),
|
||||||
|
)
|
||||||
.insert("list", CliCommand::new(&API_METHOD_LIST_KEYS))
|
.insert("list", CliCommand::new(&API_METHOD_LIST_KEYS))
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlug
|
|||||||
use proxmox_sys::fs::{replace_file, CreateOptions};
|
use proxmox_sys::fs::{replace_file, CreateOptions};
|
||||||
|
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
ProductType, MIRROR_ID_SCHEMA, PROXMOX_SERVER_ID_SCHEMA, PROXMOX_SUBSCRIPTION_KEY_SCHEMA,
|
ProductType, MEDIA_ID_SCHEMA, MIRROR_ID_SCHEMA, PROXMOX_SERVER_ID_SCHEMA,
|
||||||
|
PROXMOX_SUBSCRIPTION_KEY_SCHEMA,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
@ -69,7 +70,7 @@ pub struct MirrorConfig {
|
|||||||
#[api(
|
#[api(
|
||||||
properties: {
|
properties: {
|
||||||
id: {
|
id: {
|
||||||
schema: MIRROR_ID_SCHEMA,
|
schema: MEDIA_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
mountpoint: {
|
mountpoint: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -26,6 +26,13 @@ pub const MIRROR_ID_SCHEMA: Schema = StringSchema::new("Mirror name.")
|
|||||||
.max_length(32)
|
.max_length(32)
|
||||||
.schema();
|
.schema();
|
||||||
|
|
||||||
|
/// Schema for config IDs
|
||||||
|
pub const MEDIA_ID_SCHEMA: Schema = StringSchema::new("Medium name.")
|
||||||
|
.format(&PROXMOX_SAFE_ID_FORMAT)
|
||||||
|
.min_length(3)
|
||||||
|
.max_length(32)
|
||||||
|
.schema();
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! PROXMOX_SUBSCRIPTION_KEY_REGEX_STR { () => { r"(?:pom-|pve\d+[a-z]-|pbs[a-z]-|pmg[a-z]-).*" }; }
|
macro_rules! PROXMOX_SUBSCRIPTION_KEY_REGEX_STR { () => { r"(?:pom-|pve\d+[a-z]-|pbs[a-z]-|pmg[a-z]-).*" }; }
|
||||||
|
Loading…
Reference in New Issue
Block a user