1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
mod git;
mod http;
mod image;
mod local;

pub use self::git::GitSource;
pub use self::http::HttpSource;
pub use self::image::{ImageSource, ResolveMode};
pub use self::local::LocalSource;

/// Provide an input for other operations. For example: `FROM` directive in Dockerfile.
#[derive(Debug)]
pub struct Source;

impl Source {
    pub fn image<S>(name: S) -> ImageSource
    where
        S: Into<String>,
    {
        ImageSource::new(name)
    }

    pub fn git<S>(url: S) -> GitSource
    where
        S: Into<String>,
    {
        GitSource::new(url)
    }

    pub fn local<S>(name: S) -> LocalSource
    where
        S: Into<String>,
    {
        LocalSource::new(name)
    }

    pub fn http<S>(name: S) -> HttpSource
    where
        S: Into<String>,
    {
        HttpSource::new(name)
    }
}