use proxmox_offline_mirror::{
config::{save_config, MediaConfig, MirrorConfig},
mirror,
- types::{ProductType, MIRROR_ID_SCHEMA},
+ types::{ProductType, MEDIA_ID_SCHEMA, MIRROR_ID_SCHEMA},
};
mod proxmox_offline_mirror_cmds;
let id = loop {
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}");
id = read_string_from_tty("Enter medium ID", None)?;
}
use proxmox_offline_mirror::{
config::{MediaConfig, MediaConfigUpdater, MirrorConfig, MirrorConfigUpdater},
mirror,
- types::MIRROR_ID_SCHEMA,
+ types::{MEDIA_ID_SCHEMA, MIRROR_ID_SCHEMA},
};
pub const DEFAULT_CONFIG_PATH: &str = "/etc/proxmox-apt-mirror.cfg";
description: "Path to mirroring config file.",
},
id: {
- schema: MIRROR_ID_SCHEMA,
+ schema: MEDIA_ID_SCHEMA,
},
"output-format": {
schema: OUTPUT_FORMAT,
description: "Path to mirroring config file.",
},
id: {
- schema: MIRROR_ID_SCHEMA,
+ schema: MEDIA_ID_SCHEMA,
},
"remove-data": {
type: bool,
description: "Path to mirroring config file.",
},
id: {
- schema: MIRROR_ID_SCHEMA,
+ schema: MEDIA_ID_SCHEMA,
},
update: {
type: MediaConfigUpdater,
generate_repo_file_line,
medium::{self},
mirror,
- types::{ProductType, Snapshot, MIRROR_ID_SCHEMA},
+ types::{ProductType, Snapshot, MEDIA_ID_SCHEMA},
};
use super::DEFAULT_CONFIG_PATH;
description: "Path to mirroring config file.",
},
id: {
- schema: MIRROR_ID_SCHEMA,
+ schema: MEDIA_ID_SCHEMA,
},
"output-format": {
schema: OUTPUT_FORMAT,
description: "Path to mirroring config file.",
},
id: {
- schema: MIRROR_ID_SCHEMA,
+ schema: MEDIA_ID_SCHEMA,
},
"output-format": {
schema: OUTPUT_FORMAT,
description: "Path to mirroring config file.",
},
id: {
- schema: MIRROR_ID_SCHEMA,
+ schema: MEDIA_ID_SCHEMA,
},
"keys-only": {
type: bool,
pub fn medium_commands() -> CommandLineInterface {
let cmd_def = CliCommandMap::new()
- .insert("gc", CliCommand::new(&API_METHOD_GARBAGE_COLLECT))
- .insert("status", CliCommand::new(&API_METHOD_STATUS))
- .insert("sync", CliCommand::new(&API_METHOD_SYNC));
+ .insert(
+ "gc",
+ 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()
}
}
pub fn mirror_commands() -> CommandLineInterface {
let snapshot_cmds = CliCommandMap::new()
- .insert("create", CliCommand::new(&API_METHOD_CREATE_SNAPSHOT))
- .insert("list", CliCommand::new(&API_METHOD_LIST_SNAPSHOTS))
- .insert("remove", CliCommand::new(&API_METHOD_REMOVE_SNAPSHOT));
+ .insert(
+ "create",
+ 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()
.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()
}
pub fn key_commands() -> CommandLineInterface {
CliCommandMap::new()
- .insert("add", CliCommand::new(&API_METHOD_ADD_KEY))
+ .insert(
+ "add",
+ CliCommand::new(&API_METHOD_ADD_KEY).arg_param(&["key", "server-id"]),
+ )
.insert(
"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("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))
.into()
}
use proxmox_sys::fs::{replace_file, CreateOptions};
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(
properties: {
id: {
- schema: MIRROR_ID_SCHEMA,
+ schema: MEDIA_ID_SCHEMA,
},
mountpoint: {
type: String,
.max_length(32)
.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]
#[macro_export]
macro_rules! PROXMOX_SUBSCRIPTION_KEY_REGEX_STR { () => { r"(?:pom-|pve\d+[a-z]-|pbs[a-z]-|pmg[a-z]-).*" }; }