mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-20 03:11:14 +00:00
Make use of FilesystemDefaults when constructing migrate commands
This commit is contained in:
parent
a3a986638d
commit
1214b51ad7
3 changed files with 31 additions and 16 deletions
19
README.md
19
README.md
|
@ -417,17 +417,16 @@ $ pict-rs \
|
|||
-p /path/to/sled-repo
|
||||
```
|
||||
|
||||
~~If you are running the docker container with default paths, it can be simplified to the following:~~
|
||||
_currently broken, will fix for next release candidate_
|
||||
If you are running the docker container with default paths, it can be simplified to the following:
|
||||
```bash
|
||||
# pict-rs \
|
||||
# filesystem \
|
||||
# object-storage \
|
||||
# -e https://object-storage-endpoint \
|
||||
# -b bucket-name \
|
||||
# -r region \
|
||||
# -a access-key \
|
||||
# -s secret-key
|
||||
$ pict-rs \
|
||||
filesystem \
|
||||
object-storage \
|
||||
-e https://object-storage-endpoint \
|
||||
-b bucket-name \
|
||||
-r region \
|
||||
-a access-key \
|
||||
-s secret-key
|
||||
```
|
||||
|
||||
_This command must be run while pict-rs is offline._
|
||||
|
|
|
@ -551,7 +551,7 @@ enum MigrateStoreInner {
|
|||
#[derive(Debug, Parser)]
|
||||
struct MigrateFilesystem {
|
||||
#[command(flatten)]
|
||||
from: crate::config::primitives::Filesystem,
|
||||
from: Filesystem,
|
||||
|
||||
#[command(subcommand)]
|
||||
to: MigrateStoreInner,
|
||||
|
@ -561,7 +561,7 @@ struct MigrateFilesystem {
|
|||
#[derive(Debug, Parser)]
|
||||
struct MigrateFilesystemInner {
|
||||
#[command(flatten)]
|
||||
to: crate::config::primitives::Filesystem,
|
||||
to: Filesystem,
|
||||
|
||||
#[command(subcommand)]
|
||||
repo: Option<Repo>,
|
||||
|
@ -619,10 +619,10 @@ enum Repo {
|
|||
/// Configuration for filesystem media storage
|
||||
#[derive(Clone, Debug, Parser, serde::Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
struct Filesystem {
|
||||
pub(super) struct Filesystem {
|
||||
/// The path to store uploaded media
|
||||
#[arg(short, long)]
|
||||
path: Option<PathBuf>,
|
||||
pub(super) path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// Configuration for Object Storage
|
||||
|
|
|
@ -101,13 +101,13 @@ struct SledDefaults {
|
|||
#[derive(Clone, Debug, serde::Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[serde(tag = "type")]
|
||||
enum StoreDefaults {
|
||||
pub(super) enum StoreDefaults {
|
||||
Filesystem(FilesystemDefaults),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
struct FilesystemDefaults {
|
||||
pub(super) struct FilesystemDefaults {
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
|
@ -221,3 +221,19 @@ impl Default for FilesystemDefaults {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::config::commandline::Filesystem> for crate::config::primitives::Filesystem {
|
||||
fn from(value: crate::config::commandline::Filesystem) -> Self {
|
||||
Self {
|
||||
path: value
|
||||
.path
|
||||
.unwrap_or_else(|| FilesystemDefaults::default().path),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::config::commandline::Filesystem> for crate::config::primitives::Store {
|
||||
fn from(value: crate::config::commandline::Filesystem) -> Self {
|
||||
crate::config::primitives::Store::Filesystem(value.into())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue