git_mirror/provider/
mod.rs

1/*
2 * Copyright (c) 2017 Pascal Bach
3 *
4 * SPDX-License-Identifier:     MIT
5 */
6
7use thiserror::Error;
8/// A representation of a mirror job from origin to destination
9#[derive(Debug)]
10pub struct Mirror {
11    pub origin: String,
12    pub destination: String,
13    pub refspec: Option<Vec<String>>,
14    pub lfs: bool,
15}
16
17/// An error occuring during mirror creation
18#[derive(Debug, Error)]
19pub enum MirrorError {
20    #[error("data store disconnected")]
21    Description(String, serde_yaml::Error),
22    #[error("entry explicitly skipped")]
23    Skip(String),
24}
25
26#[inline]
27pub fn bool_true() -> bool {
28    true
29}
30
31pub type MirrorResult = Result<Mirror, MirrorError>;
32
33/// A structured description
34#[derive(Deserialize, Debug)]
35struct Desc {
36    origin: String,
37    #[serde(default)]
38    skip: bool,
39    refspec: Option<Vec<String>>,
40    #[serde(default = "bool_true")]
41    lfs: bool,
42}
43
44pub trait Provider {
45    fn get_mirror_repos(&self) -> Result<Vec<MirrorResult>, String>;
46    fn get_label(&self) -> String;
47}
48
49mod gitlab;
50pub use self::gitlab::GitLab;
51
52mod github;
53pub use self::github::GitHub;